Project 4 High-Level Design

Grading Program for the Basket Weaving Professor
Spring 2001

Student class

class Student {

  friend ostream& operator<<(ostream &out, Student s);
  friend istream& operator>>(istream &in, Student &s);

  public:
    Student();
    string getName();
    void setName(string newName);
    double numericGrade();
    string letterGrade();
    void enterData();
    void printRawHeader();
    void printRawGrades();
    void printSemesterHeader();
    void printSemesterGrades();

  private:
    string name;
    vector<double> grades;
    vector<double> weights;
    static const int numberOfGrades = 7;

}; // Student class
Student() --- Default constructor.
string getName() --- Observer method for the name data member.
double numericGrade() --- Returns the student's numeric grade based on a weighted average.
char letterGrade() --- Returns the student's letter grade corresponding to the numeric grade.
void enterData() --- Let's a user enter values for the student's name and each grade.
void printRawHeader() --- Prints the table header for the output of the raw grades.
void printRawGrades() --- Prints the data members of the Student instance in a ``pretty'' format.
void printSemesterHeader() --- Prints the table header for the output of the semester grades.
void printSemesterGrades() --- Prints the name, numeric grade, and letter grade of the Student object.
friend ostream &operator<<(ostream &out, Student s) --- Friend function overloading the stream insertion operator. Inserts the Student object s into the output stream out. Output format should match that of the data file.
friend istream &operator>>(istream &in, Student &s) --- Friend function overloading the stream extraction operator. Extracts a Student object from the istream and stores it in the s. Input format should match that of the data file.
Hint: Use the overloaded stream insertion and extraction operators primarily for reading from and writing to the data file.

StudentList class

class StudentList
{

  friend ostream &operator<<(ostream &out, StudentList sl);
  friend istream &operator>>(istream &in, StudentList &sl);

  public:
    void push_back(Student s);
    int findStudent(string name);
    void printRawGrades();
    void printRawGrades(int i);
    void printSemesterGrades();
    void printSemesterGrades(int i);

  private:
    vector<Student> students;

}; // StudentList class
void push_back(Student s) --- Pushes the Student object s onto the back of the students vector.
int findStudent(string name) --- Does a sequential search for a Student instance matching the string name. If found, returns the index of the instance in the students vector; returns -1 otherwise.
void printRawGrades() --- Prints the raw grades of the instances in the students vector to cout.
void printRawGrades(int i) --- Prints the raw grades of the instance at the ith position in the students vector to cout.
void printSemesterGrades() --- Prints the semester grades of the instances in the students vector to cout.
void printSemesterGrades(int i) --- Prints the semester grades of the instance at the ith position in the students vector to cout.
Overloaded stream insertion operator inserts into the istream each Student object stored in the vector of Student objects. Similarly, the stream extraction operator extracts Student instances from the ostream, storing them in the vector of Student objects.


GraderApp class

class GraderApp
{
  public:
    GraderApp(string newFilestem);
    void processCommands();
  
  private:
    void load(string filename);
    void save(string filename);
    void printMenu();
    void addStudent();
    void findStudent();
    void printSemesterGrades();
    void printRawGrades();

    StudentList students;
    string filestem;
    bool changesMade;

}; // GraderApp class
GraderApp(string) --- Constructor: Given the filestem in string, loads the students from the data file filestem.dta into the private data member students. Stores name in private data member filestem. Sets private data member changesMade to false.
void processCommands() --- Loops, printing the menu, getting a command from the user, and executing the command, until the user quits.
StudentList student --- Private data member holding the instances of the students in the class.
string filestem --- Stores the prefix of the input and output files.
bool changesMade --- Indicates whether the user added a new student.
void printMenu() --- Private method that prints the command menu.
void addStudent() --- Private method for letting the user add a new student to the class.
void findStudent() --- Private method for letting the user find a certain student by searching by name.
void printRawGrades() --- Private method for printing the raw grades of the StudentList object.
void printSemesterGrades() --- Private method for printing the semester grades of the StudentList object.