From a20de274cdf86d16896d834632445efef614040e Mon Sep 17 00:00:00 2001 From: Ali Abbasi Date: Sun, 27 Jun 2021 00:24:36 +0430 Subject: [PATCH] deck remove test1 --- src/main/java/controller/DeckController.java | 2 +- src/main/java/model/Deck.java | 3 +-- src/test/java/controller/DeckControllerTest.java | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/controller/DeckController.java b/src/main/java/controller/DeckController.java index d0b4111..d2dea3b 100644 --- a/src/main/java/controller/DeckController.java +++ b/src/main/java/controller/DeckController.java @@ -126,7 +126,7 @@ public void removeCard(String userInput) { ApplicationManger.getLoggedInUser().getUserData().save(); } } else { - if (Deck.isThereThisCardInMainDeckOfThisDeck(removeCardCommand.getField("card"), removeCardCommand.getField("deck"))) { + if (!Deck.isThereThisCardInMainDeckOfThisDeck(removeCardCommand.getField("card"), removeCardCommand.getField("deck"))) { System.out.println("card with name " + removeCardCommand.getField("card") + " does not exist in main deck"); } else { System.out.println("card removed form deck successfully"); diff --git a/src/main/java/model/Deck.java b/src/main/java/model/Deck.java index 08f0f72..65f02c1 100644 --- a/src/main/java/model/Deck.java +++ b/src/main/java/model/Deck.java @@ -122,9 +122,8 @@ public static boolean isThereThisCardInMainDeckOfThisDeck(String nameOfCard, Str else return deck.mainDeck.contains(Card.getCardIdByName(nameOfCard)); } catch (Exception e){ - e.printStackTrace(); + return false; } - return false; } public static void removeCardFromDeck(String nameOfCard, String nameOfDeck, String mainOrSide) { diff --git a/src/test/java/controller/DeckControllerTest.java b/src/test/java/controller/DeckControllerTest.java index 5b86020..022455f 100644 --- a/src/test/java/controller/DeckControllerTest.java +++ b/src/test/java/controller/DeckControllerTest.java @@ -144,12 +144,12 @@ void removeCard() throws ParseCommandException { assertEquals(output, outputStreamCaptor.toString()); outputStreamCaptor.reset(); input = "--card Name --deck first"; - output = "you bought Monster Reborn successfully." + System.lineSeparator() + "card added to deck successfully" + System.lineSeparator() + "card with name cardName does not exist in main deck" + System.lineSeparator(); + output = "card with name Name does not exist in main deck" + System.lineSeparator(); deckController.removeCard(input); assertEquals(output, outputStreamCaptor.toString()); outputStreamCaptor.reset(); input = "--card Monster Reborn --deck first"; - output = "you bought Monster Reborn successfully." + System.lineSeparator() + "card added to deck successfully" + System.lineSeparator() + "card removed form deck successfully" + System.lineSeparator(); + output = "card removed form deck successfully" + System.lineSeparator(); deckController.removeCard(input); assertEquals(output, outputStreamCaptor.toString());