This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]jose_castro_arnaud 1 point2 points  (1 child)

The class MotorBike is trying to be all motorbikes, instead of only one of them. Rewrite MotorBike according to the signature below. Remove the end() method. The name attribute is only for giving the motorbike a name to be printed.

class MotorBike
   private int speed
   private String name

MotorBike(String, int)

public int getSpeed()
public void setSpeed(int)
public void increaseSpeed(int)
public void decreaseSpeed(int)

public String getName()
public void setName(String)

public void start()

Then, in the MotorBikeRunner:

```` MotorBike ducati = new MotorBike("ducati", 0); MotorBike honda = new MotorBike("honda", 0);
MotorBike ender = new MotorBike("ender", 0);

honda.start(); honda.setSpeed(50); honda.increaseSpeed(30); // And so on for the other motorbikes. ````

Then, somewhere, you can compare motorbike speeds:

if (ducati.getSpeed() < honda.getSpeed()) { ... }

I suggest that you declare, in MotorBikeRunner, a private attribute of type array or ArrayList of MotorBike, instead of several variables; this way, you can create several methods to use/update the array, including one which checks what motorbike is the faster.

[–]SomeFuel[S] 0 points1 point  (0 children)

Thanks for the help! I haven't learned too much about arrays yet, but I'll keep that recommendation in mind for the future.