Explain how Capacity is equal to the number of students for Database Systems”

You will work on the Course Class which is given in Course.h file. and I need a course.cpp
class Course
{
// define operator<< as a friend function for Course public: Course(const std::string& courseName, const std::string& section, int capacity); ~Course(); // overload copy constructor // overload copy assignment operator void setCourseName(std::string name); std::string getCourseName() const; void setSection(std::string section); std::string getSection() const; void addStudent(const std::string& name); void dropStudent(const std::string& name); int getNumberOfStudents() const; int getCourseCapacity()const; void shrinkCapacity(); void increaseCapacity(unsigned inc); std::string getStudents(int index); //oveload operator+= as a member function private: std::string courseName; std::string section; std::string* students; int numberOfStudents; int capacity; }; This class has a courseName , a capacity and a section to declare the course info. Students can register for the course using their names. Course class stores all students' names in a dynamic array. When a course instance is created, a dynamic array is allocated with the size of course capacity. When a student is added to the course or a student drops the course, the value of the numberOfStudents has updated. In other words, numberOfStudents shows the current fullness of the course; capacity shows the available maximum number of students for the course. The capacity value should be represented the dynamic array size in all cases. Course(const std::string& courseName, const std::string& section, int capacity); Constructor: The course instance is created using 3 parameter values. The number of students enrolled in the course should be set to zero, a dynamic array is allocated with the size of course capacity for future student enrollments. The constructor ends with printing the confirmation message (see example ) to the console. Example: Data Structures-B has been created! ~Course(); Destructor: It prevents the memory leak. The destructor ends with printing the confirmation message (see example) to the console. Example: Data Structures-B has been deleted! overloading copy constructor Copy Constructor: It creates a copy course instance of a given course instance in the parameter list using deep copy. The copy construction ends with printing the confirmation message (see example ) to the console. Example: New Data Structures-B has been created by copy constructor! void addStudent(const std::string& name); Add the name to the course's student list as a last element of the array by checking if there is available room in the array for the student. The method ends with printing the confirmation message (see example ) to the console if the student is added, otherwise' printing a warning message as shown below. Example: Peter Jones was added to Data Structures-A successfully or The course Data Structures-A has reached maximum capacity! You need to increase the capacity!! void dropStudent(const string& name); If there is a student whose name is the same as the parameter in the student array, the name is deleted from the array by moving the last student to the dropped student's place. By doing this, we have a more efficient drop procedure compared to the shift processing in the array. The method ends by printing the confirmation message (see the unit test ) to the console. Example: Student: Ahmad Nas dropped the course Computer Network-C or Student: Kaan Pease was not found! void shrinkCapacity(); If capacity is greater than the NumberOfStudents ,the size of the dynamic array shrinks to the value of the NumberOfStudents , this would affect the dynamic array. After completing the process, it prints the confirmation message (see example), otherwise prints a message like "No need to shrink !! Explain how Capacity is equal to the number of students for Database Systems" Example after shrinking the size: Capacity of Data Structures-A is now equal to number of students void increaseCapacity(unsigned inc); Increase the course capacity by the value of parameter inc. It should affect the dynamic array as well. The method ends by printing the confirmation message (see the example ) to the console. Example: Capacity of Data Structures-A has been increased by 3 Overloading operator<< It prints the course info to the ostream object as shown in the example ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Course Name: Computer Network Section : C Capacity : 10 #ofStudents: 2 ---------Student List------------ 1. Ali Wattson 2. Steve Smith Or ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Course Name: Computer Network Section : C Capacity : 10 #ofStudents: 0 ---------Student List------------ (no students to list) Copy assignment operator It assigns the given course instance to another course instance using deep copy. The copy assignment operation ends with printing the confirmation message (see the example ) to the console. Example: The content of Database Systems-C was copied to Special Topics-X using operator= void setCourseName(std::string name); It updates the name of the course and prints the confirmation message to the console (see example) Example: Course name Database Systems-C has been changed to Computer Network-C void setSection(std::string section); It updates the section of the course and prints the confirmation message to the console (see example) Example: Course section Database Systems-B has been changed to C std::string getStudents(int index); It returns the student name located at the index in the array oveloading operator+= as a member function The operator adds the students of the course object argument to the current course object. To do this, it updates the current object capacity to the total capacity of the current and argument objects. The new capacity value affects the dynamic array of the current object. You need to update the numberOfstudent member of the current object as well. The operator returns the current object’s reference. main.cpp: #include
#include
#include “course.h”

int main(int argc, char * argv[])
{
// Check if number of command-line arguments is 2 or not. If not, print a error message
// Create a ofstream object named outFile for the filename given in the command-line
// check if the file is able to open or not
// Create Data Structure course object
Course courseDStA(“Data Structures”, “A”, 3);
// add three students
courseDStA.addStudent(“Peter Jones”);
courseDStA.addStudent(“Brian Smith”);
courseDStA.addStudent(“Anne Kennedy”);
// print course information with its student list
std::cout << courseDStA << std::endl; // shrink student list courseDStA.shrinkCapacity(); // Create Database Systems Course courseDStB("Data Structures", "B", 10); // add two students courseDStB.addStudent("Ahmad Nas"); courseDStB.addStudent("Steve Smith"); // print course info std::cout << courseDStB << std::endl; // merge two sections courseDStA += courseDStB; // print courses info std::cout << courseDStA << std::endl; std::cout << courseDStB << std::endl; // shrink student list courseDStA.shrinkCapacity(); std::cout << courseDStA << std::endl; // add a student to database course courseDStA.addStudent("Khan Tran"); // increase capacity courseDStA.increaseCapacity(3); courseDStA.addStudent("Khan Tran"); std::cout << courseDStA << std::endl; // drop student courseDStA.dropStudent("Kaan Pease"); std::cout << courseDStA<< std::endl; // create course using copy constructor Course courseDB(courseDStB); // change its name courseDB.setCourseName("Database Systems"); courseDB.setSection("C"); std::cout << courseDB << std::endl; // add student courseDB.addStudent("Ali Wattson"); std::cout << courseDB << std::endl; std::cout << courseDStB << std::endl; // create copy object Course courseX("Special Topics", "X", 0); courseX = courseDB; courseX.setCourseName("Computer Network"); std::cout << courseX << std::endl; // drop a student courseX.dropStudent("Ahmad Nas"); std::cout << courseX << std::endl; std::cout << courseDB << std::endl; // drop all students from Computer Network courseX.dropStudent("Steve Smith"); std::cout << courseX << std::endl; courseX.dropStudent("Ali Wattson"); std::cout << courseX << std::endl; // write all course objects info to the file which was given as command-line argument outFile << courseDStA << courseDStB << courseDB << courseX; outFile.close(); return 0; }

Last Completed Projects

topic title academic level Writer delivered