|
|
|
|
This program creates at least 5 separate, co-existing instances of a custom designed object. Information about each object is displayed. Each constructor, setter and getter is tested at least once. How many objects do you want? You created 5 objects: # 1 of 5 objects: Name: Apple Quantity: 4 Weight: 4.56 Price: $4 Did you purchase? true # 2 of 5 objects: Name: Orange Quantity: 7 Weight: 2.65 Price: $5 Did you purchase? true # 3 of 5 objects: Name: Banana Quantity: 4 Weight: 2.34 Price: $2 Did you purchase? false # 4 of 5 objects: Name: Avocado Quantity: 0 Weight: 2.59 Price: $0 Did you purchase? false # 5 of 5 objects: Name: Grapes Quantity: 0 Weight: 0 Price: $5 Did you purchase? false This ends the class design, implementation, test program. Goodbye! Program ended with exit code: 0 |
~Fruit(){};
is all that's required, ie without the message. It's up to you.
|
|
This program creates at least 5 separate, co-existing instances of a custom designed object. Information about each object is displayed. Each constructor, setter and getter is tested at least once. How many objects do you want? 10 There is space for 10 fruits in your cart Name: Apple Quantity: 4 Weight: 4.56 Price: $4 Did you purchase? true # 2 of 5 objects: Name: Orange Quantity: 7 Weight: 2.65 Price: $5 Did you purchase? true # 3 of 5 objects: Name: Banana Quantity: 4 Weight: 2.34 Price: $2 Did you purchase? false # 4 of 5 objects: ****** ERROR: Invalid quantity - try again Name: Avocado Quantity: 0 Weight: 2.59 Price: $0 Did you purchase? false # 5 of 5 objects: ****** ERROR: Invalid quantity - try again Name: Grapes Quantity: 0 Weight: 0 Price: $5 Did you purchase? false *** ITEM #0 of 5 fruits ... Name: Apple Quantity: 4 Weight: 4.56 Price: $4 Did you purchase? true *** ITEM #1 of 5 fruits ... Name: Orange Quantity: 7 Weight: 2.65 Price: $5 Did you purchase? true *** ITEM #2 of 5 fruits ... Name: Banana Quantity: 4 Weight: 2.34 Price: $2 Did you purchase? false *** ITEM #3 of 5 fruits ... Name: Avocado Quantity: 0 Weight: 2.59 Price: $0 Did you purchase? false *** ITEM #4 of 5 fruits ... Name: Grapes Quantity: 0 Weight: 0 Price: $5 Did you purchase? false This ends the class design, implementation, test program. Goodbye! Program ended with exit code: 0 |
Without flogging a dead horse the destructor is important and regardless of opinions to the contrary leaving it out is a no-brainer reusability mistake. Your teacher should know better. A simple ~Fruit(){}; is all that's required, ie without the message. It's up to you. |
It wasn't meant to be passive aggressive. |
someone wrote: |
---|
// Setters should NOT change existing valid member values to invalid values. // If given invalid data in a setter, reject it. Do not change the value. |
|
|
This program creates at least 5 separate, co-existing instances of a custom designed object. Information about each object is displayed. Each constructor, setter and getter is tested at least once. How many objects do you want? (Limit is 5): 4 You created 4 objects: # 1 of 4 objects: Name: Apple Quantity: 4 Weight: 4.56 Price: $4 Did you purchase? true # 2 of 4 objects: Name: Orange Quantity: 7 Weight: 2.65 Price: $5 Did you purchase? true # 3 of 4 objects: Name: Banana Quantity: 4 Weight: 2.34 Price: $2 Did you purchase? false # 4 of 4 objects: Name: Avocado Quantity: 0 Weight: 2.59 Price: $0 Did you purchase? false # 5 of 4 objects: Name: Grapes Quantity: 0 Weight: 0 Price: $5 Did you purchase? false This ends the class design, implementation, test program. Goodbye! Program ended with exit code: 0 |
|
|
|
|