-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreature.java
More file actions
36 lines (31 loc) · 1.14 KB
/
Creature.java
File metadata and controls
36 lines (31 loc) · 1.14 KB
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
//Xinyu Xiong
import java.io.Serializable;
public class Creature implements Serializable {
private int age; //maximum age is 40
private int energy; //maximum energy is 100
private int num; //num means different type of creature. 1 means plant, 2 means herbivore and 3 means carnivore
private int x; //x coordinate
private int y; //y coordinate
private int moved;
private int ate;
public Creature(int num) {
this.num=num;
this.age=0;
if(num!=1) {
this.energy=(int) (51*Math.random()+50);
// energy ranges from 50 to 100
this.moved=0;
this.ate=0;
}
}
public int getAge() {return this.age;}
public void setAge(int age) {this.age=age;}
public int getEnergy() {return this.energy;}
public void setEnergy(int energy) {this.energy=energy;}
public int getNum() {return num;}
public void setNum(int num) {this.num=num;}
public void setMoved(int status) {this.moved=status;}
public int getMoved() {return moved;}
public void setAte(int status) {this.ate=status;}
public int getAte() {return ate;}
}