public class Water {
private Graphic graphic;
private float speed;
private float distanceTraveled;
public Water(float x, float y, float direction)
{
speed = 0.7f;
graphic = new Graphic();
graphic.setType("WATER");
graphic.setX(x);
graphic.setY(y);
direction = graphic.getDirection(); //direction from Hero as water is fired
}
public Water update(int time)
{
graphic.draw();
return Water.this;
distanceTraveled; // this is where the error occured...
}
}
When I tried to call distanceTraveled, I am getting the error as:
Syntax error, insert "VariableDeclarators" to complete LocalVariableDeclaration
To make the Syntax error disappear and to assign a value to distanceTraveledmodify the method public Water update(int time) as follows:
public Water update(int time) {
graphic.draw();
distanceTraveled = 1; // assign a value before returning
return Water.this;
}
Maybe you should read a bit about Java and doing some tutorials, because this is very basic stuff (at least if I'm not getting you wrong).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With