Question: Swimming Pool Management (C++) In this programming exercise you will create a simple swimming management program according to the following customer specifications: - Write the
Swimming Pool Management (C++)
In this programming exercise you will create a simple swimming management program according to the following customer specifications:
- Write the definition of a class SwimmingPool, to implement the properties and functions of a swimming pool. The pool must be a rectangular shaped of any dimension. (20%)
-- The class should have the instant variables to store the length (in feet), width (in feet), depth (in feet), amount (in cubic feet), of water in the pool, the rate (in gallons / minute), at which the water is draining from the pool.
- Must add the SwimmingPool Constructor(s) and Destructor member functions. (10%)
- Add appropriate accessor and mutator member functions.(10%)
- Add member functions to do the following: (40%)
-- determine the amount of water needed to fill an empty or partially filled pool,
-- determine the time needed to completely or partially fill or empty the pool, and add or drain water for a specific amount of time.
-- Allow adding or subtracting one or more pools (add by adding lenghs, widths and depths, rates and amount subtract by subtracting lengths, widths, and depths, rates and amount).
Add a static property (data member) to count the number of swimming pools created and static member function to report this count.(20%)
NOTE: The amount of gallons in a cubic feet is 7.48
Please use the following driver program to test your class:
//Main program
#include
#include "swimmingPool.h"
using namespace std;
int main()
{
cout << "The initial total number of pools in this program is "<<
SwimmingPool::getNumberOfPools() << endl;
const int NUM_OF_POOLS = 3;
SwimmingPool pools[NUM_OF_POOLS];
pools[0] = SwimmingPool(30, 15, 10);
pools[1] = SwimmingPool(60, 25, 16);
pools[2] = SwimmingPool(35, 20, 11);
int waterFRate;
int time;
cout << "Pool data: " << endl;
for (int i = 0; i < 3; i++)
{
cout << " ";
cout << "POOL # " << i + 1 << ": " << endl;
cout << " Length: " << pools[i].getLength() << endl;
cout << " Width: " << pools[i].getWidth() << endl;
cout << " Depth: " << pools[i].getDepth() << endl;
cout << " Total water in the pool: " <<
pools[i].getTotalWaterInPool() << endl;
cout << "To completely fill the pool: " << endl;
cout << " Enter water fill in rate: ";
cin >> waterFRate;
cout << endl;
pools[i].setWaterFlowRateIn(waterFRate);
time = pools[i].timeToFillThePool();
cout << " Time to fill the pool is approximately: "
<< time / 60 << " hour(s) and " << time % 60
<< " minute(s)." << endl;
}
//Add 2nd Pool to 3rd Pool
cout << " The Added Pool Data: " << endl;
SwimmingPool addedPool = pools[2].add(pools[1]);
cout << " Length: " << addedPool.getLength() << endl;
cout << " Width: " << addedPool.getWidth() << endl;
cout << " Depth: " << addedPool.getDepth() << endl;
cout << " Total water in the pool: " <<
addedPool.getTotalWaterInPool() << endl;
//Subtract the the 3rd Pool from the 2nd Pool
cout << " The Subtracted Pool Data: " << endl;
SwimmingPool subPool = pools[1].subtract(pools[2]);
cout << " Length: " << subPool.getLength() << endl;
cout << " Width: " << subPool.getWidth() << endl;
cout << " Depth: " << subPool.getDepth() << endl;
cout << " Total water in the pool: " <<
subPool.getTotalWaterInPool() << endl;
SwimmingPool extraPool(20, 10, 5);
cout << " The total number of pools created in this program is "
<< extraPool.getNumberOfPools() << endl;
system("pause");
return 0;
}
//In your SwimmingPool class, add the following Copy Constructor member function to your class. (No modification is required to this function):
//Copy Constructor Topic covered in chapter 11.
SwimmingPool::SwimmingPool(const SwimmingPool ©)
{
length = copy.length;
width = copy.width;
depth = copy.depth;
waterFlowInRate = copy.waterFlowInRate;
waterFlowOutRate = copy.waterFlowOutRate;
amountOfWaterInPool = copy.amountOfWaterInPool;
numOfPools++;
}
SAMPLE OUTPUT:
The initial total number of pools in this program is 0
Pool data:
POOL # 1:
Length: 30
Width: 15
Depth: 10
Total water in the pool: 0
To completely fill the pool:
Enter water fill in rate: 10
Time to fill the pool is approximately: 56 hour(s) and 6 minute(s).
POOL # 2:
Length: 60
Width: 25
Depth: 16
Total water in the pool: 0
To completely fill the pool:
Enter water fill in rate: 10
Time to fill the pool is approximately: 299 hour(s) and 12 minute(s)
POOL # 3:
Length: 35
Width: 20
Depth: 11
Total water in the pool: 0
To completely fill the pool:
Enter water fill in rate: 10
Time to fill the pool is approximately: 96 hour(s) and 0 minute(s).
The Added Pool Data:
Length: 95
Width: 45
Depth: 27
Total water in the pool: 0
The Subtracted Pool Data:
Length: 25
Width: 5
Depth: 5
Total water in the pool: 0
The total number of pools created in this program is 6
Press any key to continue . . .
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
