Trouble with methods from libraries in Java?

303 Views Asked by At

So my class extends Actor, and I want to use the method getLocation() which requires Location from Actor, but it sends me to getLocation() of java.awt.Point which requires Point

public class Myplayer extends Actor
Location myLocation = player.getLocation();

The Error:

incompatible types: java.awt.Point cannot be converted to ch.aplu.jgamegrid.Location

Here are links to the two libraries:

Actor: http://www.aplu.ch/classdoc/jgamegrid/index.html

getLocation

public Location getLocation()

Returns the current location (horizontal and vertical coordinates).

Returns:
    a clone of the current location (cell indices)

Point: http://docs.oracle.com/javase/7/docs/api/java/awt/Point.html#getLocation%28%29

getLocation

public Point getLocation()

Returns the location of this point. This method is included for completeness, 
to parallel the getLocation method of Component.

Returns:
a copy of this point, at the same location

How I can fix this, without using Point?

EDIT:

import ch.aplu.jgamegrid.*;
import java.awt.Color;
import java.util.*;

public class MyPlayer extends Actor

private Players player

public Location myLocation() {
    return player.getLocation();
1

There are 1 best solutions below

0
On

The class Player inherits all methods of Actor, because of that I found that getLocation() can be used only by itself without calling an object reference.