//************************************************************** // // Class: Student class (version 2)(Asst5) // // Author: Art Miller amiller@mta.ca // // // Description: A class for Student objects // // METHODS: // Student constructor which initializes a student // record, // // setName accepts a String and sets the name of the student // // setMarks accepts an (integer) mark array containing // marks for assignments, labs, midterm, and final. // // grade accepts a weight vector and returns the (weighted) // grade out of 100 // // displayStudent accepts a weight vector and displays the student // name and grade, with the grade given as a series // of 0 to 20 *'s. (bar-chart form) // // // Date: November 25, 1999 // // Course Info: CS 1711, Assignment 5 (due December 3, 1999) // // Filename: student.h // //*************************************************************** #include "tstring.h" #include class Student { private: // student name and marks data members String name; // the student name int marks[4]; // an array of 4 integer marks public: // initialize student with empty name, all marks set to 0 Student(); // set the name of the student void setName(String newName); // set the student marks, passing in an array of marks void setMarks(int newMarks[]); // calculate the student grade, based on a weighting vector double grade(double weight[] ); // display the student name and course grade (rep'd as asterisks) void displayStudent(double weight[]); }; // ******************************* // Student class implementation // ******************************* Student::Student() { name = ""; for (int i = 0; i < 4; i = i + 1) { marks [i] = 0; } } // set the name of the student void Student:: setName(String newName) { name = newName; } // update the student marks, passing in an array of marks void Student::setMarks(int newMarks[]) { for (int k = 0; k < 4; k = k + 1) { marks[k] = newMarks[k]; } } // ************************************************************** // calculate the student grade, based on a weighting vector // // THIS METHOD MUST BE MODIFIED, OTHERWISE THE GRADE RETURNED WILL // ALWAYS BE 40 double Student::grade(double weight[]) { return 40; } //*************************************************************** // display the student name and course grade (rep'd as "stars") void Student::displayStudent(double weight[]) { const int NAMEWIDTH = 12; const char STAR = '*'; cout <