A)
public void
ResetAll() {
for (int a = 0; a < myPumps.length; a++) { // loop through every
pump we have
myPumps[a].ResetGallonsSold(); // and call
ResetGallonsSold on them
}
}
B)
public double
TotalSales() {
double total = (myPumps[0].GallonsSold() + myPumps[1].GallonsSold()) *
(mybaseprice + .25);
// set total to the first 2 pumps at full service rates
for (int a = 2; a < myPumps.length; a++) { // go through all
remaining pumps (start at index 2)
total = total + myPumps[a].GallonsSold() * mybaseprice; //
add in the given pump at the base price
}
return total; // return the total
}
C)
public
void CloseStation(PrintWriter logfile) {
logfile.println("" + TotalSales()); // write out the TotalSales
(coverted to a String) to the logfile
ResetAll(); // reset all of the pumps to 0 (thanks to Part A!)
}