-
Notifications
You must be signed in to change notification settings - Fork 513
Expand file tree
/
Copy pathMain.java
More file actions
42 lines (39 loc) · 1.53 KB
/
Copy pathMain.java
File metadata and controls
42 lines (39 loc) · 1.53 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
package snakesAndLadders;
import snakesAndLadders.game.Game;
import snakesAndLadders.model.Player;
import java.util.*;
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Please enter number of snakes: ");
int snakeCount = sc.nextInt();
Map<Integer, Integer> snakes = new HashMap<>();
for(int i = 0; i < snakeCount; i++){
System.out.println("Enter snake head and tail: ");
int head = sc.nextInt();
int tail = sc.nextInt();
snakes.put(head, tail);
}
System.out.println("Please enter number of ladders: ");
int ladderCount = sc.nextInt();
Map<Integer, Integer> ladders = new HashMap<>();
for(int i = 0; i < ladderCount; i++){
System.out.println("Enter ladder base and top: ");
int base = sc.nextInt();
int top = sc.nextInt();
ladders.put(base, top);
}
System.out.println("Please enter number of players: ");
int playerCount = sc.nextInt();
List<Player> players = new ArrayList<>();
for(int i = 0; i < playerCount; i++){
System.out.println("Enter player name: ");
String name = sc.next();
players.add(new Player(name));
}
Game game = new Game(players, snakes, ladders);
game.start();
}
}