-
Notifications
You must be signed in to change notification settings - Fork 0
/
Organism.java
60 lines (54 loc) · 2.21 KB
/
Organism.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import java.awt.*;
import java.awt.geom.*;
import java.util.ArrayList;
public interface Organism{
/* Organisms can be in various states represented by an integer
0. idle
1. eating
2. beingEaten
3. hunting
4. escaping */
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* ~~~~~~~~~~~~~ Control Methods: To be called by AnimalSimulator ~~~~~~~~~~~~~ */
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
public void updateHealthTime();
public void updateState(ArrayList<Organism> organisms);
public void move();
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* ~~~~~~~~~~~~~~ Utility methods - called by control methods ~~~~~~~~~~~~~~~~~ */
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
public Point2D.Double randomWalk();
public Point2D.Double hunt();
public Point2D.Double escape();
public ArrayList<Organism> getOrganismsWithinSightRadius(ArrayList<Organism> organisms);
public ArrayList<Organism> getNearbyPrey(ArrayList<Organism> organisms);
public Organism getClosestPrey(ArrayList<Organism> nearbyPrey);
public ArrayList<Organism> getNearbyPredators(ArrayList<Organism> nearbyOrganisms);
public Organism getClosestPredator(ArrayList<Organism> nearbyPrey);
public void eatPrey();
public boolean isPointWithinBoundary(Point2D.Double point);
public double generateRandomInitialHealth();
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* ~~~~~~~~~~ Get and Set (These should be the same for all organisms) ~~~~~~~~ */
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
// Get
public int getID();
public String getType();
public int getX();
public int getY();
public Point2D.Double getXY();
public double getHealth();
public double getMaxHealth();
public int getSightRadius();
public int getState();
public boolean isGivingBirth();
public int getNumBabiesProduced();
// Set
public void setX(int x);
public void setY(int y);
public void setXY(Point2D.Double point);
public void setTargetLocation(Point2D.Double point);
public void setHealth(double newHealth);
// To String
public String toString();
}