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. For instance, the
distance between (-5, 0) and (7, 0) is 12km.
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
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.
|
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 Tue Sep 13 12:15:51 2011 | http://epydoc.sourceforge.net |