Answered step by step
Verified Expert Solution
Question
1 Approved Answer
/ * * * * / package interfacePackage; import java.util.ArrayList; / * * * @author Larry Shannon * * / public interface CellInterface { int
package interfacePackage;
import java.util.ArrayList;
@author Larry Shannon
public interface CellInterface
int location new int;
The getCellType returns the cell type
@Precondition The cell type must be initialized as a final variable during the construction of a cell object.
It should indicate one of the two cell types Cell, Hole
@Postcondition no change
@return a character for the cell type
public char getCellType;
The receiveRat method receives a rat and stores the rat
@param RatInterface holds reference to Rat object
@return
Returns rowcol
cell location
public int receiveRatRatInterface pRat;
The retrieveRatString pRatID method receives a rat ID and returns the reference to that rat if the rat is stored in the cell
@param RatID holds String ID of Rat object
@return Returns the reference to a Rat object if there is one in the cell
postcondition: the reference to the Rat object is removed from the cell
public RatInterface retrieveRatString pRatId;
The storeTheDeadRat pRat method stores the argument Rat in a list of dead rats.
precondition: pRat must reference a Rat object, a list structure of some kind that stores rats, must exist.
postcondition: pRat's reference is added to a list of dead rats.
@param pRat
public void storeTheDeadRatInterface pRat;
The returnTheDead method retrieves a list of the rats that died in the cell.
@precondition The dead rat ArrayList must exist though it need not have any rats in it
@postcondition none
@return
ArrayList of Rat objects.
public ArrayList returnTheDead;
package interfacePackage;
@author Larry Shannon
public interface HoleInterface extends CellInterface
The receiveRat method receives a rat,
then randomly determines if the rat went down the hole
to another cell
to disappearescape
or stayed at this location
@param RatInterface holds reference to Rat object
@return
Returns rowcol
new row col of cell rat is ends up in
this location is also returned if the Rat escapes.
When the Cell is queried for the escaped Rat It will return a null
public int receiveRatRatInterface pRat;
@return
count of rats that have disappeared
public int countLostSouls;
package interfacePackage;
@author Larry Shannon
public interface RatInterface
The move method has the rat randomly select one of the eight possible moves directions.
N NW W SW S SE E NE;
@Precondition: None
@Postcondition: None
@return
the unbiased, randomly generated, direction to move the rat
public String move;
The getAliveState method returns the alive status of the rat.
Rat is alive, Rat is dead of exhaustion
@Precondition: the Rat's alive status has been initialized
@Postcondition: no change in the mouse's state
@return
the integer value of the mouse's alive status
public int getAliveState;
Rat is refreshed
Clears away exhaustion
public void refresh;
Rat gets a little more exhausted
If exhaustion gets too low Rat dies.
public void wearDown;
Retrieve the Rat's ID
public String getId;
package interfacePackage;
@author Larry Shannon
public interface RatStatusInterface
@return String representation of Rat ID
public String getRatID;
@return integer of Rat's state
Rat lost or dead
Rat alive
Rat finished
public int getRatState;
@param pRateState
Rat lost or dead
Rat alive
Rat finished
public void setRatStateint pRateState;
package interfacePackage;
@author Larry Shannon
public interface DesertInterface
Obtains a new rat and introduces it at the start of the desert.
@return
Id of Rat and its status as a tuple object.
public RatStatusInterface startRat;
Finds the current rat and instructs the rat to move.
@param currentMouse
@return Rat ID and status
if rat is no longer exists
if mouse moves to a new cell but not the exit
if rat finishes
public RatStatusInterface moveRatString pRatID;
Prints all required information on dead rats.
void displayStatistics;
void printMap;
Responsibilities
If the rat tries to leave the maze by exiting one of the edge cells, across the edge, it stays in that cell until
it moves again but also wears down or refreshes by one unit. When a rat dies the control driver decides
if a new rat must then brave the desert from the beginning location cell notifies desert, d
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