|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectCarStat
public class CarStat
This class implements a mutable class for keeping car race statistics on miles led, percent of miles led, and average finish. Each object represents one driver and his/her stats.
Constructor Summary | |
---|---|
CarStat(java.lang.String name,
int number)
This constructor creates a CarStat object with a driver name and car number. |
Method Summary | |
---|---|
double |
avgFinish()
This accessor method calculates the average position of finish for this driver over the races in which the driver competed. |
java.lang.String |
getDriver()
This accessor method returns the name of this driver. |
double |
getMilesLed()
This accessor method returns the total miles led by this driver. |
double |
percentMilesLed()
This accessor method returns the percent of miles led by this driver as a percentage of the total miles of all races. |
static void |
setupRace(double lapLength,
double miles)
This mutator method sets the track size and distance data for a race and must be called before calling updateRaceStats to add statistics for that race to any object. |
java.lang.String |
toString()
This method returns a string representation of this object. |
void |
updateRaceStats(int lapsLed,
int position)
This mutator method updates the individual driver statistics on laps led, average finish position. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public CarStat(java.lang.String name, int number)
name
- Driver namenumber
- Car numberMethod Detail |
---|
public static void setupRace(double lapLength, double miles)
lapLength
- Size of the track in milesmiles
- Length of race in milespublic void updateRaceStats(int lapsLed, int position)
lapsLed
- Number of laps that this driver led the raceposition
- Position number at end of the racepublic double avgFinish()
public double percentMilesLed()
public double getMilesLed()
public java.lang.String getDriver()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |