Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Implement the functions in Roster.h: #ifndef ROSTER_H #define ROSTER_H #include #include #include Student.h class Roster { public: Roster(); static const int ROSTER_MAX = 1024; void
Implement the functions in Roster.h:
#ifndef ROSTER_H #define ROSTER_H #include#include #include "Student.h" class Roster { public: Roster(); static const int ROSTER_MAX = 1024; void addStudentsFromStream(std::istream &is); void addStudentsFromFile(std::string filename); int getNumStudents() const; Student getStudentAt(int index) const; std::string toString() const; // Format of Roster::toString() // opening "{ ", // one Student toString() per line, each followed by ", " // closing "} " // No comma on last line before closing } // Example: // { // [1234567,Smith,Mary Kay], // [7654321,Perez,Carlos] // } void sortByPerm(); // use Selection Sort void resetRoster(); // delete all students from roster // By rights, these next two helper functions // should probably be private. We expose them as // public so they are easily unit testable. void sortByPermHelper(int k); // swaps max perm from [0..k-1] with elem [k-1] int indexOfMaxPermAmongFirstKStudents(int k) const; private: // pointers to Students on heap! Student *students[ROSTER_MAX]; int numStudents; }; #endif
---------------------------------------------------------
#ifndef STUDENT_H #define STUDENT_H #includeclass Student { public: Student(int perm, std::string lastName, std::string firstAndMiddleNames); // initialize one student from a comma separated string, // e.g. 1234567,Smith,Mary Kay Student(std::string csvString); int getPerm() const; std::string getLastName() const; std::string getFirstAndMiddleNames() const; std::string getFullName() const; std::string toString() const; // e.g. [12345,Smith,Malory Logan] private: int perm; std::string lastName; std::string firstAndMiddleNames; }; #endif
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