Question: Composed / Aggregated Objects Create a new class named LunchBag. LunchBag should have data members of length, width, height, and a water bottle. All LunchBags
ComposedAggregated Objects Create a new class named LunchBag. LunchBag should
have data members of length, width, height, and a water bottle. All LunchBags have a bottle
holder that can hold a WaterBottle that can be purchased separately from the LunchBag so
it can be created in a main method and passed to the LunchBag class
Additional Requirements
a A default LunchBag should have dimensions of L x W x H
b There should be a default constructor that sets default values for the LunchBag. Create
a default WaterBottle in this constructor: setWaterBottlenew WaterBottle;
c There should be a convenience constructor that takes four parameters that match all
data members in the order they are listed in the description above.
d All LunchBag data members should have an accessor and a mutator and all values
should be positive. If they are not positive, set them to their default values.
This includes the WaterBottle data member which should also have an accessor
and a mutator.
e A LunchBag can hold a WaterBottle as long as the diameter is positive and less than or
equal to
If a WaterBottle is set using the appropriate mutator method, an error message
should be printed if the WaterBottle cannot be stored and a default WaterBottle
should be used in its place.
Note that an error message in the mutator is not the most appropriate
way to accomplish this. In Chapter we will learn the correct way.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
