nl.bluering.ppracing
Class Car
java.lang.Object
|
+--nl.bluering.ppracing.Car
- public class Car
- extends java.lang.Object
This is the data class for the users car. It contains the locationhistory
of the car. It also features an undo-function. The car is moved, using vectors.
Constructor Summary |
Car(int sx,
int sy,
java.awt.Color c)
Builds a new car |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Car
public Car(int sx,
int sy,
java.awt.Color c)
- Builds a new car
- Parameters:
sx
- Horizontal start locationsy
- Vertical start locationc
- Color of the car
move
public void move(Vector vec)
- Moves the car using the given vector
- Parameters:
vec
- The new speed-vector
fault
public void fault()
- Is called when the grass is hit, to keep track of erronous counted turns
getx
public int getx()
- Returns:
- The horizontal position of the car
gety
public int gety()
- Returns:
- The vertical position of the car
getstartx
public int getstartx()
- Returns:
- The horizontal start-position of the car
getstarty
public int getstarty()
- Returns:
- The vertical start-position of the car
getturns
public int getturns()
- Returns:
- The number of turns done, including erronous
getplayerturns
public int getplayerturns()
- Returns:
- The number of turns done by the player
gethistory
public Vector gethistory(int i)
- Parameters:
i
- Index of the desired vector- Returns:
- The movement vector on a specific point of time
getvector
public Vector getvector()
- Returns:
- The current movement-vector
getspeed
public double getspeed()
- Returns:
- The current speed of the car
getcolor
public java.awt.Color getcolor()
- Returns:
- The color of the car
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
- Returns:
- A string representation of the car, including position and movement
undo
public void undo()
- This function undos the last players' move