Skip to content

Commit

Permalink
Merge branch 'main' into doc/API-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavbeat03 authored Dec 6, 2023
2 parents 32e1237 + ad23ea1 commit 7575d49
Show file tree
Hide file tree
Showing 11 changed files with 726 additions and 392 deletions.
62 changes: 37 additions & 25 deletions src/main/java/team/rocket/Entities/AbstractAnimal.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,71 +4,83 @@
import team.rocket.Map;

/**
* @since 0.1.0
* An abstract class to define characteristics and behaviors for multiple types of animals.
*
* @version 0.6.0
* @since 0.1.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();

Expand All @@ -79,4 +91,4 @@ public void resetMove(){
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();

}
54 changes: 33 additions & 21 deletions src/main/java/team/rocket/Entities/AbstractPlant.java
Original file line number Diff line number Diff line change
@@ -1,57 +1,68 @@
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;
}

Expand All @@ -65,8 +76,9 @@ public void resetGrown(){
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

0 comments on commit 7575d49

Please sign in to comment.