From 0f2846d275983e04dc9c2732646493194cee26dc Mon Sep 17 00:00:00 2001 From: smfulford Date: Wed, 26 Jun 2019 12:03:54 -0400 Subject: [PATCH] Addresses issue #6 by changing the number of examples to 3 --- .idea/codeStyles/codeStyleConfig.xml | 5 ++ .idea/modules.xml | 10 --- .idea/modules/flashy.iml | 12 --- .idea/modules/flashy_main.iml | 79 ------------------ .idea/modules/flashy_test.iml | 83 ------------------- .../flashy/controllers/IndexController.java | 11 ++- 6 files changed, 12 insertions(+), 188 deletions(-) create mode 100644 .idea/codeStyles/codeStyleConfig.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/modules/flashy.iml delete mode 100644 .idea/modules/flashy_main.iml delete mode 100644 .idea/modules/flashy_test.iml diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..a55e7a1 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 0b6b7df..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/flashy.iml b/.idea/modules/flashy.iml deleted file mode 100644 index 2f6b1cf..0000000 --- a/.idea/modules/flashy.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/flashy_main.iml b/.idea/modules/flashy_main.iml deleted file mode 100644 index 3d7e5d1..0000000 --- a/.idea/modules/flashy_main.iml +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/flashy_test.iml b/.idea/modules/flashy_test.iml deleted file mode 100644 index 3c5b73a..0000000 --- a/.idea/modules/flashy_test.iml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/java/com/teamtreehouse/flashy/controllers/IndexController.java b/src/main/java/com/teamtreehouse/flashy/controllers/IndexController.java index f127754..53b1886 100644 --- a/src/main/java/com/teamtreehouse/flashy/controllers/IndexController.java +++ b/src/main/java/com/teamtreehouse/flashy/controllers/IndexController.java @@ -12,6 +12,7 @@ @Controller public class IndexController { + public static final int AMOUNT_TO_SHOW = 3; private FlashCardService flashCardService; @Autowired @@ -22,7 +23,7 @@ public void setFlashCardService(FlashCardService flashCardService) { @RequestMapping("/") public String index(Model model) { StringBuilder ctaBuilder = new StringBuilder(); - List cards = flashCardService.getRandomFlashCards(5); + List cards = flashCardService.getRandomFlashCards(AMOUNT_TO_SHOW); ctaBuilder.append("Refresh your memory about "); for (FlashCard card : cards) { ctaBuilder.append(card.getTerm()); @@ -30,10 +31,12 @@ public String index(Model model) { ctaBuilder.append(", "); } } - ctaBuilder.append(" and "); Long totalCount = flashCardService.getCurrentCount(); - ctaBuilder.append(totalCount); - ctaBuilder.append(" more"); + if (totalCount > AMOUNT_TO_SHOW){ + ctaBuilder.append(" and "); + ctaBuilder.append(totalCount - AMOUNT_TO_SHOW); + ctaBuilder.append(" more"); + } model.addAttribute("cta", ctaBuilder.toString()); model.addAttribute("flashCardCount", totalCount); return "index";