Answered step by step
Verified Expert Solution
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, eg CECS ; values must be in uppercase
string courseName; the course's name, eg Computer Programming II Laboratory
int credits; the number of credits for the course
static sizet codeSize; the size of the courseCode field
void setCodeSizestring bool; private method to set the value for codeSize
static sizet nameSize; the size of the courseName field
void setNameSizestring bool; private method to set the value for nameSize
public:
Coursestring string int ; the default constructor with default values
the constructor must validate the value for credits, assign if invalid
Courseconst Course&; the copy constructor, use assignment operator
~Course; the destructor
void setCourseCodestring;
void setCourseNamestring;
void setCourseCreditsint; validates the parameter to be or greater
string getCourseCode const;
string getCourseName const;
string getCourseCredits const;
sizet getCodeSize const;
sizet 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& operatorconst Course&; overload of the assignment operator
Since duplicate course codes are not allowed, add a lowercase c to the end of the string
bool operatorconst 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:
Catalogstring int Course nullptr; the default constructor
Catalogconst Catalog&; the copy constructor, use assignment operator
~Catalog; the destructor
void setUniversityNamestring;
string getUniversityName const;
void addCoursestring 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 findCourseconst string const; method to find a course by code in the catalog
void deleteCourseint; 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& operatorconst Catalog&; overload of the assignment operator
;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started