I want to adapt the code below so that when int i increments by 1, c1.xlocation increments by its speed variable. ie in this case 30. rather than by 1.
Probably really simple but I can't see it!
CODE
public class Main
{
public String name; public int startX; public int endX; public int startY; public int endY; //road vars
public String vname; public double speed; public double xlocation; public double ylocation; //vehicle vars
public static void main(String[] args){
Road h1 = new Road ("H1", 0, 600, 50, 100);
Road h2 = new Road ("H2", 0, 600, 150, 200);
Road h3 = new Road ("H3", 0, 600, 250, 300);
Road v1 = new Road ("V1", 50, 100, 0, 400);
Road v2 = new Road ("V2", 150, 200, 0, 400);
Road v3 = new Road ("V3", 250, 300, 0, 400);
Vehicle c1 = new Car ("Car 1", 30, 20, 52);
Vehicle b1 = new Bike ("Bike 1", 15, 20, 51);
for (int i = 0; i<10; i++, c1.xlocation++)
System.out.println("Car 1 is at x position " + c1.xlocation);
}
}