-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.java
191 lines (152 loc) · 3.33 KB
/
Game.java
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
package Lab4;
public class Game extends Player{
private Player[] player;
private Map map;
public Game() {
player = new Player[10];
}
public Game(Player[] player, Map map) {
this.player = player;
this.map = map;
}
public Game(Game game) {
this.player = game.player;
for (int i = 0; i < player.length; i++) {
player[i] = new Player(player[i]);
}
this.map = game.map;
}
public static Game getInstance() {
return new Game();
}
public static Game getInstance(Player[] player, Map map) {
return new Game(player, map);
}
public static Game getInstance(Game game) {
return new Game(game);
}
public Player[] getPlayer() {
return this.player;
}
public Map getMap() {
return this.map;
}
public void setPlayer(Player[] player) {
this.player = player;
}
public void setMap(Map map) {
this.map = map;
}
}
/**
* This class implements all a player requires to play in this game.
*/
class Player{
String name;
Role role;
public Player() {
super();
name = "";
role = new Role();
}
public Player(String name, Role role) {
super();
this.name = name;
this.role = role;
}
public Player(Player player) {
super();
this.name = player.name;
this.role = player.role;
}
public static Player getInstance() {
return new Player();
}
public static Player getInstance(String name, Role role) {
return new Player(name, role);
}
public static Player getInstance(Player player) {
return new Player(player);
}
public String getName() {
return name;
}
public Role getRole() {
return role;
}
public void setName(String name) {
this.name = name;
}
public void setRole(Role role) {
this.role = role;
}
}
/**
* This class implements the areas in which players can play.
*/
class Map{
String theSkeld;
String miraHq;
String polus;
String airShip;
public Map() {
theSkeld = "";
miraHq = "";
polus = "";
airShip = "";
}
public Map(String theSkeld, String miraHq, String polus, String airShip) {
this.theSkeld = theSkeld;
this.miraHq = miraHq;
this.polus = polus;
this.airShip = airShip;
}
public static Map getInstance() {
return new Map();
}
public static Map getInstance(String theSkeld, String miraHq, String polus, String airShip) {
return new Map(theSkeld, miraHq, polus, airShip);
}
public Map(Map map) {
this.theSkeld = map.theSkeld;
this.miraHq = map.miraHq;
this.polus = map.polus;
this.airShip = map.airShip;
}
public static Map getInstance(Map map) {
return new Map(map);
}
}
/**
* This class presents the role of the players,
* which can be either imposter or crewmate.
* Imposter role, gets the value of 'i'and
* Cremate gets the value of 'c'
*/
class Role{
char role;
public Role() {
role = ' ';
}
public Role(char role) {
this.role = role;
}
public Role(Role role) {
this.role = role.role;
}
public static Role getInstance() {
return new Role();
}
public static Role getInstance(char role) {
return new Role(role);
}
public static Role getInstance(Role role) {
return new Role(role);
}
public char getRole() {
return role;
}
public void setRole(char role) {
this.role = role;
}
}