From 7358240d7e9c5d1ab2a11f0dfdff7f78486c82c1 Mon Sep 17 00:00:00 2001 From: sgoudham Date: Tue, 20 Oct 2020 09:16:24 +0100 Subject: [PATCH] Closing Scanner --- Personal/Cards/src/CardMain.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Personal/Cards/src/CardMain.java b/Personal/Cards/src/CardMain.java index b1d6ccc..a3f80c1 100644 --- a/Personal/Cards/src/CardMain.java +++ b/Personal/Cards/src/CardMain.java @@ -7,15 +7,16 @@ public class CardMain { Sevens sevens = new Sevens(); sevens.shuffle(); - int numOfPlayers = getNumOfPlayers(); - List allPlayers = sevens.dealCards(numOfPlayers); + Scanner in = new Scanner(System.in); + int numOfPlayers = getNumOfPlayers(in); + in.close(); + List allPlayers = sevens.dealCards(numOfPlayers); sevens.play(allPlayers, numOfPlayers); } - public static int getNumOfPlayers() { - Scanner in = new Scanner(System.in); + public static int getNumOfPlayers(Scanner in) { System.out.println("Please Enter The Number of Players!"); while (!in.hasNextInt()) { in.nextLine();