Closing Scanner

master
sgoudham 4 years ago
parent dbc9e34839
commit 7358240d7e
No known key found for this signature in database
GPG Key ID: EF51A29A50FB754C

@ -7,15 +7,16 @@ public class CardMain {
Sevens sevens = new Sevens(); Sevens sevens = new Sevens();
sevens.shuffle(); sevens.shuffle();
int numOfPlayers = getNumOfPlayers(); Scanner in = new Scanner(System.in);
List<Player> allPlayers = sevens.dealCards(numOfPlayers); int numOfPlayers = getNumOfPlayers(in);
in.close();
List<Player> allPlayers = sevens.dealCards(numOfPlayers);
sevens.play(allPlayers, numOfPlayers); sevens.play(allPlayers, numOfPlayers);
} }
public static int getNumOfPlayers() { public static int getNumOfPlayers(Scanner in) {
Scanner in = new Scanner(System.in);
System.out.println("Please Enter The Number of Players!"); System.out.println("Please Enter The Number of Players!");
while (!in.hasNextInt()) { while (!in.hasNextInt()) {
in.nextLine(); in.nextLine();

Loading…
Cancel
Save