CSC134 Lab7 SwimmingPool-SP2020
CSC134 Lab7 SwimmingPool-SP2020
CSC134 Lab7 SwimmingPool-SP2020
Objectives
- how to create a class, which unlike a struct, allows you to group data and functions.
Goals
Grading
Complete the following programming exercise. Electronically submit all necessary source code
files for compilation. You will not get any points if your code does not compile.
Chapter 10:
Swimming Pool Management –
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%)
o 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.
o The instant variables must all be private members of the class.
Must add the SwimmingPool Constructor(s) and Destructor member functions. (10%)
______________________________________________________________________________________________________________________________________________________________________________________________________________________
//Main program
#include <iostream>
#include "swimmingPool.h"
int main()
{
cout << "The initial total number of pools in this program is "<<
SwimmingPool::getNumberOfPools() << endl;
cout << "To completely fill the pool: " << endl;
cout << " Enter water fill in rate (Gallons Per Minute): ";
cin >> waterFRate;
cout << endl;
pools[i].setWaterFlowRateIn(waterFRate);
time = pools[i].timeToFillThePool();
//Subtract the 3rd Pool from the 2nd Pool to create the subPool
cout << "\n\nThe 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;
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:
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
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
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