-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameApplication.java
57 lines (41 loc) · 1.28 KB
/
GameApplication.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
package cardsgame;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class GameApplication {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
//takes the no of player from user
System.out.println("how many players you want ? ");
int noOfPlayers = scanner.nextInt();
Player player[] = new Player[noOfPlayers];
for (int i = 0; i < noOfPlayers; i++) {
System.out.println("enter player name");
player[i] = new Player(scanner.next());
}
Deck d = new Deck();
// cards will be filled
d.fillCard();
//displays the cards before shuffling
System.out.println(d.deck);
//get the list of shuffled cards
ArrayList<Card> shuffleCards = d.shuffle();
//ArrayList<Card> shuffleCards = d.deck;
System.out.println(d.deck);
//Distribute 3 cards to each player
int kcnt = 0;
for (int k = 0; k < player.length; k++) {
int cnt = 0;
for (int tcnt = 0; cnt < 3; tcnt++) {
player[k].inHandCard[tcnt] = shuffleCards.get(kcnt);
cnt++;
kcnt++;
}
}
// for (int i = 0; i < player.length; i++) {
// System.out.println(player[i].playerName);
// player[i].showInhandCard();
// }
new DecideWinner().checkWinner(player);
}
}