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.util.HashSet;
21 import java.util.Iterator;
22 import java.util.Set;
23
24
25 /***
26 * @author matthias.vonrohr
27 *
28 * To change the template for this generated type comment go to
29 * Window>Preferences>Java>Code Generation>Code and Comments
30 */
31 public class Team {
32 private Set players;
33 private byte teamID;
34
35 public Team(byte id) {
36 this.players = new HashSet();
37 this.teamID = id;
38 }
39
40 public void addPlayer(Player p) {
41 players.add(p);
42 }
43
44 public void removePlayer(Player p) {
45 players.remove(p);
46 }
47
48 public byte getID() {
49 return this.teamID;
50 }
51 public int hashCode() {
52 return this.teamID;
53 }
54
55 public String toString() {
56 StringBuffer result = new StringBuffer();
57 Iterator i = players.iterator();
58 result.append("Team (ID " + this.teamID + "): | ");
59 while(i.hasNext()) {
60 Player p = (Player) i.next();
61 result.append(p.getName() + " | ");
62 }
63 return result.toString();
64 }
65
66 }