I need help with this Java program over a Cell class program shown below detailed in the given image: This is the Java code (Cell class)that need fixed with help of both the given image and the interface guide -  package classPackage;   import java.util.ArrayList;   import interfaces.CellInterface; import interfaces.RatInterface;   /** * @author Owner * */ public class Cell implements CellInterface { privatefinalint [] location; private ArrayList ratHouse = new ArrayList (); public Cell(int[] pLocation) { location = pLocation.clone();     }   @Override publicchar getCellType() { // TODO Auto-generated method stub return 0; }   @Override publicint[] receiveRat(RatInterface pRat) { pRat.wearDown(); if (Math.random()<.2) pRat.refresh(); ratHouse.add(pRat); returnlocation.clone(); }   @Override public RatInterface retrieveRat() { /** * 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 */ returnratHouse; }   @Override publicvoid 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. */ }   @Override public ArrayList returnTheDead() { // TODO Auto-generated method stub returnnull; }   }     The interface code that has directions that needs to be inputted in the cell class code -  package interfaces;   import java.util.ArrayList;   /** * @author Owner * */ public interface CellInterface { int[] location = newint[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 four cell types Cell, Hole, Waste, or Shelter * @Postcondition no change * @return a character for the cell type */ publicchar getCellType();   /** * The receiveRat() method receives a rat and stores the rat * @param RatInterface holds reference to Rat object * @return * Returns {row,col} * cell location if rat is accepted and stored * -1, -1 if there is no space to hold the rat * */ publicint[] 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 */ public RatInterface retrieveRat();   /** * 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 */ publicvoid 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(); }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I need help with this Java program over a Cell class program shown below detailed in the given image:

This is the Java code (Cell class)that need fixed with help of both the given image and the interface guide - 

package classPackage;

 

import java.util.ArrayList;

 

import interfaces.CellInterface;

import interfaces.RatInterface;

 

/**

* @author Owner

*

*/

public class Cell implements CellInterface {

privatefinalint [] location;

private ArrayList <RatInterface> ratHouse = new ArrayList <RatInterface>();

public Cell(int[] pLocation) {

location = pLocation.clone();

 

 

}

 

@Override

publicchar getCellType() {

// TODO Auto-generated method stub

return 0;

}

 

@Override

publicint[] receiveRat(RatInterface pRat) {

pRat.wearDown();

if (Math.random()<.2)

pRat.refresh();

ratHouse.add(pRat);

returnlocation.clone();

}

 

@Override

public RatInterface retrieveRat() {

/**

* 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

*/

returnratHouse;

}

 

@Override

publicvoid 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.

*/

}

 

@Override

public ArrayList<RatInterface> returnTheDead() {

// TODO Auto-generated method stub

returnnull;

}

 

}

 

 

The interface code that has directions that needs to be inputted in the cell class code - 

package interfaces;

 

import java.util.ArrayList;

 

/**

* @author Owner

*

*/

public interface CellInterface

{

int[] location = newint[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.<br>

* It should indicate one of the four cell types Cell, Hole, Waste, or Shelter

* @Postcondition no change

* @return a character for the cell type

*/

publicchar getCellType();

 

/**

* The receiveRat() method receives a rat and stores the rat

* @param RatInterface holds reference to Rat object

* @return

* Returns {row,col}<br>

* cell location if rat is accepted and stored<br>

* -1, -1 if there is no space to hold the rat

*

*/

publicint[] 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

*/

public RatInterface retrieveRat();

 

/**

* 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

*/

publicvoid 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<RatInterface> returnTheDead();

}

 

 
The Cell class will:
implement CellInterface
store the Cell's location on the grid. Do this during the constructor.
"house" a rat between moves by using receive Rat(Rat) to take the rat and then store it.
randomly wear down or refresh the rat.
hold rats that die in the cell.
return rats that die in the cell.
return a rat when asked, if that one is housed in it.
Transcribed Image Text:The Cell class will: implement CellInterface store the Cell's location on the grid. Do this during the constructor. "house" a rat between moves by using receive Rat(Rat) to take the rat and then store it. randomly wear down or refresh the rat. hold rats that die in the cell. return rats that die in the cell. return a rat when asked, if that one is housed in it.
Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Adjacency Matrix
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education