Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation additions #134

Merged
merged 16 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 42 additions & 25 deletions src/main/java/team/rocket/Entities/AbstractAnimal.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,75 +4,92 @@
import team.rocket.Map;

/**
* An abstract class to define characteristics and behaviors for multiple types of animals.
*
* @version 0.6.0
* @since 0.1.0
* @version 0.4.0
*/
public abstract class AbstractAnimal extends AbstractOrganism {
private static char icon;
private static int count;
private boolean hasMoved;

private static int vision;

private int hunger;
private static char icon; // The icon representation of this type of animal
private static int count; // The number of animals
private boolean hasMoved; // True if this animal has moved this time step, false otherwise
private static int vision; // The number of tiles away that an animal can see
private int hunger; // The hunger value for this animal

/**
* @return Animal's icon as a character
* Returns the icon representation of this type of animal.
*
* @return this type of animal's icon as a character
*/
public static char toIcon(){
public static char toIcon() {
return icon;
}

/**
* @return current Animal count
* Returns the total number of existing animals.
*
* @return the current animal count
*/
public static int getCount(){
public static int getCount() {
return count;
}

/**
* Resets hasMoved to false, meant to be used to reset movement each day
* Resets hasMoved to false, meant to be used to reset movement each day.
*/
public void resetMove(){
public void resetMove() {
this.hasMoved = false;
}

/**
* Creates new Animal
* Creates a new animal.
*/
public abstract void reproduce();

/**
* @return true if hunger is <= zero
* Returns true if this animal is starving, false otherwise.
*
* @return true if this animal is starving, false otherwise
*/
public abstract boolean isStarving();

/**
* @return Animal's current hunger
* Returns this animal's hunger
*
* @return this animal's current hunger
*/
public abstract int getHunger();

/**
* Takes array of an Animal's neighbors, randomly chooses an available space, and returns corresponding direction
* Takes array of an animal's neighbors, randomly chooses an available space, and returns corresponding direction.
*
* @param neighbors array of animals in adjacent tiles, 0-3 representing UP, DOWN, LEFT, or RIGHT respectively
* @return randomly determined direction based on available spaces
* @return randomly determined direction based on available spaces
*/
public abstract Direction availableMovementSpace(AbstractOrganism[] neighbors);

/**
* Moves Animal in grid based on current position, available movement space, and past movement
* @param map map of simulation
* @param y - y position of Rabbit in grid
* @param x - x position of Rabbit in grid
* Moves this animal in grid based on current position, available movement space, and past movement.
*
* @param map map of simulation
* @param y y position of Rabbit in grid
* @param x x position of Rabbit in grid
*/
public abstract void move(Map map, int y, int x);

/**
* @return nutrition
* Returns this animal's nutrition.
*
* @return nutrition
*/
public abstract int getNutrition();

/**
* Returns the vision for this type of animal.
*
* @return this type of animal's vision
*/
public static int getVision() {
return vision;
}
}
}
42 changes: 26 additions & 16 deletions src/main/java/team/rocket/Entities/AbstractOrganism.java
Original file line number Diff line number Diff line change
@@ -1,55 +1,65 @@
package team.rocket.Entities;

/**
* An abstract class to define characteristics and behaviors for multiple types of organisms.
*
* @version 0.6.0
* @since 0.1.0
* @version 0.4.0
*/
public abstract class AbstractOrganism {
private static char icon;
private static int count;
private static int nutrition;
private static char icon; // The icon representation of this type of organism
private static int count; // The total number of existing organisms
private static int nutrition; // The hunger value that this type of organism rewards when eaten

/**
* @return Organism's icon as a character
* Returns the icon representation for this type of organism.
*
* @return this type of organism's icon as a character
*/
public static char toIcon(){
public static char toIcon() {
return icon;
}

/**
* gets the icon from an instance
* @return the icon of the organism
* Gets the icon from an instance.
*
* @return the icon of the organism
*/
abstract public char instancedToIcon();

/**
* @return current Organism count
* Returns the total number of existing organisms
*
* @return current organism count
*/
public static int getCount(){
public static int getCount() {
return count;
}

/**
* Sets the count of animals
* Sets the count of organisms.
*
* @param i the number count is being set too
*/
public abstract void setCount(int i);


/**
* Needed for very specific instance with OrganismEnum so that the instance in the enum doesn't count towards the total number of Organisms
* Needed for very specific instance with OrganismEnum so that the instance in the enum doesn't count towards the
* total number of organisms.
*/
public abstract void reduceCount();

/**
* Takes the instance of an object and creates a brand new one and returns that new object
* @return a fresh new not-copied AbstractOrganism
* Takes the instance of an object and creates a brand new one and returns that new object.
*
* @return a fresh new not-copied abstract organism
*/
public abstract AbstractOrganism getNewObjectFromExistingObject();

/**
* Returns the hunger that this type of organism rewards when eaten
*
* @return nutrition
*/
public abstract int getNutrition();

}
58 changes: 35 additions & 23 deletions src/main/java/team/rocket/Entities/AbstractPlant.java
Original file line number Diff line number Diff line change
@@ -1,68 +1,80 @@
package team.rocket.Entities;

/**
* An abstract class to define characteristics and behaviors for multiple types of plants.
*
* @version 0.6.0
* @since 0.3.0
* @version 0.4.0
*/
public abstract class AbstractPlant extends AbstractOrganism{
private static char icon;
private static int count;
private boolean hasGrown;
private static int nutrition;

public abstract class AbstractPlant extends AbstractOrganism {
private static char icon; // The icon representation of this type of plant
private static int count; // The total number of existing plants
private boolean hasGrown; // True if this organism has grown today, false otherwise
private static int nutrition; // The hunger value that this type of plant rewards when eaten

/**
* @return Plant's icon as a character
* Returns an icon representation of this type of plant.
*
* @return this type of plant's icon as a character
*/
public static char toIcon(){
public static char toIcon() {
return icon;
}

/**
* gets the icon from an instance
* @return the icon of the organism
* Gets the icon from an instance.
*
* @return the icon of the organism
*/
public char instancedToIcon(){return icon;}
public char instancedToIcon() {
return icon;
}

/**
* @return current Plant count
* Returns the total number of existing plants.
*
* @return current plant count
*/
public static int getCount(){
return count;
}

/**
* Sets the count of Plants
* Sets the count of plants.
*
* @param i the number count is being set too
*/
public abstract void setCount(int i);

/**
* Needed for very specific instance with OrganismEnum so that the instance in the enum doesn't count towards the total number of Organisms
* Needed for very specific instance with OrganismEnum so that the instance in the enum doesn't count towards the
* total number of organisms.
*/
public abstract void reduceCount();

/**
* Takes the instance of an object and creates a brand new one and returns that new object
* @return a fresh new not-copied AbstractOrganism
* Takes the instance of an object and creates a brand new one and returns that new object.
*
* @return a fresh new not-copied AbstractOrganism
*/
public abstract AbstractOrganism getNewObjectFromExistingObject();

/**
* Resets hasGrown to false, meant to be used to reset growth each day
* Resets hasGrown to false, meant to be used to reset growth each day.
*/
public void resetGrown(){
public void resetGrown() {
this.hasGrown = false;
}

/**
* Creates new Organism
* Creates a new plant.
*/
public abstract void grow(AbstractOrganism grid[][], AbstractOrganism[] neighbors, int y, int x);
public abstract void grow(AbstractOrganism[][] grid, AbstractOrganism[] neighbors, int y, int x);

/**
* @return nutrition
* Returns this plant's nutrition.
*
* @return nutrition
*/
public abstract int getNutrition();

}
Loading