I'm currently trying to create a client program that sends location variables (x and y) to a server, which then passes it on to another client and vice versa so when one client moves the object, the other client see's the change immediately on screen.
I think get and set methods are the way forward for my task, but I can't figure out how to do this.
The client creates a new instance of an object which has the following methods:
public int getX() {
return x;
}
public int getY() {
return y;
}
public void setX(int x) {
this.x = x;
}
public void setY(int y) {
this.y = y;
}
The client code has:
player1.getX();
player1.getY();
While the server code has:
player1.setX();
player1.setY();
The object code and client code compile fine, but the server code refuses to compile stating:
setX(int) in Car cannot be applied to ()
player1.setX();
With the same thing for setY();
Could someone please explain what i'm doing wrong? Or a better method to pass the location coordinates between clients and servers?
Thanks