-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTree.java
More file actions
36 lines (30 loc) · 831 Bytes
/
Tree.java
File metadata and controls
36 lines (30 loc) · 831 Bytes
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
/**
* Write a description of class Tree here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Tree extends Block implements Interactable
{
private int height;
private AdventureWorld world;
public void interact(String cmd) {
world.setBlock(loc, new Ground(loc));
System.out.println("You cut down the tree and got " + (height*5) + " wood");
world.getPlayer().addToInventory(new Wood(height*5));
}
public boolean isInteractCmd(String cmd) {
return cmd.equalsIgnoreCase("chop tree");
}
public Tree(int x, int h, AdventureWorld wrld) {
super(x);
height = h;
world = wrld;
}
public String getName() {
return "Tree";
}
public boolean isHidden() {
return false;
}
}