
Hello, I am having trouble with this homework assignment for C++ (See below for the output)
2. Implement the following:
a. A class named Food.
1. dynamic data member: name
2. accessors and mutators
3. the big three
b. A class named Cake that inherits from Food.
1. dynamic data member: topping (type of icing such as chocolate)
2. accessors and mutators
3. the big three
c. Create an object of type Food and output its data member.
d. Create an object of type Cake and output its data members.
e. Test all inherited functions in main. (Cannot change the given int main. Any alteration is not accepted)
int main() {
cout << endl;
Food f1("Bread");
f1.output();
cout << "\nf2: Copy Constructor" << endl;
Food f2 = f1;
f2.output();
cout << "\nf3: Assignment Overload" << endl;
Food f3;
f3 = f2;
f3.output();
cout << "\nFood: Mutator" << endl;
f1.setName("Pizza");
f2.setName("Sandwich");
f1.output();
f2.output();
f3.output();
cout << "\nCake:\n" << endl;
Cake c1("Ice Cream Cake", "Chocolate Icing");
c1.output();
cout << "\ns2: Copy Constructor" << endl;
Cake c2(c1);
c2.output();
cout << "\ns3: Assignment Overload" << endl;
Cake c3;
c3 = c2;
c3.output();
cout << "\nCake: Mutator" << endl;
c1.setName("Cheese cake");
c1.setTopping("Strawberry");
c2.setName("Potato Cake");
c2.setTopping("Vanilla");
c1.output();
c2.output();
c3.output();
cout << endl;
return 0;
}
Output from the main function above: (This is what the output should be. Anything else will not be accepted)
Bread
f2: Copy Constructor
Bread
f3: Assignment Overload
Bread
Food: Mutator
Pizza
Sandwich
Bread
Cake:
Ice Cream Cake, Chocolate Icing
s2: Copy Constructor
Ice Cream Cake, Chocolate Icing
s3: Assignment Overload
Ice Cream Cake, Chocolate Icing
Cake: Mutator
Cheesecake, Strawberry
Potato Cake, Vanilla
Ice Cream Cake, Chocolate Icing

Trending nowThis is a popular solution!
Step by stepSolved in 5 steps with 1 images

- Q2: Using C# - Class Account declares two instance variables, name and balance. Class SavingAccount derives from Account and declares an instance variable minBalance of type double. Write the constructor for class SavingAccount, which calls the base class constructor to initialize base class variables and variable minBalance.arrow_forwardHello, I am having trouble with this homework assignment for c++ 2. Implement the following:a. A class named Food.1. dynamic data member: name2. accessors and mutators3. the big threeb. A class named Cake that inherits from Food.1. dynamic data member: topping (type of icing such as chocolate) Due date: Jul 27, 11:59 PM2. accessors and mutators3. the big three c. Create an object of type Food and output its data member. d. Create an object of type Cake and output its data members. e. Test all inherited functions in main. (Cannot change the given int main. Any alteration is not accepted)int main() {cout << endl;Food f1("Bread");f1.output();cout << "\nf2: Copy Constructor" << endl;Food f2 = f1;f2.output();cout << "\nf3: Assignment Overload" << endl;Food f3;f3 = f2;f3.output();cout << "\nFood: Mutator" << endl;f1.setName("Pizza");f2.setName("Sandwich");f1.output();f2.output();f3.output();cout << "\nCake:\n" << endl;Cake c1("Ice Cream…arrow_forwardPYTHON CLASSES AND OBJECTarrow_forward
- Java:arrow_forwardSummary In this lab, you create a derived class from a base class, and then use the derived class in a Python program. The program should create two Motorcycle objects, and then set the Motorcycle’s speed, accelerate the Motorcycle object, and check its sidecar status. Instructions Open the file named Motorcycle.py. Create the Motorcycle class by deriving it from the Vehicle class. Call the parent class __init()__ method inside the Motorcycle class's __init()__ method. In theMotorcycle class, create an attribute named sidecar. Write a public set method to set the value for sidecar. Write a public get method to retrieve the value of sidecar. Write a public accelerate method. This method overrides the accelerate method inherited from the Vehicle class. Change the message in the accelerate method so the following is displayed when the Motorcycle tries to accelerate beyond its maximum speed: "This motorcycle cannot go that fast". Open the file named MyMotorcycleClassProgram.py. In the…arrow_forwardIn C++ Q1.) Write a Review class that has: • These private data members: • string user: ID of the user • string item: ID of the item • double paid: the price of the item that the user buys • double rating: the rating that the user gives to the item • string review: the review content that the user gives to the item • These public member functions: • A default constructor to set all instance variables to a default value • A parameterized constructor (i.e., a constructor with arguments) to set all instance variables • A method for getting/setting the instance variables. • A method for printing the Review's information.arrow_forward
- Make Album in c++ You are going to develop a new class named Album. This class will has (at a minimum) teh following attributes and features: Attributes: Album Title Artist Name Array of song names (Track Listing) Array of track lengths (decide on a unit) At most there can be 20 songs on an album. Behaviors: Default and at least one argumented constructor Appropriate getters for attributes bool addTrack(string name, type duration) - adds track to album. You decide type on duration. Make sure you document what dis is. getAlbumLength() - method dat returns total length of album matching watever units / type you decide. getAlbumLength_string() - method dat returns total length of album in mm:ss format string. I would suggest using you're other getLength function here. string shuffleAlbum(int n) - method dat returns a formatted string made up of n random tracks from teh album. The string will be in the format [1] track_name (mm:ss), [2] track_name (mm:ss)... Well formatted print()…arrow_forwardC++ A college must track equipment items purchased using special funds.Create an inventory class that represents an equipment item. An equipment item consists of an 8-alphanumeric inventory number, a short description of the item, the purchase price of the item, and its currentlocation (e.g.: room/building location). If an item is surplussed (e.g., gotten rid of), then the current locationshould say surplus, but the item should remain on the list.Write a program that reads inventory items from a file into a vector. Implement a menu system that allows theuser to add, edit, and delete records from the list as well as search the list based on inventory number and printa report of all records. The list should always be maintained in order of inventory number. When the programcloses, the data file should be overwritten with the most recent data from the list.arrow_forwardUsing C++: Write a program that creates a Bus class that includes a bus ID number, number of seats, driver name, and current speed. Create a default constructor without any parameters that initializes the value of ID number, number of seats, and driver name. Create another constructor with three parameters of bus id number, number of seats, and driver name. Car speed should always be initialized as 0. The program will also include the member functions to perform the various operations: modify, set, and display bus information (Bus id, number of seats, driver name, and current speed). For example:- Set the bus id number- Set the number of seats- Set of driver number----------------------------------------------------- Return the bus id number by using get method- Return the number of seats- Return of driver number- Return the current speed-----------------------Member function to display the bus information- busInformation() Also write two member functions, Accelerate() and Brake().…arrow_forward
- People in School Objective: At the end of the activity, the students should be able to: Create a program that exhibits inheritance. Procedure: Write a simple information system that will store and display the complete information of a student, faculty, or employee. Create four (4) no-modifier classes named Person, Student, Faculty, and Employee. Create a public class named CollegeList. This class shall contain the main method. Refer to the UML Class Diagram for the names of the variables and methods. The (-) symbol represents private variables, while (+) represents public method. This should be the sequence of the program upon execution: Prompt the user to select among Employee, Faculty, or Student, by pressing E, F, or S. Ask the user to type the name and contact For Employee, ask the user to type the employee's monthly salary and the department where he/she belongs to (Ex. Registrar). Then, display name, contact number, salary, and For Faculty, ask the user to press Y if…arrow_forwardC++arrow_forwardPythonarrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY





