Question: (The Course class) Implement the class Course which are defined as follows, // Course.h #ifndef COURSE_H #define COURSE_H #include #include using namespace std; class Course
(The Course class) Implement the class Course which are defined as
follows,
// Course.h
#ifndef COURSE_H
#define COURSE_H
#include
#include
using namespace std;
class Course
{
public:
// Creates a course with the specified name and maximum
number of students allowed.
Course(const string& course_name, int capacity);
// Destructor, destory the dynamic array
~Course();
// Returns the course name.
string get_course_name() const;
// Adds a new student to the course if the array
capacity is not exceeded.
void add_student(const string& new_student);
// Drops the specified student
void drop_student(const string& drop_student);
// Returns the array of students for the course.
String* get_students() const;
// Returns the number of students for the course.
int get_number_of_students() const;
// Prints the course name, the number of students, and
the added students.
void print_course() const;
private:
// The name of the course
string course_name;
//An array of students who take the course. students is
a pointer for the array.
string* students;
// The number of students (default: 0).
int number_of_students;
// The maximum number of students allowed for the
course.
int capacity;
};
#endif
Write a test program that
1) creates a course (prompt the user to enter the course name and capacity),
2) adds students (prompt the user to enter the student name, stop adding the
students when the user enter "exit" as student name),
3) removes the student (prompt the user to enter the student name to be removed,
remove the student from the course),
4) displays the course name, the number of students, and students added in the
course.
Four files should be submitted for this program question.
1) a header file Course.h which contains the definition of Course class,
2) an implementation file Course.cpp which contains the implementation of
Course class,
3) a client test file a1q9.cpp containing main() function,
4) a script file a1q9result containing result.
Here are the sample runs:
Enter the course name: CSE330
Enter the course capacity: 20
Enter the student name: Taylor
The student is added
Enter the student name: Jim
The student is added
Enter the student name: Alice
The student is added
Enter the student name: exit
Enter the student that will be removed: Jim
The student is removed
The course information:
CSE330 2
Taylor
Alice
C++ language
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
