Reference no: EM132316031
Assignment -
The course registration system maintains information of courses, students and the course registered. There are two Class Course and Student (defined in Course.h and Student.h respectively)
class course
{
private:
char name50;
char codel9];
int credit
public:
//Constructor member funct ions
course();
course(const char n[50], const char cI9], int cre);
// ACCESSOR member funct ions
void print_course_detail() const;
int get credit() const;
void get_code(char+ output) const;
// MUTATOR member funct ions
void set_credit (int cre) ;
};
class student
{
private:
char name[20];
char id[9];
int num_registered_course;
course courses[MAX_COURSES];
public:
// CONSTRUCTOR member function
student();
student (const char n[20], const char i[9]);
// ACCESSOR member funct ions void list_registered_courses) const;
void print_name_id() const;
int get total_credit() const
//MUTATOR member functions
bool registerCourse(const course &c);
bool dropCourse(const course &c);
};
YOUR TASKS - You are required to build the above program based on the skeleton code provided.
You may define additional function if necessary. There are three files, course,h, student.h and main.cpp in the zipped folder. To build them in eclipse, you should first "New" a empty C++ project, and then copy these files directly to the project (or drag them into project folder).
Functions are declared in .h file and you should complete the implementation of the following functions in Student.cpp and Course.cpp:
In Course.cpp,
1. course() - a constructor member function that initialize course's name and code to "N/A" and set the credit to 0
2. course(const char n[50], const char c[9], int cre) a constructor member function that initialize course's name to n and code to c and set the credit to cre
3. void print_course_detail() const prints the course name, code and credit in the format "Course Code: course_codej Course Name: scourse_namej Credit: credit!"
4. int get_credit() const - return the credit of the course
5. void get_code(char* output) const - return the course code to the char output
6. void set_credit (int cre) - a mutator member function that set credit of the course to cre
In Student.cpp
1. student() a constructor member function that initialize student's name and id to "N/A" and num_registered_course to 0
2. student(const char n[20], const char i[9]) a constructor member function that initialize student's name to n, id to i, and num_registered_course to 0
3. void list_registered_courses() const lists courses registered by the student.
4. void print_name_id) const - prints the student name and id in format "Name: (student_name ID: {student id} endl"
5. int get_total_credit() const - return the sum of earned credit from all the registered course of the student
6. bool registerCourse(const course &c) - a mutator member function that register the course c for the student.
You should check if the student's course quota if full. If it is not full, add this course and increment the number of registered courses.
If the student successfully registered the course, return true return false otherwise
7. bool dropCourse(const course &c) - drops course c for the student. You should check if the course c is registered.
If it is registered, drop it and decrement the number of registered courses. If the drop successful, return true, return false otherwise
To compare two C strings, you can use the function int strcmp (const char str1, const char str2) It returns value 0 when contents of both strings are equal, value str1 greater than str2 0 when str1 smaller than str2, and value > 0 when when str1 greater than str2.