Skip to content
Snippets Groups Projects
Commit 90fa0ae1 authored by Yiya Zhuang's avatar Yiya Zhuang
Browse files

The entity classes are completed

The classes that represent entities (such as Player, Zombie, Sandwich, Treasure, ...) are completed. Now the ShadowTreasure is the only class that need to complete.
parent 213d508f
No related branches found
No related tags found
No related merge requests found
import java.util.ArrayList;
public class Player extends Entity implements Movable{ public class Player extends Entity implements Movable{
private Energy energy; private Energy energy;
...@@ -14,9 +16,9 @@ public class Player extends Entity implements Movable{ ...@@ -14,9 +16,9 @@ public class Player extends Entity implements Movable{
this.energy.add(amount); this.energy.add(amount);
} }
protected void eat(Sandwich sandwich) { protected void eat(ArrayList<Sandwich> sandwiches, int index) {
this.updateEnergy(+5); this.updateEnergy(+5);
sandwich.eaten(); sandwiches.get(index).eaten();
} }
@Override @Override
......
public class Zombie extends Entity{ public class Zombie extends Entity{
private boolean dead = false;
protected Zombie(String filename, double x, double y) { protected Zombie(String filename, double x, double y) {
super(filename, x, y); super(filename, x, y);
} }
protected void killed() { protected boolean isDead() {
return dead;
}
protected void killed() {
dead = true;
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment