Write a class named Pool to represent a swimming pool. Start with writing a UML diagram that we develop in class as a group. The class should have:
private data fields to store the length (in feet), width (in feet), depth (in feet), volume (in cubic feet), and a boolean field named is_empty to indicate if the pool is empty.
A default constructor without any parameters to initialize the data field variables. Assume our default pool has a length of 10, width of 10, and depth of 5 and is empty. Note the volume is calculated as: length * width * depth
Appropriate public methods (mutators) to set the value of each of the private data fields.
Appropriate public methods (accessors) to get the value of each of the private data fields.
A member function named tostring() that returns a string description of the pool. If the pool is empty, the function returns the length, width, depth, and volume in one combined string. If the pool is not empty, the function returns the length, width, depth, and volume along with the string "pool is full " in one combined string.
Write a test program that creates two Pool objects. For the first object, create it as a default pool. For the second object, assign length of 70, width of 30, depth of 15 and assume that the pool is full. Display the objects by invoking their tostring function.
Here is a sample run for the calculations.
object 1: Length:10 Width: 10 Depth:5 Volume: 500 object 2: Length:70 Width: 30 Depth:15 Volume: 31500 pool is full
String concatenation:
In order to create a string that mixes strings and numbers, use the ostringstream definition.
Need:
include < sstream> For example: ostringstream s1; double age = 30; string name = "foo"; string news; s1 << name << " is " << age << "tyears oldn"; news = s1.str(); // convert the ostringstream to a string cout << news;
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference
and should not be submitted as is. We are not held liable for any misuse of the solutions.
Please see the frequently asked questions page
for further questions and inquiries.
Kindly complete the form.
Please provide a valid email address and we will get back to you within 24 hours.
Payment is through PayPal, Buy me a Coffee
or Cryptocurrency.
We are a nonprofit organization however we need funds to keep this organization operating
and to be able to complete our research and development projects.