Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

What is this class doing - please describe public abstract class Organism { //Ab

ID: 3716420 • Letter: W

Question

What is this class doing - please describe
public abstract class Organism { //Abstract class since new organism must be either ant or doodlebug //Variables private int timeStep; private Organism[][] board; private int row; private int col; private boolean canMove;
//Constructor public Organism(int myRow, int myCol,Organism[][] aBoard) {
//Variables timeStep = 0; row = myRow; col = myCol; canMove = false; board = aBoard; }
//Time methods //Increment one to the time step public void addTimeStep() { timeStep++; } //Resets timeStep to 0 public void resetTimeStep() { timeStep = 0; }
//Mutators; Modifies the private variables //Sets organism's ability to move on the next turn public void setCanMove(boolean moved) { canMove = moved; } //Sets the new row position of Organism object public void setRow(int newRow) { row = newRow; } //Sets the new column position of Organism object public void setCol(int newCol) { col = newCol; }
//Accessors; returns the values of the private variables //Accesses time step variable public int getTimeStep() { return timeStep; } //Accesses row position public int getRow() { return row; } //Accesses column position public int getCol() { return col; } //Accesses the board of all Organism objects public Organism[][] getBoard() { return board; } //Accesses whether the Organism can move or not public boolean canMove() { return canMove; }
//Abstraction for Move and Breed Methods; as abstract, they must be overwritten in Ant and Doodlebug class public abstract void move(); public abstract void breed(); }
What is this class doing - please describe
public abstract class Organism { //Abstract class since new organism must be either ant or doodlebug //Variables private int timeStep; private Organism[][] board; private int row; private int col; private boolean canMove;
//Constructor public Organism(int myRow, int myCol,Organism[][] aBoard) {
//Variables timeStep = 0; row = myRow; col = myCol; canMove = false; board = aBoard; }
//Time methods //Increment one to the time step public void addTimeStep() { timeStep++; } //Resets timeStep to 0 public void resetTimeStep() { timeStep = 0; }
//Mutators; Modifies the private variables //Sets organism's ability to move on the next turn public void setCanMove(boolean moved) { canMove = moved; } //Sets the new row position of Organism object public void setRow(int newRow) { row = newRow; } //Sets the new column position of Organism object public void setCol(int newCol) { col = newCol; }
//Accessors; returns the values of the private variables //Accesses time step variable public int getTimeStep() { return timeStep; } //Accesses row position public int getRow() { return row; } //Accesses column position public int getCol() { return col; } //Accesses the board of all Organism objects public Organism[][] getBoard() { return board; } //Accesses whether the Organism can move or not public boolean canMove() { return canMove; }
//Abstraction for Move and Breed Methods; as abstract, they must be overwritten in Ant and Doodlebug class public abstract void move(); public abstract void breed(); }
What is this class doing - please describe
public abstract class Organism { //Abstract class since new organism must be either ant or doodlebug //Variables private int timeStep; private Organism[][] board; private int row; private int col; private boolean canMove;
//Constructor public Organism(int myRow, int myCol,Organism[][] aBoard) {
//Variables timeStep = 0; row = myRow; col = myCol; canMove = false; board = aBoard; }
//Time methods //Increment one to the time step public void addTimeStep() { timeStep++; } //Resets timeStep to 0 public void resetTimeStep() { timeStep = 0; }
//Mutators; Modifies the private variables //Sets organism's ability to move on the next turn public void setCanMove(boolean moved) { canMove = moved; } //Sets the new row position of Organism object public void setRow(int newRow) { row = newRow; } //Sets the new column position of Organism object public void setCol(int newCol) { col = newCol; }
//Accessors; returns the values of the private variables //Accesses time step variable public int getTimeStep() { return timeStep; } //Accesses row position public int getRow() { return row; } //Accesses column position public int getCol() { return col; } //Accesses the board of all Organism objects public Organism[][] getBoard() { return board; } //Accesses whether the Organism can move or not public boolean canMove() { return canMove; }
//Abstraction for Move and Breed Methods; as abstract, they must be overwritten in Ant and Doodlebug class public abstract void move(); public abstract void breed(); }

Explanation / Answer

/*** I have provided the significance of each method and variable in the class in the comments . Please go through the class .***/

/***
*
* @author
* Creating an abstract class Organism which has list of private variables
* @Variable
* timestamp, board, row, col, canMove
* This is the abstract class so this class can't be initialised but other class which will extend this class can inherit its properties
* So Organism is an abstract class and we will create new class which will extend this class and will be of Ant or DoodleBug type
*
*/


public abstract class Organism { //Abstract class since new organism must be either ant or doodlebug

    //Variables

    private int timeStep;

    private Organism[][] board;

    private int row; // variable for the row position of the organism

    private int col; // var for the column position of organism

    private boolean canMove; // var to define whether organism can move or not


    //Constructor
    /***
     * Creating a parameterized constructor which intialises the class variable with the passed values.
     */

    public Organism(int myRow, int myCol,Organism[][] aBoard) {


        //Variables
    // timeStep is set to 0
        timeStep = 0;
        // row is set to myRow
        row = myRow;
        // col is set to myCol
        col = myCol;
        // setting canMove to false i.e. Organism can't move
        canMove = false;
        // setting board to aBoard
        board = aBoard;

    }


    //Time methods

    //Increment one to the time step
   
    /**
     * Creating a public method addTimeStep() which increaments the timestep by one
     */
    public void addTimeStep() {

        timeStep++;

    }

    //Resets timeStep to 0
    /**
     * Creating public method resetTimeStep() which resets the timeStep and sets back to Zero
     */
    public void resetTimeStep() {

        timeStep = 0;

    }


    //Mutators; Modifies the private variables

    //Sets organism's ability to move on the next turn
    /**
     *
     * Defining mutator or setter for variable canMove and sets its value to the passed boolean value
     * Basically it set that whether organism can move or not
     */
    public void setCanMove(boolean moved) {

        canMove = moved;

    }

    //Sets the new row position of Organism object
   
    /**
     * Defining mutator for row variable and sets its value to the passed newRow variable.
     * It sets the new row position of the organism
     *
     */
    public void setRow(int newRow) {

        row = newRow;

    }

    //Sets the new column position of Organism object
    /**
     * Defining mutator for col variable and sets its value to the passed newCol variable.
     * It sets the new column position of the organism
     */

    public void setCol(int newCol) {

        col = newCol;

    }


    //Accessors; returns the values of the private variables

    //Accesses time step variable
    /**
     * Defining Accessor for timeStep. This method is used to access timeStep of Organism
     *
     */
    public int getTimeStep() {

        return timeStep;

    }

    //Accesses row position
    /**
     * Defining the accessor for row variable. This method returns the current row position of the organism
     *
     */
    public int getRow() {

        return row;

    }

    //Accesses column position

    /**
     *
     * Defining the accessor for col variable. This method returns the current column position of the organism
     */
    public int getCol() {

        return col;

    }

    //Accesses the board of all Organism objects
   
    /**
     *
     * Defining the accesor for the board and returns the current board of organisms
     */
    public Organism[][] getBoard() {

        return board;

    }

    //Accesses whether the Organism can move or not
    /**
     *
     * Accessor for the variable canMove and returns that whether organism can move or not
     */
    public boolean canMove() {

        return canMove;

    }


    //Abstraction for Move and Breed Methods; as abstract, they must be overwritten in Ant and Doodlebug class
   
    /***
     * Below are the two abstract methods whose implementation will be provided in the classes which extends this Organism Class.
     * The class which will extend the Organism class has to provide the implementation of below two methods otherwise that class will also become
     * the abstract class.
     *
     */
   
    public abstract void move();

    public abstract void breed();

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote