-
Notifications
You must be signed in to change notification settings - Fork 513
Expand file tree
/
Copy pathGame.java
More file actions
55 lines (45 loc) · 1.25 KB
/
Copy pathGame.java
File metadata and controls
55 lines (45 loc) · 1.25 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
import java.util.ArrayList;
import java.util.List;
public class Game {
private final int dices;
private final Board board;
private final List<Player> playersList;
private final Dice dice;
private static int snakes;
private static int ladders;
private Game(int rows,int columns,int dices) {
playersList = new ArrayList<>();
board = new Board(rows,columns);
this.dices = dices;
dice = new Dice(1,6);
}
private static Game game;
public static Game getInstance(int rows,int columns,int dices) {
if(game == null)
game = new Game(rows,columns,dices);
return game;
}
public static int getSnakes() {
return snakes;
}
public static void setSnakes(int snakes) {
Game.snakes = snakes;
}
public static int getLadders() {
return ladders;
}
public static void setLadders(int ladders) {
Game.ladders = ladders;
}
public List<Player> getPlayersList() {
return playersList;
}
public Board getBoard() {
return board;
}
public void start() {
System.out.println("\n----------Starting game---------------\n");
board.display();
GameUtil.start(playersList,dices,dice,board);
}
}