Answered step by step
Verified Expert Solution
Question
1 Approved Answer
NAMED: 5p) public interface Named The Named interface consists of objects which have been given a name. It is comprised of one single method public
NAMED: 5p) public interface Named The Named interface consists of objects which have been given a name. It is comprised of one single method public String getName0 lots of disTerent things can have a name. This interface could represent any of them ENTITY: (5p) public interface Entity extends Named An Entity is something which can move around from place to place. It has a name which it has inherited from Named. In normal usage, setting a location would first involve calling setLocation with null (in order to leave the previous location), and then immediately set location again with the new location public void setLocation Location loc) typically this method would cause the entity to leave a previous location (if one was defined) and update the current location.. public Location getLocationO report back the current location of the entity. Notice how Entity has a couple of methods which have Location as a parameter or return type? It's ok for two interfaces to depend on one another. LOCATION: (5p) public interface Location extends Named A location has a name, but it can also be entered or left by an Entity. Furthermore, it can have a set of neighbors, which can be returned as a list public void enter(Entity e) enter the Location; this may involve informing the Entity that it's been added, and possibly recording the presence of the entity. public boolean leave(Entity e) the opposite of enter, this may involve informing the entity that it's left, and possibily removing the entity from some list; also returns true if the removal was successful public Location] getNeighbors0 returns a list of Locations which represent neighbors of the current location. DIRECTION: (10p) public enum Direction This is an enumeration which represents the four compass directions, north, south, east, and west. The actual members of the enumeration will be N, S, E, and W (in that order), but they will each have an overridden toString0 method which holds the string values "north", "south", "east", and "west". private Direction(String name) initializes the element of the enumeration using the given name @Override public String toString0 returns the name of the direction (i.e. "north
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started