Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use the comments as the instructions or guide to build and complete the Catalog and Course Class cpp . The content below is the interface

Use the comments as the instructions or guide to build and complete the Catalog and Course Class cpp. The content below is the interface of those two classes the Catalog.h and Course.h. Give me the solution in C++
/*
* File name: Course.h
* This file declares a class named Course
* You can add methods if required, must provide supporting explanation.
* Your code must include comments explaining your reasoning and artifact choices.
*/
#pragma once
// preprocessor directives
class Course{
private:
string courseCode; // the course's code, e.g. CECS 2223; values must be in uppercase
string courseName; // the course's name, e.g. Computer Programming II Laboratory
int credits; // the number of credits for the course
static size_t codeSize; // the size of the courseCode field
void setCodeSize(string, bool); // private method to set the value for codeSize
static size_t nameSize; // the size of the courseName field
void setNameSize(string, bool); // private method to set the value for nameSize
public:
Course(string ="", string ="", int =-1); // the default constructor with default values
// the constructor must validate the value for credits, assign -1 if invalid
Course(const Course&); // the copy constructor, use assignment operator
~Course(); // the destructor
void setCourseCode(string);
void setCourseName(string);
void setCourseCredits(int); // validates the parameter to be 0 or greater
string getCourseCode() const;
string getCourseName() const;
string getCourseCredits() const;
size_t getCodeSize() const;
size_t getNameSize() const;
void displayCourse() const; // prints the course data ready for a table
// the order is course code, course name, credits, and the size of the
// course and name fields is variable; align to the left
Course& operator=(const Course&); // overload of the assignment operator
// Since duplicate course codes are not allowed, add a lowercase c to the end of the string
bool operator>(const Course&); // overload of the greater than operator
};
------------------------------------------------------------------------------------------
/*
* File name: Catalog.h
* This file declares a class named Catalog
* Complete the declaration as required.
* You can add methods if required, must provide supporting explanation.
* Your code must include comments explaining your reasoning and artifact choices.]
*/
#pragma once
// preprocessor directives
class Catalog {
private:
string universityName; // the name of the university
int courseCount; // the number of courses in the catalog
Course** courses; // the array which contains the courses
void sortCatalog(); // sorts the courses in the catalog in alphabetical order
public:
Catalog(string ="", int =0, Course**= nullptr); // the default constructor
Catalog(const Catalog&); // the copy constructor, use assignment operator
~Catalog(); // the destructor
void setUniversityName(string);
string getUniversityName() const;
void addCourse(string, string, int); // adds a course to the catalog
// No duplicate course codes are allowed, must validate
// The addCourse method calls the sortCatalog method after a course is added.
int findCourse(const string) const; // method to find a course by code in the catalog
void deleteCourse(int); // removes a course from the catalog
void printCatalog() const; // prints the course list for the university
// printCatalog prints the header CODE, NAME, CREDITS using the column widths
// from the Course class
Catalog& operator=(const Catalog&); // overload of the assignment operator
};

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions