Skip to content

Commit e482230

Browse files
Merge pull request #66 from ThePriyanshuBurman/main1
closed input scanner and adding one comment
2 parents a76a73b + ba3eb87 commit e482230

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Number_Gusses.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ public Game() {
2020
Random rand=new Random();
2121
Computer_input = rand.nextInt(100);
2222
}
23+
//method for taking input from user
2324
public void takeUserInput(){
2425
Scanner input=new Scanner(System.in);
2526
System.out.println("Enter the Number That you want to guess it :");
2627
User_input=input.nextInt();
28+
input.close(); //input closed
2729
}
2830
boolean isCorrectNumber(){
2931
if(User_input==Computer_input){
@@ -42,8 +44,8 @@ else if (User_input>Computer_input){
4244
public class Number_Gusses {
4345
public static void main(String[] args) {
4446
Game g=new Game();
45-
boolean b=false;
46-
while(!b){
47+
boolean b=false;
48+
while(!b){
4749
g.takeUserInput();
4850
b= g.isCorrectNumber();
4951
System.out.println(b);

0 commit comments

Comments
 (0)