-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathPlayer.java
More file actions
87 lines (62 loc) · 1.47 KB
/
Player.java
File metadata and controls
87 lines (62 loc) · 1.47 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import java.util.ArrayList;
import java.util.List;
/** This is the player class **/
public class Player {
public String name;
public int money = 100;
public Item[] inventory = new Item[10];
public Room myloc;
public Boolean out = false;
private List<Item> itemlist = new ArrayList<Item>();
public int Spentmoney = 0;
public void setname(String d){
name = d;
}
public String getname(){
return name;
}
public Boolean getout(){
return out;
}
public void setLoc(Room r){myloc = r;}
public void go(int direction, Player p){
myloc.exit(direction,p);
}
public void setEnt(Room r){
myloc = r;
}
public Room getLoc(){return myloc;}
public void Additem(Item i) {
itemlist.add(i);
}
public void listitems() {
String Text = "You currently have: ";
for (int i = 0; i < itemlist.size(); i++){
Text = Text + itemlist.get(i).getname() + ", ";
}
System.out.printf("%s\n", Text);
}
public void removeitem(String a) {
for (int i = 0; i < itemlist.size(); i++){
if (itemlist.get(i).getname().contains(a)){
int x = itemlist.get(i).getprice();
deductprice(x);
itemlist.remove(i);
} }
}
private void deductprice(int item) {
Spentmoney = Spentmoney - item;
}
public void setmoney(int m){
money = m;
}
public void setSpentmoney(int getamount) {
Spentmoney = Spentmoney + getamount;
}
public int getspent() {
return Spentmoney;
}
public int getmoney() {
return money;
}
}