****************************************Instructions**************************************************** I just need a test .cpp client file that tests the new bold bits of code...

50.1K

Verified Solution

Question

Programming

****************************************Instructions****************************************************

I just need a test .cpp client file that tests the newbold bits of code of the courseListType class.

It can be relatively simple. :)

Just want to let you know this is Part 2 of the questionpreviously answered at:

https://www.chegg.com/homework-help/questions-and-answers/right-courselisttype-hold-static-50-courses-need-make-little-flexible-want-change-static-a-q57690521

***********************************************************************************************************

//courseTypeList.h

#ifndef COURSELISTTYPE_H_INCLUDED
#define COURSELISTTYPE_H_INCLUDED

#include
#include \"courseType.h\"

class courseTypeList {

public:
void print() const;
void addCourse(std::string);
courseTypeList(int n);
~courseTypeList();

private:
int NUM_COURSES;
int courseCount;
courseType *courses;
};

#endif // COURSELISTTYPE_H_INCLUDED

====================================================

//courseTypeList.cpp

#include
#include
#include \"courseTypeList.h\"

void courseTypeList::print() const {

for (int i = 0; i < courseCount; i++) {
courses[i].printCourse();
}
}

void courseTypeList::addCourse(std::string name) {
courses[courseCount++].setCourseName(name);
}

/* This allocates the array of the provided size, if nosize is provided, default is 50 */

courseTypeList::courseTypeList(int n = 50)
{
   courseCount = 0;
   courses = new courseType[n];
   NUM_COURSES = n;
}

/* destructor to for CourseListType to deallocate spacewhenever a declared object goes out of scope. */

courseTypeList::~courseTypeList()
{
   delete courses;
}

***************************************************************************************************************

Just showing the courseType files as a reference forpieces of code in courseListType files.

***************************************************************************************************************

//courseType.h

#ifndef COURSETYPE_H_INCLUDED
#define COURSETYPE_H_INCLUDED
#include
#include

using namespace std;

class courseType {

public:
courseType(int, string);
courseType();

int getCourseID();
string getCourseName();

void setCourseID(int);
void setCourseName(string);

void printCourse();

private:
int courseID;
string courseName;

};

#endif

===================================================

//courseType.cpp

#include \"courseType.h\"
#include

using namespace std;

courseType::courseType(int id, string name) {
this-> courseID = id;
this-> courseName = name;
}

int courseType::getCourseID() {
return courseID;
}

string courseType::getCourseName() {
return courseName;
}

void courseType::setCourseID(int id) {
courseID = id;
}

void courseType::setCourseName (string name) {
courseName = name;
}


courseType::courseType()
{
   ;
}

void courseType::printCourse() {
cout << \"Course ID: \" << getCourseID() <cout << \"Course Name: \" << getCourseName() <}

Answer & Explanation Solved by verified expert
4.2 Ratings (784 Votes)
courseTypeListhifndef COURSELISTTYPEHINCLUDEDdefine COURSELISTTYPEHINCLUDEDinclude include courseTypehclass courseTypeList publicvoid print constvoid addCoursestdstringcourseTypeListint ncourseTypeListprivateint NUMCOURSESint courseCountcourseType coursesendif    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students