import static java.lang.System.*;
public class ShipTester
{
public static void main (String []args)
{
Ship s1 = new Ship();
s1.setX(3);
s1.setY(10);
s1.setSPeed(22);
out.println(s1.getX());
out.println(s1.getY());
out.println(s1.getSpeed());
out.println(s1);//calls the ToString method
Ship s2 = new Ship (3,10, 22);
ship s3 = new Ship(5,7 );
s3.setSpeed(19);
out.println(s1.equals(s2));//s2 becomes rhs
out.println(s1.equals(s3));//s3 becomes rhs
}
}
public class Ship
{
private int x,y, speed;
public Ship()
{
x=y=speed=0;
}
public Ship(int xx,int yy)
{
x=xx;
y=yy;
speed=0;
}
public Ship(int xx,int yy,int sp)
{
x=xx;
y=yy;
speed=sp;
}
public int getX(){return x;}
public int getY(){return y;}
public int getSpped(){return speed;}
public void setX(int x){xx == x;}
public void setY(int y){yy== y;}
public void setSpeed(int sp){speed= sp;}
public boolean equals(Ship rhs)//rhs=right hand side
{
if(x==rhs.x&&y==rhs.y&&speed==rhs.speed)
return true;
return false;
}
public String toString()
{
return x +", "+y+", " = speed;
}
} // put your code here
it says those red lettered ones are not a statement.
what's wrong with those?