Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ format, only need help with Registrar.h and Registrar.cpp //TO BE COMPLETED sections need to be complete. main.cpp below does not need to be

In C++ format, only need help with Registrar.h and Registrar.cpp "//TO BE COMPLETED" sections need to be complete. main.cpp below does not need to be changed.

image text in transcribed

/// 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 #include #include

#include "Student.h"

using namespace std;

template bool testAnswer(const string &nameOfTest, const T &received, const T &expected);

template bool testAnswerEpsilon(const string &nameOfTest, const T &received, const T &expected);

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 bool testAnswer(const string &nameOfTest, const T &received, const T &expected) { if (received == expected) { cout

template bool testAnswerEpsilon(const string &nameOfTest, const T &received, const T &expected) { const double epsilon = 0.0001; if ((received - expected Requirements . You should not use any of the C++ Standard Library containers (such as std:array, std:vector, std::list) for this project. The text file can be large there can be upto 50,000 students. Hence, the file must be read only once (i.e., only Registrar: :readTextfile must read the file and store the data in some member variables to be used later by other functions. Other functions should not try to read the file.) Add default constructors, copy constructor, assignment operator, destructor if needed to the classes Registrar::getStudent (cwid) should throw one of the std: :exceptions if the cwid is invalid. (Other types of error checking are not required) . Do not change main.cpp- the main function is a series of tests of your code (it is ok to edit the file for your own testing, but during grading we will use the original main file) Simplifying assumptions . . Each student will take at most 50 courses CWIDs are strings Course names are a single word without spaces. Grades are single letters (char): 4 for A, 3 for B, 2 for C, 1 for D, and 0 for F. All courses have the same number of units Requirements . You should not use any of the C++ Standard Library containers (such as std:array, std:vector, std::list) for this project. The text file can be large there can be upto 50,000 students. Hence, the file must be read only once (i.e., only Registrar: :readTextfile must read the file and store the data in some member variables to be used later by other functions. Other functions should not try to read the file.) Add default constructors, copy constructor, assignment operator, destructor if needed to the classes Registrar::getStudent (cwid) should throw one of the std: :exceptions if the cwid is invalid. (Other types of error checking are not required) . Do not change main.cpp- the main function is a series of tests of your code (it is ok to edit the file for your own testing, but during grading we will use the original main file) Simplifying assumptions . . Each student will take at most 50 courses CWIDs are strings Course names are a single word without spaces. Grades are single letters (char): 4 for A, 3 for B, 2 for C, 1 for D, and 0 for F. All courses have the same number of units

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Online Market Research Cost Effective Searching Of The Internet And Online Databases

Authors: John F. Lescher

1st Edition

0201489295, 978-0201489293

More Books

Students also viewed these Databases questions