From 330cfe0a6fbd43d68af4af8f3b8d89187d94051b Mon Sep 17 00:00:00 2001 From: Kiran Date: Sun, 30 Apr 2017 18:30:33 +0100 Subject: [PATCH 1/2] fdhfhg --- .idea/kotlinc.xml | 7 +++++++ .idea/misc.xml | 15 +-------------- .idea/modules/flashy_main.iml | 2 +- .idea/modules/flashy_test.iml | 2 +- .../flashy/controllers/IndexController.java | 6 ++++-- src/test/resources.properties | 0 6 files changed, 14 insertions(+), 18 deletions(-) create mode 100644 .idea/kotlinc.xml create mode 100644 src/test/resources.properties diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..1c24f9a --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 164b970..d5d79e0 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,19 +1,6 @@ - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/.idea/modules/flashy_main.iml b/.idea/modules/flashy_main.iml index 3d7e5d1..65aba19 100644 --- a/.idea/modules/flashy_main.iml +++ b/.idea/modules/flashy_main.iml @@ -1,6 +1,6 @@ - + diff --git a/.idea/modules/flashy_test.iml b/.idea/modules/flashy_test.iml index 3c5b73a..6e4737e 100644 --- a/.idea/modules/flashy_test.iml +++ b/.idea/modules/flashy_test.iml @@ -1,6 +1,6 @@ - + diff --git a/src/main/java/com/teamtreehouse/flashy/controllers/IndexController.java b/src/main/java/com/teamtreehouse/flashy/controllers/IndexController.java index f127754..375e2c2 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()); @@ -35,8 +36,9 @@ public String index(Model model) { ctaBuilder.append(totalCount); ctaBuilder.append(" more"); model.addAttribute("cta", ctaBuilder.toString()); - model.addAttribute("flashCardCount", totalCount); + model.addAttribute("flash CardCount", totalCount); return "index"; } } +¢ \ No newline at end of file diff --git a/src/test/resources.properties b/src/test/resources.properties new file mode 100644 index 0000000..e69de29 From 6d0ed85c24c901793da545c8ce5e4aa757d08ba8 Mon Sep 17 00:00:00 2001 From: Kiran Date: Sun, 30 Apr 2017 18:56:27 +0100 Subject: [PATCH 2/2] fdhfhg --- .../flashy/controllers/IndexController.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/teamtreehouse/flashy/controllers/IndexController.java b/src/main/java/com/teamtreehouse/flashy/controllers/IndexController.java index 375e2c2..b0570ce 100644 --- a/src/main/java/com/teamtreehouse/flashy/controllers/IndexController.java +++ b/src/main/java/com/teamtreehouse/flashy/controllers/IndexController.java @@ -31,14 +31,16 @@ 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("flash CardCount", totalCount); return "index"; } -} -¢ \ No newline at end of file +} \ No newline at end of file