riggnaros

swimmingpool_main

Apr 21st, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.54 KB | None | 0 0
  1. //Main program
  2.  
  3. #include <iostream>
  4.  
  5. #include "swimming_pool_header.h"
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.  
  12.     swimmingPool pool(30, 15, 10, 0, 0, 100);
  13.  
  14.     double waterFRate;
  15.     double waterDRate;
  16.     int galAdd;
  17.     int galDrain;
  18.     int time;
  19.     int selection;
  20.     char exitSelection;
  21.  
  22.     cout << "Pool data: " << endl;
  23.     cout << "  Length: " << pool.getLength() << endl;
  24.     cout << "  Width: " << pool.getWidth() << endl;
  25.     cout << "  Depth: " << pool.getDepth() << endl;
  26.     cout << "  Total capacity of pool (Cubic Gallons): " << pool.poolTotalWaterCapacity() << endl;
  27.     cout << "  Total water in the pool: " << pool.getTotalWaterInPool() << endl;
  28.  
  29.     do {
  30.     cout << "Menu: \n";
  31.     cout << "1. Fill the pool.\n";
  32.     cout << "2. Drain the pool.\n";
  33.     cout << "3. Add water to the pool.\n";
  34.     cout << "4. Drain water from the pool.\n";
  35.     cout << "5. Exit\n";
  36.     cin >> selection;
  37.  
  38.     if (selection == 1) {
  39.         cout << "Enter water fill in rate (in Gallons per min): ";
  40.         cin >> waterFRate;
  41.         cout << endl;
  42.         pool.setWaterFlowRateIn(waterFRate);
  43.         cout << endl;
  44.         cout << "  Water In Flow Rate: " << pool.getWaterFlowRateIn() << endl;
  45.         cout << "  Water needed to fill the pool (cubic gallons): " << pool.waterNeededToFillThePool() << endl;
  46.  
  47.         time = pool.timeToFillThePool();
  48.  
  49.         cout << "  Time to fill the pool is appriximately: "
  50.             << time / 60 << " hour(s) and " << time % 60
  51.             << " minute(s)." << endl;
  52.     }
  53.  
  54.     else if (selection == 2) {
  55.         cout << "Enter water drain rate (in Gallons per min): ";
  56.         cin >> waterDRate;
  57.         cout << endl;
  58.         pool.setWaterFlowRateOut(waterDRate);
  59.         cout << endl;
  60.  
  61.         cout << "  Water Out Flow Rate: " << pool.getWaterFlowRateOut() << endl;
  62.         cout << "  Water needed to drain from the pool (cubic gallons): " << pool.waterNeededToDrainThePool() << endl;
  63.  
  64.         time = pool.timeToDrainThePool();
  65.  
  66.         cout << "  Time to drain the pool is appriximately: "
  67.             << time / 60 << " hour(s) and " << time % 60
  68.             << " minute(s)." << endl;
  69.     }
  70.  
  71.     else if (selection == 3) {
  72.         cout << "Enter how many gallons of water you would like to add: \n" << endl;
  73.         cin >> galAdd;
  74.         pool.addWater(galAdd);
  75.         cout << endl;
  76.         cout << "Updated amount of water in pool: " << pool.getTotalWaterInPool() << endl;
  77.     }
  78.  
  79.     else if (selection == 4) {
  80.         cout << "Enter how many gallons of water you would like to remove: \n" << endl;
  81.         cin >> galDrain;
  82.         pool.drainWater(galDrain);
  83.         cout << endl;
  84.         cout << "Update amount of water in pool: " << pool.getTotalWaterInPool() << endl;
  85.     }
  86.     else if (selection >= 5)
  87.         exit(0);
  88.     } while (selection >= 1);
  89.  
  90.     return 0;
  91. }
Add Comment
Please, Sign In to add comment