Advertisement
Guest User

Untitled

a guest
Oct 21st, 2014
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.96 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. class GasPump
  7. {
  8. private:
  9.     int highOctane;// quantity of high octane gas in the pump
  10.     int medOctane;// quantity of medium octane gas in the pump
  11.     int lowOctane;//  quantity of low octane gas in the pump
  12.     int priceHigh;//  price/gallon for high octane gas
  13.     int priceMed;// price/gallon for medium octane gas
  14.     int priceLow;// price/gallon for low octane gas
  15.     int totalHigh;// total cash earned from high octane sales
  16.     int totalMed;// total cash earned from medium octane sales
  17.     int totalLow;// total cash earned from low octane sales
  18.    
  19. public:
  20.     //constructor
  21.     GasPump();
  22.     GasPump(int l, int m = 100, int h = 100);
  23.     GasPump(double prl, double prm, double prh);
  24.    
  25.     void setHighGal(int gallons);
  26.     void setMedGal(int gallons);
  27.     void setLowGal(int gallons);
  28.    
  29.     void setHighPrice(double price);
  30.     void setMedPrice(double price);
  31.     void setLowPrice(double price);
  32.    
  33.     int getHigh() const;
  34.     int getMed() const;
  35.     int getLow() const;
  36.    
  37.     double getPriceHigh() const;
  38.     double getPriceMed() const;
  39.     double getPriceLow() const;
  40.    
  41.     bool emptyHigh() const;
  42.     bool emptyMed() const;
  43.     bool emptyLow() const;
  44.    
  45.     double salePriceHigh(int gal);
  46.     double salePriceMed(int gal);
  47.     double salePriceLow(int gal);
  48.    
  49.     double earnedHigh();
  50.     double earnedMed();
  51.     double earnedLow();
  52.    
  53.     void display(ostream& out) const;
  54. };
  55.  
  56. //===============CONSTRUCTORS===================
  57.  
  58. GasPump::GasPump() // loads all pumps w/ 50 gallons, low price 2.00, med price 2.25, high price 2.50
  59. {
  60.     setLowGal(50);
  61.     setMedGal(50);
  62.     setHighGal(50);
  63.    
  64.     setLowPrice(2.00);
  65.     setMedPrice(2.25);
  66.     setHighPrice(2.50);
  67. }
  68.  
  69. GasPump::GasPump(int l, int m, int h)
  70. {
  71.     setLowGal(l);
  72.     setMedGal(m);
  73.     setHighGal(h);
  74.    
  75.     setLowPrice(2.00);
  76.     setMedPrice(2.25);
  77.     setHighPrice(2.50);
  78.    
  79. }
  80.  
  81. GasPump::GasPump(double prl, double prm, double prh)
  82. {
  83.     setLowGal(50);
  84.     setMedGal(50);
  85.     setHighGal(50);
  86.    
  87.     setLowPrice(prl);
  88.     setMedPrice(prm);
  89.     setHighPrice(prh);
  90.    
  91. }
  92.  
  93. //===============SETTERS===================
  94. void GasPump::setHighGal(int gallons)
  95. {
  96.     totalHigh = 0;
  97.     highOctane = gallons*(gallons >= 0);
  98. }
  99.  
  100. void GasPump::setMedGal(int gallons)
  101. {
  102.     totalMed = 0;
  103.     medOctane = gallons*(gallons >= 0);
  104. }
  105.  
  106.  
  107. void GasPump::setLowGal(int gallons)
  108. {
  109.     totalLow = 0;
  110.     lowOctane = gallons*(gallons >= 0);
  111. }
  112.  
  113. void GasPump::setHighPrice(double price)
  114. {
  115.     totalHigh = 0;
  116.     priceHigh= price*(price >= 0);
  117. }
  118.  
  119. void GasPump::setMedPrice(double price)
  120. {
  121.     totalMed = 0;
  122.     priceMed= price*(price >= 0);
  123. }
  124.  
  125. void GasPump::setLowPrice(double price)
  126. {
  127.     totalMed = 0;
  128.     priceLow= price*(price >= 0);
  129. }
  130.  
  131. //===============GETTERS===================
  132. double GasPump::getPriceHigh()   const  //returns price for high octane
  133. {
  134.     return priceHigh;
  135. }
  136.  
  137. double GasPump::getPriceMed()  const    //returns price for medium octane
  138. {
  139.     return priceMed;
  140. }
  141.  
  142. double GasPump::getPriceLow()  const   //returns price for low octane
  143. {
  144.     return priceLow;
  145. }
  146.  
  147. bool GasPump::emptyHigh()  const  //is high octane empty?
  148. {
  149.     if (highOctane > 0)
  150.         return true;
  151.     else
  152.         return false;
  153.    
  154. }
  155.  
  156. bool GasPump::emptyMed()  const  //is medium octane empty?
  157. {
  158.     if (medOctane > 0)
  159.         return true;
  160.     else
  161.         return false;
  162. }
  163.  
  164. bool GasPump::emptyLow() const   //is low octane empty?
  165. {
  166.     if (lowOctane > 0)
  167.         return true;
  168.     else
  169.         return false;
  170. }
  171.  
  172. double GasPump::salePriceHigh(int gal)  //purchase gal gallons of high octane, cost of this purchase is returned
  173. {
  174.     return priceHigh;
  175. }
  176.  
  177. double GasPump::salePriceMed(int gal)  //purchase gal gallons of medium octane, cost of this purchase is returned
  178. {
  179.     return priceMed;
  180. }
  181.  
  182. double GasPump::salePriceLow(int gal)  //purchase gal gallons of low octane, cost of this purchase is returned
  183. {
  184.     return priceLow;
  185. }
  186.  
  187. int main()
  188. {
  189.     double gallons;
  190.     int input;
  191.     GasPump GasPump1;
  192.    
  193.     cout << "Select amount of high (gallons) octane gas to fill the pump with." << endl;
  194.     cin >> gallons;
  195.     GasPump1.setHighGal(gallons);
  196.     cout << "Select amount (gallons) of medium octane gas to fill the pump with." << endl;
  197.     cin >> gallons;
  198.     GasPump1.setMedGal(gallons);
  199.     cout << "Select amount (gallons) of low octane gas to fill the pump with." << endl;
  200.     cin >> gallons;
  201.     GasPump1.setLowGal(gallons);
  202.    
  203.     while (input != 0)
  204.     {
  205.        
  206.         cout << "--Main menu--\n" << endl;
  207.         cout << "Choose an action:\n1) Add a quantity of gas to any of the thr/ee pumps.\n2) Enter a price for each grade of gas.\n3) Enter gas purchase menu.\n4) Output quantity of low grade gasoline remaining.\n5) Output quantity of medium grade gasoline remaining.\n6) Output quantity of high grade gasoline remaining.\n7) Output the quantity of cash made by each grade.\n0) Quit" << endl;
  208.         cin >> input;
  209.        
  210.         switch(input)
  211.         {
  212.             case 1:// Enter quantity of gas with which each pump will be filled
  213.             {
  214.                 break;
  215.             }
  216.             case 2:// enter a price for each grade of gas
  217.             {
  218.                 break;
  219.             }
  220.             case 3:
  221.             {
  222.                 cout << "--Purchase Menu--\n" << endl;
  223.                 cout << "Enter: 1, 2, 3, \, x" << endl;
  224.                 cin >> input;
  225.                
  226.                
  227.                 switch(input)
  228.                 {
  229.                     case 1:
  230.                         break;
  231.                     case 2:
  232.                         break;
  233.                     case 3:
  234.                         break;
  235.                        
  236.                 }
  237.                
  238.                
  239.                 break;
  240.             }
  241.                
  242.                
  243.                
  244.         }
  245.     }
  246.     return 0;
  247. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement