From 7e6f4bd21f68a63dfad2c71f3393cf7521d92cf3 Mon Sep 17 00:00:00 2001 From: Yeo Zong Yao Date: Wed, 20 Mar 2024 04:57:38 +0800 Subject: [PATCH] checkstyle fix --- src/main/java/seedu/bookbuddy/BookBuddy.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/seedu/bookbuddy/BookBuddy.java b/src/main/java/seedu/bookbuddy/BookBuddy.java index c031fce6f4..db7ef8f3c4 100644 --- a/src/main/java/seedu/bookbuddy/BookBuddy.java +++ b/src/main/java/seedu/bookbuddy/BookBuddy.java @@ -1,5 +1,7 @@ package seedu.bookbuddy; +import exceptions.UnsupportedCommandException; + import java.util.Scanner; public class BookBuddy { @@ -19,8 +21,17 @@ public static void getUserInput(BookList books) { //noinspection InfiniteLoopStatement while (true) { - String userInput = input.nextLine(); - Parser.parseCommand(userInput, books); + String userInput = input.nextLine().trim(); + if (userInput.isEmpty()) { + // If the input is empty, do not call parseCommand and just prompt for input again. + continue; + } + + try { + Parser.parseCommand(userInput, books); + } catch (UnsupportedCommandException e) { + System.out.println(e.getMessage()); + } } }