Question
In C++ format, only Registrar.h and Registrar.cpp //TO BE COMPLETED sections need to be complete. main.cpp below does not need to be changed. /// Registrar.h
In C++ format, only Registrar.h and Registrar.cpp "//TO BE COMPLETED" sections need to be complete. main.cpp below does not need to be changed.
/// Registrar.h - NEEDS COMPLETION ///
#include
#include
#include "Student.h"
using namespace std;
class Registrar {
public:
void readTextfile(string filename); // Load information from a text file with the given filename: THIS IS COMPLETE
void addLine(string courseName, string cwid, char grade); // process a line from the text file
Student& getStudent(string cwid) const; // return the Student object corresponding to a given CWID
// getStudent must throw an exception if cwid is invalid
// add constructors, destructors, assignment operators if needed
private:
// Add private member variables for your class along with any
// other variables required to implement the public member functions
// TO BE COMPLETED
};
/// Registrar.cpp - NEEDS COMPLETION ///
#include
#include
#include
#include
#include "Registrar.h"
using namespace std;
// Load information from a text file with the given filename
// THIS FUNCTION IS COMPLETE
void Registrar::readTextfile(string filename) {
ifstream myfile(filename);
if (myfile.is_open()) {
cout
string courseName;
string cwid;
char grade;
while (myfile >> courseName >> cwid >> grade) {
// cout
addLine(courseName, cwid, grade);
}
myfile.close();
}
else
throw invalid_argument("Could not open file " + filename);
}
// return Student object corresponding to a given CWID
// getStudent must throw an exception if cwid is invalid
Student& Registrar::getStudent(string cwid) const {
// TO BE COMPLETED
}
// process a line from the text file
void Registrar::addLine(string courseName, string cwid, char grade) {
// TO BE COMPLETED
}
/// main.cpp - DOES NOT NEED COMPLETION ///
////////////////////////////////////////////////////////////////////////////////////////////// DO NOT EDIT THIS FILE (except for your own testing) //////////////////////////////////////////////////////////////////////////////////////////////
#include
#include "Student.h"
using namespace std;
template
template
int main() { { // test only the Student class Student student("123456789"); testAnswer("Student::getCWID test", student.getCWID(), string("123456789")); student.addCourseGrade("cs101", 'A'); testAnswerEpsilon("Student::getGPA test1", student.getGPA(), 4.0); student.addCourseGrade("cs201", 'C'); testAnswerEpsilon("Student::getGPA test2", student.getGPA(), 3.0); }
}
template template
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started