public class Agent {
private Space _location;
private String _name;
public void setLocation(Space space){
_location = space;
}
public void usePortal(){
if(_location.getPortal() != null){
Portal.transport(Agent.this);
}
}
}
java.lang.Error: Unresolved compilation problem: Cannot make a static reference to the non-static method transport(Agent) from the type Portal
Above is the error it gives me. I have a public class Space with a member variable of type Portal and a getPortal() getter. which looks like:
public class Space {
private String _name;
private String _description;
private Portal _portal;
public Portal getPortal(){
return _portal;
}
}
In my public Portal class, I have a transport method with an Agent parameter:
public class Portal {
private String _name;
private String _direction;
private Space _destination;
public Space getDestination(){
return _destination;
}
public void transport(Agent str){
str.setLocation(getDestination());
}
}
My main problem is having the usePortal() method to work, the Space and Portal classes are fully functional. I don't know how I would call the method on an instance of Agent within the Agent class.