diff --git a/src/main/java/javacake/ui/MainWindow.java b/src/main/java/javacake/ui/MainWindow.java index 32a16d7791..b1b1324103 100644 --- a/src/main/java/javacake/ui/MainWindow.java +++ b/src/main/java/javacake/ui/MainWindow.java @@ -163,7 +163,7 @@ private void handleUserInput() { if (inputDivider.length == 0) { throw new CakeException("OOPS!!! I'm sorry, but I don't know what that means."); } - if ("exit".equals(input)) { + if ("exit".equals(input) && !isWritingNote) { //must be "exit" exactly, else wont exe handleExit(); } else if (isQuiz) { diff --git a/src/test/java/QuestionTest.java b/src/test/java/QuestionTest.java index bef39980c2..64e79a2411 100644 --- a/src/test/java/QuestionTest.java +++ b/src/test/java/QuestionTest.java @@ -2,7 +2,11 @@ import javacake.quiz.Question; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + public class QuestionTest { Question dummyQuestion1 = new Question("abc", "3", 5); @@ -20,10 +24,8 @@ public void inputValidationNegativeTest() throws CakeException { @Test public void inputValidationNotInRangeTest() { - Exception e1 = assertThrows(CakeException.class, - ()-> dummyQuestion1.isAnswerCorrect("0")); - assertEquals(e1.getMessage(), - "[!] Please enter option number between 1 and 5! [!]\n"); - assertThrows(CakeException.class, ()-> dummyQuestion1.isAnswerCorrect("6")); + Exception e1 = assertThrows(CakeException.class, () -> dummyQuestion1.isAnswerCorrect("0")); + assertEquals(e1.getMessage(), "[!] Please enter option number between 1 and 5! [!]\n"); + assertThrows(CakeException.class, () -> dummyQuestion1.isAnswerCorrect("6")); } } diff --git a/src/test/java/junittesting/quiztest/ReviewSessionTest.java b/src/test/java/junittesting/quiztest/ReviewSessionTest.java index 1a2e40af3d..27965e7a1d 100644 --- a/src/test/java/junittesting/quiztest/ReviewSessionTest.java +++ b/src/test/java/junittesting/quiztest/ReviewSessionTest.java @@ -59,13 +59,13 @@ void parseInputTest() throws CakeException { assertTrue(e1.getMessage().contains("You can't use that command here")); // negative test: out of bounds of number of questions - Exception e2 = assertThrows(CakeException.class, - () -> reviewSession.parseInput(0, String.valueOf(MAX_QUESTIONS + 1))); + Exception e2 = assertThrows(CakeException.class, () -> reviewSession.parseInput( + 0, String.valueOf(MAX_QUESTIONS + 1))); assertTrue(e2.getMessage().contains("That question number is out of range! Try again.")); // negative test: int overflow input - Exception e3 = assertThrows(CakeException.class, - () -> reviewSession.parseInput(0, "2147483700")); + Exception e3 = assertThrows(CakeException.class, () -> reviewSession.parseInput( + 0, "2147483700")); assertTrue(e3.getMessage().contains("number is out of range!")); // positive test: back