File tree 5 files changed +60
-4
lines changed
src/main/java/com/teamtreehouse/flashy/controllers
5 files changed +60
-4
lines changed Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <classpath >
3
+ <classpathentry kind =" src" path =" src/main/java" >
4
+ <attributes >
5
+ <attribute name =" FROM_GRADLE_MODEL" value =" true" />
6
+ </attributes >
7
+ </classpathentry >
8
+ <classpathentry kind =" src" path =" src/main/resources" >
9
+ <attributes >
10
+ <attribute name =" FROM_GRADLE_MODEL" value =" true" />
11
+ </attributes >
12
+ </classpathentry >
13
+ <classpathentry kind =" src" path =" src/test/java" />
14
+ <classpathentry kind =" con" path =" org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8" />
15
+ <classpathentry kind =" con" path =" org.eclipse.buildship.core.gradleclasspathcontainer" />
16
+ <classpathentry kind =" output" path =" bin" />
17
+ </classpath >
Original file line number Diff line number Diff line change 62
62
63
63
! gradle-wrapper.jar
64
64
65
+ /bin /
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <projectDescription >
3
+ <name >flashy</name >
4
+ <comment ></comment >
5
+ <projects >
6
+ </projects >
7
+ <buildSpec >
8
+ <buildCommand >
9
+ <name >org.eclipse.jdt.core.javabuilder</name >
10
+ <arguments >
11
+ </arguments >
12
+ </buildCommand >
13
+ <buildCommand >
14
+ <name >org.eclipse.buildship.core.gradleprojectbuilder</name >
15
+ <arguments >
16
+ </arguments >
17
+ </buildCommand >
18
+ </buildSpec >
19
+ <natures >
20
+ <nature >org.eclipse.buildship.core.gradleprojectnature</nature >
21
+ <nature >org.eclipse.jdt.core.javanature</nature >
22
+ </natures >
23
+ </projectDescription >
Original file line number Diff line number Diff line change
1
+ build.commands =org.eclipse.jdt.core.javabuilder
2
+ connection.arguments =
3
+ connection.gradle.distribution =GRADLE_DISTRIBUTION(WRAPPER)
4
+ connection.java.home =null
5
+ connection.jvm.arguments =
6
+ connection.project.dir =
7
+ derived.resources =.gradle,build
8
+ eclipse.preferences.version =1
9
+ natures =org.eclipse.jdt.core.javanature
10
+ project.path =\:
Original file line number Diff line number Diff line change 12
12
13
13
@ Controller
14
14
public class IndexController {
15
+ private static final int AMOUNT_TO_SHOW = 3 ;
15
16
private FlashCardService flashCardService ;
16
17
17
18
@ Autowired
@@ -22,18 +23,22 @@ public void setFlashCardService(FlashCardService flashCardService) {
22
23
@ RequestMapping ("/" )
23
24
public String index (Model model ) {
24
25
StringBuilder ctaBuilder = new StringBuilder ();
25
- List <FlashCard > cards = flashCardService .getRandomFlashCards (5 );
26
+ List <FlashCard > cards = flashCardService .getRandomFlashCards (AMOUNT_TO_SHOW );
26
27
ctaBuilder .append ("Refresh your memory about " );
27
28
for (FlashCard card : cards ) {
28
29
ctaBuilder .append (card .getTerm ());
29
30
if (card != cards .get (cards .size () - 1 )) {
30
31
ctaBuilder .append (", " );
31
32
}
32
33
}
33
- ctaBuilder .append (" and " );
34
34
Long totalCount = flashCardService .getCurrentCount ();
35
- ctaBuilder .append (totalCount );
36
- ctaBuilder .append (" more" );
35
+ if (totalCount > AMOUNT_TO_SHOW )
36
+ {
37
+ ctaBuilder .append (" and " );
38
+ ctaBuilder .append (totalCount - AMOUNT_TO_SHOW );
39
+ ctaBuilder .append (" more" );
40
+ }
41
+
37
42
model .addAttribute ("cta" , ctaBuilder .toString ());
38
43
model .addAttribute ("flashCardCount" , totalCount );
39
44
return "index" ;
You can’t perform that action at this time.
0 commit comments