1: package siege.core;
2:
3: import java.util.Observable;
4:
5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17:
18: public class Player extends Observable implements Comparable
19: {
20: 21: 22:
23: private String name;
24:
25: 26: 27:
28: private String address;
29:
30: 31: 32:
33: private Score score;
34:
35: 36: 37: 38: 39:
40: private boolean isLocalPlayer = false;
41:
42: 43: 44: 45: 46:
47: private boolean isChallenger = false;
48:
49:
50: 51: 52:
53: public Player ()
54: {
55: super();
56: score = new Score(this);
57: }
58:
59: 60: 61: 62:
63: public Player (String name)
64: {
65: this();
66: this.name = name;
67: }
68:
69: 70: 71:
72: public String getName ()
73: {
74: return name;
75: }
76:
77: 78: 79: 80:
81: public void setName (String name)
82: {
83: this.name = name;
84: setChanged();
85: notifyObservers();
86: }
87:
88: 89: 90:
91: public String getAddress ()
92: {
93: return address;
94: }
95:
96: 97: 98: 99:
100: public void setAddress (String address)
101: {
102: this.address = address;
103: }
104:
105: 106: 107:
108: public Score getScore ()
109: {
110: return score;
111: }
112:
113: 114: 115:
116: public boolean isChallenger ()
117: {
118: return isChallenger;
119: }
120:
121: 122: 123:
124: public boolean isPartaker ()
125: {
126: return !isChallenger;
127: }
128:
129: 130: 131: 132: 133:
134: public void setChallenger (boolean status)
135: {
136: this.isChallenger = status;
137: }
138:
139: 140: 141:
142: public boolean isLocalPlayer ()
143: {
144: return isLocalPlayer;
145: }
146:
147: 148: 149:
150: public boolean isRemotePlayer ()
151: {
152: return !isLocalPlayer;
153: }
154:
155: 156: 157: 158: 159:
160: public void setLocalPlayer (boolean status)
161: {
162: if(status) {
163: isLocalPlayer = true;
164: } else {
165: isLocalPlayer = false;
166: }
167: setChanged();
168: notifyObservers();
169: }
170:
171: 172: 173:
174: public int compareTo(Object o)
175: {
176: return score.compareTo(((Player)o).score);
177: }
178: }