Courses have certain properties: a title, number of credits it’s worth, prerequisites, a course number, a department name). For example, this course might have:

computer science

Description

Must be in c++ and runnable on centos8 without modification

Courses have certain properties: a title, number of credits it’s worth, prerequisites, a course number, a department name). For example, this course might have:

Title: Programming and Computing Credits: 4
Prerequisite: CS 100
Course Number: 140

Department Name: CS
In a C++ program, create a class Course where each instance of the class Course has these five properties. Apart from a constructor, which your class must have, include public member functions to:

  • get the value of any of the values in the object, e.g., getTitle() returns a string with the title, setCredits() allows the number of credits to be set.

  • set the value of any of the values in the object, e.g., setTitle("Basketweaving in Python") would set title to a new name.

  • search the set of courses for a given course number and department name pair, returning the index in the array where the course entry was found, or a suitable value to indicate the course was not found. For example, you might search for department name “CS” and course number 140: findCourse("CS", 140)

    Test your class in a program to set up all the 200 level courses the program offers (there are ten in the catalog: 212, 221, 228, 240, 250, 260, 270, 280, 288, 290, 299; ignore 2XX). Your program should use methods of the class you create to set all five fields in each of the courses, and use methods of your class to print out the object to show it correctly initialized. Test your search method with at least one invalid course/dept pair, as well as at least one valid pair.

    Hints:

    1. you’ll need an array of Course objects

    2. you probably want a method that just prints out all of an object in addition to any methods you create that retrive a specific value from an object

    3. your search method will need two parameters to form what it searches for, one with the department name, one with the course number.


Related Questions in computer science category