I need help with this Java program over a Rat class program shown below detailed on the given image: package classPackage; import interfaces.RatInterface; import interfaces.CellInterface; import java.util.ArrayList; import interfaces.HoleInterface; public class Rat implements RatInterface { private int ratEnergy = 5; @Override public String move() { // TODO Auto-generated method stub returnnull; } @Override publicint getAliveState() { // TODO Auto-generated method stub return 0; } @Override publicvoid refresh() { ratEnergy = 5; } @Override publicvoid wearDown() { ratEnergy -= 1; } @Override public String getId() { // TODO Auto-generated method stub returnnull; } } This is an ratInterface that describes what should be inputted in the rat Class program: package interfaces; /** * * @author Owner * */ 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 */ publicint getAliveState(); /** * Rat is refreshed * Clears away exhaustion */ publicvoid refresh(); /** * Rat gets a little more exhausted * If exhaustion gets too low Rat dies. */ publicvoid wearDown(); /** * Retrieve the Rat's ID */ public String getId(); }
I need help with this Java program over a Rat class program shown below detailed on the given image:
package classPackage;
import interfaces.RatInterface;
import interfaces.CellInterface;
import java.util.ArrayList;
import interfaces.HoleInterface;
public class Rat implements RatInterface {
private int ratEnergy = 5;
@Override
public String move() {
// TODO Auto-generated method stub
returnnull;
}
@Override
publicint getAliveState() {
// TODO Auto-generated method stub
return 0;
}
@Override
publicvoid refresh() {
ratEnergy = 5;
}
@Override
publicvoid wearDown() {
ratEnergy -= 1;
}
@Override
public String getId() {
// TODO Auto-generated method stub
returnnull;
}
}
This is an ratInterface that describes what should be inputted in the rat Class program:
package interfaces;
/**
*
* @author Owner
*
*/
public interface RatInterface
{
/**
* The move() method has the rat randomly select one of the eight possible moves directions.<br>
* (N, NW, W, SW, S, SE, E, NE);<br>
* @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
*/
publicint getAliveState();
/**
* Rat is refreshed
* Clears away exhaustion
*/
publicvoid refresh();
/**
* Rat gets a little more exhausted
* If exhaustion gets too low Rat dies.
*/
publicvoid wearDown();
/**
* Retrieve the Rat's ID
*/
public String getId();
}
Step by step
Solved in 4 steps with 2 images