1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package ch.twiddlefinger.inet.rewinder.model.entities;
19
20 import java.awt.Color;
21
22 /***
23 * @author matthias.vonrohr To change the template for this generated type
24 * comment go to Window>Preferences>Java>Code
25 * Generation>Code and Comments
26 */
27 public class Player {
28 private Color color;
29 private String name;
30 private Race race;
31 private int playerID;
32
33 public Player(String name, Color color, Race race) {
34 if ((color == null) || (name == null) || (race == null)) {
35 throw new IllegalArgumentException("Constructor Player: some parameters are null");
36 }
37
38 this.color = color;
39 this.race = race;
40 this.name = name;
41 }
42
43 public Player(int playerID, String name, Race race) {
44 this(name, Color.BLUE, race);
45 this.playerID = playerID;
46 }
47
48 /***
49 * Returns the player's color
50 *
51 * @return
52 */
53 public Color getColor() {
54 return color;
55 }
56
57 /***
58 * Returns the player's name
59 *
60 * @return
61 */
62 public String getName() {
63 return name;
64 }
65
66 /***
67 * Returns the players race
68 *
69 * @return
70 */
71 public Race getRace() {
72 return race;
73 }
74
75 public boolean equals(Object o) {
76 if (o instanceof Player) {
77 return ((Player) o).getName().equals(this.name);
78 } else {
79 return false;
80 }
81 }
82
83 /***
84 * @return
85 */
86 public int getPlayerID() {
87 return playerID;
88 }
89
90 /***
91 * @param i
92 */
93 public void setPlayerID(int i) {
94 this.playerID = i;
95 }
96
97 public String toString() {
98 StringBuffer result = new StringBuffer();
99 result.append(
100 "[ ("
101 + this.playerID
102 + ") "
103 + this.name
104 + ", "
105 + this.color
106 + ", "
107 + this.race
108 + " ]");
109
110 return result.toString();
111 }
112
113 public void setColor(Color color) {
114 this.color = color;
115 }
116 }