Question

In: Computer Science

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

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

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

It can be relatively simple. :)

Just want to let you know this is Part 2 of the question previously 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 no size 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 space whenever a declared object goes out of scope. */

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

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

Just showing the courseType files as a reference for pieces 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() << endl;
cout << "Course Name: " << getCourseName() << endl;
}

Solutions

Expert Solution

//courseTypeList.h

#ifndef COURSELISTTYPE_H_INCLUDED
#define COURSELISTTYPE_H_INCLUDED

#include <string>
#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 <iostream>
#include <string>
#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);
courses[courseCount].setCourseID(1000+courseCount);
courseCount++;
}


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

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

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

//courseType.h

#ifndef COURSETYPE_H_INCLUDED
#define COURSETYPE_H_INCLUDED
#include <iostream>
#include <string>

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 <string>

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()
{
   this-> courseID = 0;
this-> courseName = "";
}

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

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

//test.cpp

#include"courseTypeList.cpp"
#include<iostream>
using namespace std;

int main()
{
   courseTypeList c1(10);
   c1.addCourse("CSC");
   c1.addCourse("Physics");
   c1.print();
}

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

//Output


Related Solutions

c++ ///////////////////////////////////////////////////////////////////////// need to be named Subsequences.h and pass test cpp file SubsequenceTester.cpp at the end...
c++ ///////////////////////////////////////////////////////////////////////// need to be named Subsequences.h and pass test cpp file SubsequenceTester.cpp at the end of this question. This assignment will help you solve a problem using recursion Description A subsequence is when all the letters of a word appear in the relative order of another word. Pin is a subsequence of Programming ace is a subsequence of abcde bad is NOT a subsequence abcde as the letters are not in order This assignment you will create a Subsequence...
I have placed my answers in bold I just need to make sure these are right...
I have placed my answers in bold I just need to make sure these are right I have some with two answers because I'm just not sure which is correct. I just really want to do well on this last assignment any help is apperciated. Thank you! Abby is a 20-year-old female college student. For at least the last 3 months, Abby has experienced ongoing anxiety and worry without a specific cause for these feelings. She has been restless and...
Answers are in bold under questions. I just need to know how to get them, so...
Answers are in bold under questions. I just need to know how to get them, so Please show work!! A) If 25% of all vehicles at a certain emissions inspection failed the inspection. Assuming that successive vehicles pass or fail independently of one another. Calculate the following probabilities: At least seven of the last 40 vehicles inspected failed. 0.9038 B) If 25% of all vehicles at a certain emissions inspection failed the inspection. Assuming that successive vehicles pass or fail...
Using C++ Create the UML, the header, the cpp, and the test file for an ArtWork...
Using C++ Create the UML, the header, the cpp, and the test file for an ArtWork class. The features of an ArtWork are: Artist name (e.g. Vincent vanGogh or Stan Getz) Medium (e.g. oil painting or music composition) Name of piece (e.g. Starry Night or Late night blues) Year (e.g. 1837 or 1958)
(i just need an answer for question 4) (i just need an answer for just question...
(i just need an answer for question 4) (i just need an answer for just question 4) you have two facilities, one in Malaysia and one in Indonesia. The variable cost curve in the Malaysian plant is described as follows: VCM = q­ + .0005*q2 , where q is quantity produced in that plant per month. The variable cost curve in the Indonesian plant is described by VCI = .5q + .00075q2, where q is the quantity produced in that...
I know the answers I just need detailed step-by-step instructions. Brad Company developed the following budgeted...
I know the answers I just need detailed step-by-step instructions. Brad Company developed the following budgeted life-cycle income statement for two proposed products. Each product's life cycle is expected to be two years. Product A Product B Total Sales $200,000 $200,000 $400,000 Cost of goods sold 120,000 130,000 250,000 Gross profit $ 80,000 $ 70,000 $150,000 Period expenses:      Research and development (70,000)      Marketing (50,000) Life-cycle income $ 30,000 A 10 percent return on sales is required for new products. Because...
I also need the references in this assignment. What's in bold are the websites that can...
I also need the references in this assignment. What's in bold are the websites that can be used. Throughout the course, you have been learning about managed care, both past and present. Conduct additional research on trends happening in managed care today. The following websites are a great place to start: Centers for Medicare & Medicaid Services Kaiser Family Foundation (Search for the series on health care marketplace trends.) You can also visit the following videos related to managed care...
I just want to make the productions runs per month which is in bold to be...
I just want to make the productions runs per month which is in bold to be related to ether total run labor cost per month or to standard cost per unit Manufactoring Cost Valves Pumps Flow controllers Material cost per unit 16 20 22 Units per month 7500 12500 4000 Material cost per month 120000 250000 88000 Labor cost Production runs per month 1 5 10 Set- up labor hours/production run 8 8 12 Labor hrs per unit 0.25 0.5...
i need an example of a program that uses muliple .h and .cpp files in c++...
i need an example of a program that uses muliple .h and .cpp files in c++ if possible.
I need an answer only for the bold part of the question. 1. Circle: The class...
I need an answer only for the bold part of the question. 1. Circle: The class has two private instance variables: radius (of the type double) and color (of the type String). The class also has a private static variable: numOfCircles (of the type long) which at all times will keep track of the number of Circle objects that were instantiated. Construction: A constructor that constructs a circle with the given color and sets the radius to a default value...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT