Assignment title: Information
CPSC-501 OOP with Design Patterns
Assignment 3: Student Templated Class
Due: November 29th, 2016 at 11:59 PM
For this assignment, you will be creating a templated class with the name "Student" that will
act as a container adapter. The class will have the following properties:
1. Student name: as std::string. (private)
2. Student ID number: as std::string. (private)
3. Student grades: as std::vector of the type T (the student class template type name)
(private)
4. An iterator to traverse the student grades. (public)
The class will also have the following methods (None should be inline, but all methods
should be declared inside the header file):
1. A set of constructors
2. A constructor that accepts a file path, reads the first line of the path and convert
and parse it. Use the sample file data.txt from the assignment folder, it's a comma
separated string where the first value is the name, the second is the id, and the rest
are grades. (This constructor will have a specialized version for int so that you can
use stoi method, for generic types just read name and id).
3. begin(): returns an iterator that points to the first grade in the student grades.
4. end(): returns an iterator that points to the last grade in the student grades.
5. get_student_name(): a getter for student name data member.
6. set_student_name(): a setter for the student name data member.
7. get_student_id(): a getter for student id data member.
8. set_student_id(): a setter for the student id data member.
9. get_gpa(): this method will compute the average of the student grades and return a
value of the type T (so it should be templated).
10. Specialized get_gpa() method for the type string: if the grade is string ("A", "A-",
"B+", "B", "B-", "C+", "C", "C-", "D"), then a different calculation is required, so this
method is required.
11. push_back(T): it accepts a value of the type T and insert it at the end of the student
grades.
12. size(): to get the number of grades in the student grades.
13. Overload the operator [] to get a grade at a specific location.
14. Any other method that is required to make the class work with Source.cpp.
Use the file Source.cpp as your main source file. Don't change anything in that file, your
Student.h file is supposed to work with Source.cpp. Use only standard data structures and
objects, no third-party libraries (Don't use Boost or any similar libraries).For the submission, just upload the file Student.h through Canvas.
Source.cpp
data.txt
#include
#include "Student.h"
#include
using namespace std;
template
void display_student(Student & const st)
{
cout< 0)
{
Student::iterator it = st.begin();
while(it != st.end())
{
cout<<*it<<", ";
++it;
}
}
cout< jane("Jane", "0123455");
jane.push_back("A");
jane.push_back("B+");
jane.push_back("A-");
cout< john("John", "0123456");
john.push_back(3.4);
john.push_back(3.7);
john.push_back(4);
display_student(john);
std::string file_path = "";
cout<<"Enter the full file path: ";
cin>>file_path;
Student patel(file_path);
display_student(patel);
system("pause");
}
Patel,999999,95,94,96