Chapter 6: Classes
1. Write a class called Cake with the following attributes:
· Number of layers (an int)
· Flavors (a string)
· Price (a float)
A constructor should set up
each cake (that is, each Cake object) as single layer, plain, ten dollar
cake. Make separate member functions to
change and print each attribute.
2. Make a class called Boxer. Each boxer (that is, each Boxer object) created in the main has a weight class, power rating, speed rating, as well a win-loss record (two separate private data members). These attributes should be defined in the main rather than prompting the user. The constructor should be set up to default these attributes, if none are sent upon instantiation. Make a fight member function that accepts two boxers (two references to Boxer objects). The fight function should check to see if they’re in the same weight class. If so, it should use a reasonable algorithm of your choosing that incorporates the attributes of each boxer, as well as a luck factor, to determine the winner of the fight. A stat function should print out all the info on a boxer, including an up-to-date win-loss record.
3. Problem 6.6, page 412
4. Problem 6.7, page 413
5. Problem 6.15, page 414
6. Problem 6.16, page 414