From 3a9c2cda7d40d61499a068bd6594e578f346816f Mon Sep 17 00:00:00 2001 From: Julia Zhong Guo Date: Tue, 3 Dec 2024 21:45:30 -0500 Subject: [PATCH] fix: no combobox value read aloud Fix related interactor and test file --- .../usecase/readhand/ReadHandInteractor.java | 13 +++++-- .../readhand/ReadHandInteractorTest.java | 34 ++++++++++++++----- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/src/main/java/usecase/readhand/ReadHandInteractor.java b/src/main/java/usecase/readhand/ReadHandInteractor.java index 69fb991..fe08ce6 100644 --- a/src/main/java/usecase/readhand/ReadHandInteractor.java +++ b/src/main/java/usecase/readhand/ReadHandInteractor.java @@ -61,7 +61,6 @@ public void execute(ReadHandInputData inputData) { * @return a string describing the player's hand, dora, uradora, and attributes */ private String getHandInfo(String playerName, String[] attributeNames) { - // TODO: read more than just Head List hand = dataAccessObj.getPlayer(playerName).getHand(); StringBuilder handInfo = new StringBuilder(); @@ -109,7 +108,17 @@ private String getHandInfo(String playerName, String[] attributeNames) { } handInfo.append("That's all tiles."); - // 4. Create string that describes the player's attributes. + // 4. Create string that describes the player's attributes (comboboxes). + String winType = dataAccessObj.getPlayer(playerName).getWinType(); + handInfo.append("You won by ").append(winType).append(". "); + String seatWind = dataAccessObj.getPlayer(playerName).getSeatWind(); + handInfo.append("Your seat wind is ").append(seatWind).append(". "); + String roundWind = dataAccessObj.getPlayer(playerName).getRoundWind(); + handInfo.append("The round wind is ").append(roundWind).append(". "); + int numAkaDora = dataAccessObj.getPlayer(playerName).getNumAkaDora(); + handInfo.append("You have ").append(numAkaDora).append(" red dora. "); + + // 4. Create string that describes the player's attributes (checkboxes). // Get whether all attributes are false. Boolean[] attributes = dataAccessObj.getPlayer(playerName).getAttributes(); boolean allFalse = false; diff --git a/src/test/java/unit/usecase/readhand/ReadHandInteractorTest.java b/src/test/java/unit/usecase/readhand/ReadHandInteractorTest.java index 62f74dc..96deba5 100644 --- a/src/test/java/unit/usecase/readhand/ReadHandInteractorTest.java +++ b/src/test/java/unit/usecase/readhand/ReadHandInteractorTest.java @@ -58,9 +58,13 @@ void setup() { void testHandEmptyAllFalse() { DAO.savePlayer(player); interactor.execute(new ReadHandInputData(name, attrib)); - final String expected = "Your hand is empty." - + "There are no dora tiles.There are no uradora tiles." - + "That's all tiles.You have no special attributes."; + final String expected = "Your hand is empty. " + + "There are no dora tiles.There are no uradora tiles.That's all tiles." + + "You won by Tsumo. " + + "Your seat wind is East. " + + "The round wind is East. " + + "You have 0 red dora. " + + "You have no special attributes."; Assertions.assertEquals(expected, presenter.getMessage()); } @@ -74,9 +78,13 @@ void testHandEmpty() { player.setAttributes(newAttrib); DAO.savePlayer(player); interactor.execute(new ReadHandInputData(name, attrib)); - final String expected = "Your hand is empty." - + "There are no dora tiles.There are no uradora tiles." - + "That's all tiles.You have the following special attributes: Riichi. Finish. "; + final String expected = "Your hand is empty. " + + "There are no dora tiles.There are no uradora tiles.That's all tiles." + + "You won by Tsumo. " + + "Your seat wind is East. " + + "The round wind is East. " + + "You have 0 red dora. " + + "You have the following special attributes: Riichi. Finish. "; Assertions.assertEquals(expected, presenter.getMessage()); } @@ -86,9 +94,13 @@ void testHandNonEmptyAllFalse() { player.setHand(hand); DAO.savePlayer(player); interactor.execute(new ReadHandInputData(name, attrib)); - final String expected = "Your hand includes 1 Man." - + "There are no dora tiles.There are no uradora tiles." - + "That's all tiles.You have no special attributes."; + final String expected = "Your hand includes 1 Man. " + + "There are no dora tiles.There are no uradora tiles.That's all tiles." + + "You won by Tsumo. " + + "Your seat wind is East. " + + "The round wind is East. " + + "You have 0 red dora. " + + "You have no special attributes."; Assertions.assertEquals(expected, presenter.getMessage()); } @@ -110,6 +122,10 @@ void testHandNonEmpty() { interactor.execute(new ReadHandInputData(name, attrib)); final String expected = "Your hand includes 2 Man. The dora tiles are 2 Man. " + "The uradora tiles are 2 Man. That's all tiles." + + "You won by Tsumo. " + + "Your seat wind is East. " + + "The round wind is East. " + + "You have 0 red dora. " + "You have the following special attributes: Riichi, Double Riichi. Finish. "; Assertions.assertEquals(expected, presenter.getMessage()); }