I have followed the Greenfoot tutorial that explains how to access one abject from another. In the Pitch class I have added the following method:
public Player1 getX()
{
return player;
}
and in the Stick class I access the method as follows:
Pitch pitch = (Pitch) getWorld();
Player1 player= pitch.getX();
int xpos = player.getX();
This works fine as discussed in the tutorial.
However, I wish to getX() for another class Player2. I have added the following to the Pitch class:
public Player1 getX()
{
return player;
}
public Player2 getX()
{
return player2;
}
and it returns the following error:
getX() is already defined in Pitch
Is there anyway to define the same method for more than one object so they can be passed to other objects.
Many thanks in advance.

