becker.xtras.gasPump
Interface IMeter

All Known Implementing Classes:
SampleMeter

public interface IMeter

Objects implementing IMeter are used to measure the volume of fuel delivered to a customer at a gas pump. Such objects also know the current cost per unit (liter or gallon) of fuel and can thus calculate the cost of the fuel delivered. For informational purposes, they also know the octane level of the fuel and a marketing label such as "Gold" or "Ultra".

A typical gas pump will have three objects implementing IMeter, one for each of the three different kinds of fuel available.

Please see the package description for a more in-depth discussion of using this class.

Author:
Byron Weber Becker

Method Summary
 void addView(IView aView)
          Add a view (graphical user interface) to the meter.
 double calcTotalCost()
          Calculate the total cost of fuel sold to this customer.
 String getLabel()
          Get the label for this meter's fuel.
 int getOctane()
          Get the octane rating of the fuel.
 double getUnitCost()
          Get the cost per unit of fuel.
 double getVolumeSold()
          Get the volume of fuel sold to this customer.
 void pump(double howMuch)
          Pump some fuel into a tank.
 void reset()
          Reset the meter for a new customer.
 

Method Detail

getUnitCost

double getUnitCost()
Get the cost per unit of fuel.

Returns:
cost per unit of fuel

getVolumeSold

double getVolumeSold()
Get the volume of fuel sold to this customer.

Returns:
volume of fuel sold

getOctane

int getOctane()
Get the octane rating of the fuel.

Returns:
octane rating (typically between 87 and 93)

getLabel

String getLabel()
Get the label for this meter's fuel. For example, "Gold" or "Ultra".

Returns:
this meter's fuel label

reset

void reset()
Reset the meter for a new customer.


pump

void pump(double howMuch)
Pump some fuel into a tank. This method is called repeatedly while the "handle" on the pump is pressed.

Parameters:
howMuch - How much fuel was pumped since the last time this method was called.

calcTotalCost

double calcTotalCost()
Calculate the total cost of fuel sold to this customer.

Returns:
price/unit * number of units sold

addView

void addView(IView aView)
Add a view (graphical user interface) to the meter. The view's updateView method must be called each time the meter's state changes.