Home | Trees | Indices | Help |
|
---|
|
object --+ | Car
Class Car
represents cars which can be drive about on a
two-dimensional coordinate plane. A car has a fuel tank that contains
gasoline (the maximum amount is determined by the car's tank size). Each
car can have a different fuel consumption rate.
N.B. Wherever the class car makes use of Location
, the
coordinates of each location are in kilometers (float). For instance, the
distance between (-5, 0) and (7, 0) is 12km.
|
|||
|
|||
boolean |
|
||
float |
|
||
float |
|
||
float |
|
||
location object |
|
||
float |
|
||
Inherited from |
|
|||
Inherited from |
|
Constructs a new car with the given attributes and which has its kilometer count set to zero.
|
Drives in a straight line towards the destination. If there isn't enough fuel, the car stops somewhere along the way. This method calculates how far is the destination from the starting location, figures out how many kilometers can be driven using current fuel amount, consumes fuel and updates kilometer count, determines new location and creates an object of it.
|
Adds a given amount of fuel to the tank, if possible. If the given amount cannot be poured into the tank, the tank is filled up and the rest of the fuel discarded.
|
Fills up the tank of this car. (Hint: you can call the method
|
Returns a number between 0 and 100 that represents the percentage of fuel in the tank. That is, 100 means the tank is full and 0 means it is empty.
|
Tells where the car is located at the moment
|
Returns the total number of kilometers driven with this car.
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Mon Oct 1 13:37:09 2012 | http://epydoc.sourceforge.net |