I have a question regarding interfaces. I have a interface that has all the methods of a class called GameWorld. The GameWorld holds a class called GameObject that can be tanks, rocks, missiles, etc.
public interface IGameWorld
{
public Point getLocation(); // GameObject
public Color getColor();
public void setLocation(Point newCoord);
public void setColor(Color newColor);
}
I want to implement the methods in IGameWorld in GameWorld's GameObject class. Something like this.
public class GameWorld implements IGameWorld
{
// vector to hold gameobjects
public class GameObject
{
private Point location;
private Color color; // all objects have a random color
GameObject()
{
// method
}
public Point getLocation()
{
// method
}
public Color getColor()
{
// method
}
public void setLocation (Point newCoord)
{
// method
}
public void setColor (Color newColor)
{
// method
}
}
}
Is that possible? And if not, what is the alternative to doing this? Thanks.