Create a class called furniture that has a string data attribute called color. The attribute default value is "brown" an
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Create a class called furniture that has a string data attribute called color. The attribute default value is "brown" an
Create a class called furniture that has a string data attribute called color. The attribute default value is "brown" and acceptable values are "brown", "cherry", "white". Create get and set functions. Create the all default argument constructor. Overload the stream insertion operator (operator<<) to output the details of a furniture object (output must be: furniture: <color>). Create a class called chair that will be publicly derived from the furniture class. This class introduces one new data attribute, an integer called legs which will use 4 as the default value and acceptable values are from 1 to 6. Create get and set functions and the all-default argument constructor with the member initializer listing. Overload the stream extraction operator (operator>>) to read in a string followed by an integer and assign (using the set respective functions) to color and legs. Write a driver program that will declare an array of 500 chair objects and then include a loop to go through the array and enter details using the overloaded stream extraction operator. Finally, write code to answer the following questions: 1. what is the total number of legs from all the chairs 2. what is the the total count of "brown" chairs 3. what is the relationship of percentages of the "brown" and "cherry" chairs. The captures below demonstrate example runs with only 3 elements. enter chair details (color legs): white 4 enter chair details (color legs): white 4 enter chair details (color legs): brown 3 Total leg count is: 11 Total white chair count is: 2 brown (33.3333 %) is greater than cherry (0%)