Question
c++program Define class Sales that has the following: - private members: 1. int * sold_items: points to an array of integers. Each element in the
c++program
Define class Sales that has the following:
- private members:
1. int * sold_items: points to an array of integers. Each element in the array represents the number of sold items in a day. The default value of any element in the array is 3.
2. int sales_size: it is the size of the sold_items array, it represents the number of days on which the item was sold. Its default value is 7.
- public functions:
1. One Constructor (parameterized and default) that takes a value to set all the elements of the array, and the size of the array. If any of these parameters is not passed, then its value is set to the default value.
2. Getter for the sales_size, dont write a setter for it.
3. Getter for the sold_items array at a given day, it receives an index and returns the stored value in that index in the sold_items array. Assume the index is in the proper range.
4. void set_sales(int value, int index): it sets the received value in the received index in the sold_items array. Assume the index is in the proper range.
5. int set_sales(int arr[], int sales_size): it copies the values in arr to the sold_items array and then returns 1. This function works only if the passed array size equals the sold_items array size. Otherwise, it returns -111.
Define class Item which has the following:
- private data members:
1. double price: represents the price of the item. Its default value is 5.
- protected data members:
1. Sales item_sales: an object of class Sales that represents the sales of an item.
- public data members:
1. const double cost: it represents the cost of the item. Its default value is 1.
- Public functions:
1. One constructor (parameterized and default): it takes a value to set all the elements of the sold_items array, its size, price, and cost. If any of these parameters is not passed, then its value is set to the default value.
2. Getter and setter for the price.
3. Getter for the item_sales object.
4. void show_report(): it prints the item price, cost, and the number of days on which it was sold.
Define class Clothing_Item which is an Item that has following:
- private data members:
1. int clothing_size: it represents the size of the clothing item. Its default value is 0.
2. static int counts: initialized to 0. It counts the number of Clothing_Item objects created so far.
- public functions:
1. One constructor (parameterized and default): it takes a value to set all the elements of the sold_items array, its size, price, cost, and the size of the clothes. If any of these parameters is not passed, then its value is set to the default value.
2. Getter for the clothing_size data member.
3. Getter for the counts data member, make it a static function.
4. multiply_price(double factor): it updates the price to be the multiplication of the price by the factor.
5. Override the show_report function to call the show_report function of the Item class and print the size of the clothing item.
6. A friend function duplicateMaxSales(Clothing_Item & item): it doubles the maximum sales value in the sold_items array. Example: if the maximum value in the sold_items array is 10, then it becomes 20.
In the driver program define the following:
- non-member function of the following form to do the following:
void operations(Clothing_Item c[], int size, int i, int sales_value)
If the value in the sold_items array in the index (i) is smaller than the sales_value, then replace the value in the sold_items array at that index with the sales_value. Do that for all objects in the c array.
The following example shows the sold_items arrays of each Clothing_Item object in c array.
c elements sold_items
c[0] -----> {3, 4, 4, 5}
c[1] -----> {4, 3, 3, 7}
c[2] -----> {7, 3, 8, 3}
If the index (i) is 2 and the sales_value is 6. Then the sold_items arrays of each Clothing_Item object in c array should be as follows:
c elements sold_items
c[0] -----> {3, 4, 6, 5}
c[1] -----> {4, 3, 6, 7}
c[2] -----> {7, 3, 8, 3}
- Write the main function to do the following:
a. Define an array of 4 Clothing_Item objects.
b. Ask the user to enter sales for 7 days. Then, set these sales in the sold_items array for the last object in the Clothing_Item array.
c. Double the price of the second object in the Clothing_Item array.
d. Call duplicateMaxSales function for the last object in the Clothing_Item array.
e. Use the operations function to set the first element of the sold_items array to 5, if its value is less than 5. Do that for all objects in the Clothing_Item.
f. Print the number of Clothing_Item objects created so far.
g. Print the information of all objects of the Clothing_Item array using show_report function.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started