#include < iostream >
using namespace std;
class Gastank{
private:
	int lowFuelLevel;
	int currentFuelLevel;
	int MAX_FUEL_LEVEL;
public:
	Gastank(){ // Default Constructor
		MAX_FUEL_LEVEL = 20;
		currentFuelLevel = 0;
		lowFuelLevel = (MAX_FUEL_LEVEL / 4);
	}
	Gastank(int userVal){ // Alt Constructor
		MAX_FUEL_LEVEL = userVal;
		currentFuelLevel = 0;
		lowFuelLevel = (MAX_FUEL_LEVEL / 4);
	}
	int fillTank(int gasUp){ // Put gas in the tank, tell us how much was ACTUALLY put in the tank
		if (gasUp + currentFuelLevel > MAX_FUEL_LEVEL){
			int fuelMissing = MAX_FUEL_LEVEL - currentFuelLevel;
			currentFuelLevel = MAX_FUEL_LEVEL;
			return fuelMissing;
		}
		else if (currentFuelLevel == MAX_FUEL_LEVEL){ // Tank is already full
			return 0;
		}
		else{
			currentFuelLevel += gasUp; // Put gas in the tank
			return gasUp;
		}
	}
	int getTankCapacity(){
		return MAX_FUEL_LEVEL;
	}
	int getFuelLevel(){ // Return the gas level in the tank 
		return currentFuelLevel;
	}
	int used(int gasOut){ // Take gas out of the tank
		if (currentFuelLevel - gasOut <= 0){
			currentFuelLevel = 0;
			return 0;
		}
		else{
			currentFuelLevel -= gasOut;
		}
	}
	bool isFuelLow(){ // Toggle the low-fuel light
		if (currentFuelLevel <= lowFuelLevel)
			return true;
		else
			return false;
	}
};
void main()
{
	int gallonsUsed;
	int gallonsIn;
	int menuOp;
	Gastank tank1; // Object to point to class function
	tank1.fillTank(3);
	Gastank tank2(5);
	tank2.fillTank(5);
	cout << "Fuel Tanks: " << endl;
	cout << "Fuel Tank 1: " << tank1.getFuelLevel() << " / " << tank1.getTankCapacity();
	if (tank1.isFuelLow()){
		cout << "   Warning: Fuel Low";
	}
	cout << endl;
	cout << "Fuel Tank 2: " << tank2.getFuelLevel() << " / " << tank2.getTankCapacity() << endl;
	cout << endl;
	cout << "Menu Selections" << endl;
	cout << "1) Query Tanks" << endl;
	cout << "2) Fill Tanks" << endl;
	cout << "3) Use Tanks" << endl;
	cout << "Choose Menu Option (Integers Only): ";
	cin >> menuOp;
	switch (menuOp){
	case 1:{
		cout << "1) Query Tanks" << endl;
		cout << "Current fuel level for Tank 1 is: " << tank1.getFuelLevel() << endl;
		cout << "Current fuel level for Tank 2 is: " << tank2.getFuelLevel() << endl;
		break;
	}
	case 2:{
		cout << "2) Fill Tanks" << endl;
		cout << "Please enter the gallons to fill :";
		cin >> gallonsIn;
		cout << "Gallons filled Tank 1 ->" << tank1.fillTank(gallonsIn) << endl;
		cout << "Gallons filled Tank 2 ->" << tank2.fillTank(gallonsIn) << endl;
		break;
	}
	case 3:{
		
		cout << "3) Use Tanks" << endl;
		tank1.used(gallonsUsed);
		tank2.used(gallonsUsed);
		cout << "Gallons out Tank 1 ->" << tank1.used(gallonsUsed) << endl;
		cout << "Gallons out Tank 2 ->" << tank2.used(gallonsUsed) << ". Tank level is now " << tank2.getFuelLevel() << endl;
		break;
	}
system("pause"

 ;
}