I'm learning Java and need to make a vehicle simulator.
A vehicle can move one step each round either vertically or horizontally.
b) move method increments or decrements either x or y coordinates by 1.
I don't know if my unfinished code will be of any help, but here it is:
package vehicleSimulator;
public class Vehicle {
int h; // horizontal coordinate instead of x
int v; // vertical coordinate instead of y
boolean isAlive = true;
public Vehicle(int h, int v, boolean isAlive) {
this.h = h;
this.v = v;
this.isAlive = isAlive;
}
public void moveVehicle() {
if (isAlive == true) {
// ++ or -- x or y
}
}
Any help or links to sites that can help is much appreciated.
Aucun commentaire:
Enregistrer un commentaire