I am trying to check the customers request against the volume remaining in the tank. If the request is greater, I need to instruct the customer to move to the next tank. But I am having problems. The tank is set to store 100 gallons. On the 1st request, I ask for more than 100 gallons, and instead of moving to the next pump it I am told to try another station.
The second problem is if the 1st customer is dispensed an amount less than the 100 gallon capacity, the 2nd customer can also be issued an amount less than the 100 gallons, instead of being moved to the next pump.
Any help will be appreciated.
if (listOfPumps[pumpSelection]->checkRorP(grade, quantity)== true)
{
listOfPumps[pumpSelection]->dispense(grade, quantity);
numOfCustomers--;
listOfPumps[pumpSelection]->getVolume(grade);
} // end if check == true
///////////////////////////////////////////////////////
//////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
else // checkRorP == false
{
int nextPump = pumpSelection%5 + 1 ;
while (nextPump != pumpSelection)
{
if (listOfPumps[nextPump]->checkRorP(grade, quantity)==true)
{
listOfPumps[nextPump]->dispense(grade, quantity);
numOfCustomers--;
/*
cout << "\nThe amount left in tank is " <<
listOfPumps[nextPump]->getRegVolume() << endl;
*/
listOfPumps[nextPump]->getVolume(grade);
break;
} // end if
else
nextPump = nextPump%5 + 1;
}
if (nextPump == pumpSelection)
{
cout << "Sorry, we cannot service you. Please try another gas station. Sorry for the inconvenience\n" ;
numOfCustomers--;
}
}