Skip to content

Commit

Permalink
Merge pull request #172 from samuelory/Samuel-v2.6
Browse files Browse the repository at this point in the history
Caught NoSuchElementException and IllegalStateException
  • Loading branch information
JeffinsonDarmawan committed Apr 14, 2024
2 parents a350bac + 3fc60d5 commit 37be645
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/java/florizz/core/Ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import java.util.ArrayList;
import java.util.HashMap;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Ui {
Expand Down Expand Up @@ -42,7 +43,11 @@ public static void printBreakLine(){
* @return Returns the user input as one String.
*/
public String getInput(){
return inputScanner.nextLine();
try{
return inputScanner.nextLine();
} catch(NoSuchElementException | IllegalStateException error){
return "bye";
}
}

/**
Expand Down

0 comments on commit 37be645

Please sign in to comment.