User can now enter in the number of players

master
sgoudham 4 years ago
parent c30a8369f1
commit 5a01203177
No known key found for this signature in database
GPG Key ID: EF51A29A50FB754C

@ -1,12 +1,26 @@
import java.util.List; import java.util.List;
import java.util.Scanner;
public class CardMain { public class CardMain {
public static void main(String[] args) { public static void main(String[] args) {
/* Play Sevens */ /* Play Sevens */
Sevens sevens = new Sevens(); Sevens sevens = new Sevens();
sevens.shuffle(); sevens.shuffle();
List<Player> allPlayers = sevens.dealCards(4);
sevens.play(allPlayers, 4);
int numOfPlayers = getNumOfPlayers();
List<Player> allPlayers = sevens.dealCards(numOfPlayers);
sevens.play(allPlayers, numOfPlayers);
}
public static int getNumOfPlayers() {
Scanner in = new Scanner(System.in);
System.out.println("Please Enter The Number of Players!");
while (!in.hasNextInt()) {
in.nextLine();
System.out.println("Invalid Amount of Players! Try again!");
}
return in.nextInt();
} }
} }

Loading…
Cancel
Save