Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class GasPump
- {
- private:
- int highOctane;// quantity of high octane gas in the pump
- int medOctane;// quantity of medium octane gas in the pump
- int lowOctane;// quantity of low octane gas in the pump
- int priceHigh;// price/gallon for high octane gas
- int priceMed;// price/gallon for medium octane gas
- int priceLow;// price/gallon for low octane gas
- int totalHigh;// total cash earned from high octane sales
- int totalMed;// total cash earned from medium octane sales
- int totalLow;// total cash earned from low octane sales
- public:
- //constructor
- GasPump();
- GasPump(int l, int m = 100, int h = 100);
- GasPump(double prl, double prm, double prh);
- void setHighGal(int gallons);
- void setMedGal(int gallons);
- void setLowGal(int gallons);
- void setHighPrice(double price);
- void setMedPrice(double price);
- void setLowPrice(double price);
- int getHigh() const;
- int getMed() const;
- int getLow() const;
- double getPriceHigh() const;
- double getPriceMed() const;
- double getPriceLow() const;
- bool emptyHigh() const;
- bool emptyMed() const;
- bool emptyLow() const;
- double salePriceHigh(int gal);
- double salePriceMed(int gal);
- double salePriceLow(int gal);
- double earnedHigh();
- double earnedMed();
- double earnedLow();
- void display(ostream& out) const;
- };
- //===============CONSTRUCTORS===================
- GasPump::GasPump() // loads all pumps w/ 50 gallons, low price 2.00, med price 2.25, high price 2.50
- {
- setLowGal(50);
- setMedGal(50);
- setHighGal(50);
- setLowPrice(2.00);
- setMedPrice(2.25);
- setHighPrice(2.50);
- }
- GasPump::GasPump(int l, int m, int h)
- {
- setLowGal(l);
- setMedGal(m);
- setHighGal(h);
- setLowPrice(2.00);
- setMedPrice(2.25);
- setHighPrice(2.50);
- }
- GasPump::GasPump(double prl, double prm, double prh)
- {
- setLowGal(50);
- setMedGal(50);
- setHighGal(50);
- setLowPrice(prl);
- setMedPrice(prm);
- setHighPrice(prh);
- }
- //===============SETTERS===================
- void GasPump::setHighGal(int gallons)
- {
- totalHigh = 0;
- highOctane = gallons*(gallons >= 0);
- }
- void GasPump::setMedGal(int gallons)
- {
- totalMed = 0;
- medOctane = gallons*(gallons >= 0);
- }
- void GasPump::setLowGal(int gallons)
- {
- totalLow = 0;
- lowOctane = gallons*(gallons >= 0);
- }
- void GasPump::setHighPrice(double price)
- {
- totalHigh = 0;
- priceHigh= price*(price >= 0);
- }
- void GasPump::setMedPrice(double price)
- {
- totalMed = 0;
- priceMed= price*(price >= 0);
- }
- void GasPump::setLowPrice(double price)
- {
- totalMed = 0;
- priceLow= price*(price >= 0);
- }
- //===============GETTERS===================
- double GasPump::getPriceHigh() const //returns price for high octane
- {
- return priceHigh;
- }
- double GasPump::getPriceMed() const //returns price for medium octane
- {
- return priceMed;
- }
- double GasPump::getPriceLow() const //returns price for low octane
- {
- return priceLow;
- }
- bool GasPump::emptyHigh() const //is high octane empty?
- {
- if (highOctane > 0)
- return true;
- else
- return false;
- }
- bool GasPump::emptyMed() const //is medium octane empty?
- {
- if (medOctane > 0)
- return true;
- else
- return false;
- }
- bool GasPump::emptyLow() const //is low octane empty?
- {
- if (lowOctane > 0)
- return true;
- else
- return false;
- }
- double GasPump::salePriceHigh(int gal) //purchase gal gallons of high octane, cost of this purchase is returned
- {
- return priceHigh;
- }
- double GasPump::salePriceMed(int gal) //purchase gal gallons of medium octane, cost of this purchase is returned
- {
- return priceMed;
- }
- double GasPump::salePriceLow(int gal) //purchase gal gallons of low octane, cost of this purchase is returned
- {
- return priceLow;
- }
- int main()
- {
- double gallons;
- int input;
- GasPump GasPump1;
- cout << "Select amount of high (gallons) octane gas to fill the pump with." << endl;
- cin >> gallons;
- GasPump1.setHighGal(gallons);
- cout << "Select amount (gallons) of medium octane gas to fill the pump with." << endl;
- cin >> gallons;
- GasPump1.setMedGal(gallons);
- cout << "Select amount (gallons) of low octane gas to fill the pump with." << endl;
- cin >> gallons;
- GasPump1.setLowGal(gallons);
- while (input != 0)
- {
- cout << "--Main menu--\n" << endl;
- 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;
- cin >> input;
- switch(input)
- {
- case 1:// Enter quantity of gas with which each pump will be filled
- {
- break;
- }
- case 2:// enter a price for each grade of gas
- {
- break;
- }
- case 3:
- {
- cout << "--Purchase Menu--\n" << endl;
- cout << "Enter: 1, 2, 3, \, x" << endl;
- cin >> input;
- switch(input)
- {
- case 1:
- break;
- case 2:
- break;
- case 3:
- break;
- }
- break;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement