Answered step by step
Verified Expert Solution
Link Copied!

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[2];
/**
* 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 {row,col}
* cell location
*/
public int[] receiveRat(RatInterface pRat);
/**
* The retrieveRat(String 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 retrieveRat(String pRatId);
/**
* The storeTheDead(Rat 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 storeTheDead(RatInterface 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 disappear/escape
* or stayed at this location
* @param RatInterface holds reference to Rat object
* @return
* Returns {row,col}
* 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[] receiveRat(RatInterface 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.
*0 Rat is alive, 1 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
*1 Rat lost or dead
*0 Rat alive
*-1 Rat finished
*/
public int getRatState();
/**
*
* @param pRateState
*1 Rat lost or dead
*0 Rat alive
*-1 Rat finished
*/
public void setRatState(int 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
*1 if rat is no longer exists
*0 if mouse moves to a new cell but not the exit
*-1 if rat finishes
*/
public RatStatusInterface moveRat(String 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 [0][0](cell notifies desert, d
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

More Books

Students also viewed these Databases questions