|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectbecker.xtras.gasPump.SampleMeter
public final class SampleMeter
A sample class implementing the IMeter interface. It measures the
volume of fuel sold and calculates the amount owed by the
customer, given the current fuel cost.
Please see the package description for a more in-depth discussion of using this class.
| Constructor Summary | |
|---|---|
SampleMeter(double unitCost,
int octaneRating,
String theLabel)
Construct a new fuel meter. |
|
| 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. |
static void |
main(String[] args)
Used to test the class. |
void |
pump(double howMuch)
Pump some fuel into a tank. |
void |
reset()
Reset the meter for a new customer. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SampleMeter(double unitCost,
int octaneRating,
String theLabel)
unitCost - The cost per unit volume of fuel. For example, $2.85/gallon
or $1.05/litre.octaneRating - An integer related to the "performance" of the fuel; usually
between 87 and 93.theLabel - A label for the fuel such as "Gold" or "Ultra".| Method Detail |
|---|
public void reset()
IMeter
reset in interface IMeterpublic void pump(double howMuch)
IMeter
pump in interface IMeterhowMuch - How much fuel was pumped since the last time this
method was called.public double getUnitCost()
IMeter
getUnitCost in interface IMeterpublic double getVolumeSold()
IMeter
getVolumeSold in interface IMeterpublic int getOctane()
IMeter
getOctane in interface IMeterpublic String getLabel()
IMeter
getLabel in interface IMeterpublic double calcTotalCost()
IMeter
calcTotalCost in interface IMeterpublic void addView(IView aView)
IMeterupdateView
method must be called each time the meter's state changes.
addView in interface IMeterpublic static void main(String[] args)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||