Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include using namespace std; class CTXcourse { private: string name; int CRN; int seats; string instructor; static int internal_class_code; public: CTXcourse() { CRN = 0;

image text in transcribed

#include using namespace std;

class CTXcourse { private: string name; int CRN; int seats; string instructor; static int internal_class_code; public: CTXcourse() { CRN = 0; name = "none"; seats = 0; instructor = "TBA"; internal_class_code++; } // default constructor CTXcourse(int c, string n, int s, string i) { CRN = c; name = n; seats = s; instructor = i; internal_class_code++; } void print(); void setName(string s) { name = s; } string getName() { return name; } void setCRN(int a) { CRN = a; } int getCRN() { return CRN; } void setSeats(int n) { seats = n; } int getSeats() { return seats; } void setInstructor(string i) { instructor = i; } string getInstructor() { return instructor; } void addSeats(int m) { seats += m; } };

int CTXcourse::internal_class_code = 0;

void CTXcourse::print() { cout

int main() { string inst; int more; // Step 1 - 1 line of code CTXcourse course2; // Step 2 done

course2.setCRN(2766); // Step 3 done

// Step 4 - 1 line of code // Step 5 - 1 line of code

// Step 6 - 3 lines of code: prompt, cin, call setInstructor() // Step 7 - 3 lines of code: prompt, cin, call addSeats()

course1.print(); // Step 8 done cout

// Step 10 - 1 line of code

}

Use a class You are provided with code that implements a class that holds information for Concordia courses. This class keeps track of a courses name, CRN, number of seats, and instructor. This class is complete and there is no work to be done on the class. The name of the class is CTXcourse. You can see the code in the uneditable section of the code. The class contains the following methods you will need to use Default constructor. Create an object of type CTXcourse with default settings Four argurnent constructor: CTXcourse(int . string n, int s, string i). This constructor creates a new CTXcourse object setting the CRN-, nane-n, seats-s, and instructor-i setNanme(string s) sets the course name to s. - setSeats(int n) sets the number of seats to n setinstructorstringsets the instructor to i. setCRN (int a) sets the CRN to a. addSeats(int m) adds m seats to the seats for that course printo prints information about the course using cout. You will be using this class in a mainO function. main is started for you and you must complete the following steps 1. Declare a CExcouraa object named courael using the four argument constructor. CRN should be 2765, name should be "CSC 1401", seats should be 20, and instructor should be "Schielke 2. Declare another cIxcourse object named course2 using the default (0 argument) constructor. This step has been done for you 3. Use the atCRy method to set the CRN of courscz to be 2766. This step has been done for you 4. Use the aetNae ) method to set the name of coures2 2 to "CSC 1402 5, Use the setleats[) method to set the number of seats for course2 to be 10. . Prompt the user to enter an instructor name. Read the name into the string variable named inst (already declared for you) using cin and use the set Instructor () method to set the instructor for course 2 to be that name. 7. Prompt the user to enter an additional number of seats, and read in an integer value into the variable more (already declared for you) using in. Use the .ddseata ( ] method to add that number of seats to course 2. B. Use the print method to print out the information for course T. This step has been done for you 9. Print a blank line. This step has been done for you 10. Use the print ) method to print out the information for course 2 The code is started for you and some steps have been completed. Here is 1 sample run of your completed code (user input is in bold italics): Enter additional seats: 3 CSC 1481 Instructor: Schiclke CSC 1482 Seats: 13 Instructor: Jones

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

Question

=+ what roles should government play in them ?

Answered: 1 week ago

Question

=+ Why do we have markets and, according to economists,

Answered: 1 week ago