Assignment: Lab 6 P3 : Course Class Dynamic Mem Copy in the code from 11.17 and
ID: 3653356 • Letter: A
Question
Assignment: Lab 6 P3 : Course Class Dynamic Mem Copy in the code from 11.17 and 11.18 - Course1.h, Course1.cpp 1. Customizing Copy Constructors 2. Create a displayAll function and make it output like shown below: void displayAllStudents(); //add this to display all the students in one course in the follwoing format: |1) Peter Pan|2) Jim Jones|3) Captain Hook|4) Mr T|5) Superman 3. Create a find function and make it show the location of the requestioned name or 0 if not found. int find(const string &name); 4. Create a drop function that removes a name from the list. void dropStudent(const string &name); 5. Use the following main() to test your code (Do NOT modify the main() function) // Don't forget your comments! #include #include "Course1.h" using namespace std; // Make sure you get this working with the code below... void main(){ cout << "Hello World" << endl; Course course1( "C++", 10); //10000000 Course course2(course1); course1.addStudent( "Peter Pan"); course1.addStudent( "Jim Jones"); course1.addStudent( "Captain Hook"); course1.addStudent( "Mr T"); course1.addStudent( "Superman"); course2.addStudent( "Lisa Ma"); cout << "Peter Pan is a position " << course1.find("Peter Pan") << endl; cout << "Lisa Ma is a position " << course1.find("Captain Hook") << endl; cout << "Tom Jones is a position " << course1.find("Tom Jones") << endl; cout << "students in course1: " << endl;// << //course1.getStudents()[0] << endl; course1.displayAllStudents(); course1.remove("Captain Hook"); cout << "Captin Hook should be removed!" << endl; course1.displayAllStudents(); cout << "students in course2: " << course2.getStudents()[0] << endl; //system("pause"); } 6. Sample Output: Hello World Peter Pan is a position 1 Captain Hook is a position 3 Lisa Ma is a position 1 students in course1: C++ |1) Peter Pan|2) Jim Jones|3) Captain Hook|4) Mr T|5) Superman Captin Hook should be removed! |1) Peter Pan|2) Jim Jones|3) Mr T|4) Superman students in course2: C++ |1) Lisa MaExplanation / Answer
Course1.h // Paste in your specification code here. #ifndef COURSE_H #define COURSE_H #include using namespace std; class Course { public: Course(const string & courseName, int capacity); ~Course(); // Destructor Course(Course &); // Copy constructor string getCourseName() const; void addStudent(const string &name); void remove(const string &name); string *getStudents() const; int getNumberOfStudents() const; void displayAllStudents(); int find(const string tempName); private: int capacity; string courseName; string *students; int numberOfStudents; }; #endif Course1.cpp // Paste in your implementation code here. #include #include "Course1.h" Course::Course(const string &courseName, int capacity) { //capacity = 0; numberOfStudents = 0; this->courseName = courseName; this->capacity = capacity; students = new string[capacity]; } Course::~Course() { delete [] students; } string Course::getCourseName() const { return courseName; } void Course::addStudent(const string &name) { if (numberOfStudents >= capacity) { coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.