@@ -0,0 +1,85 @@ | |||
*.db | |||
############################## | |||
## Java | |||
############################## | |||
.mtj.tmp/ | |||
*.class | |||
*.jar | |||
*.war | |||
*.ear | |||
*.nar | |||
hs_err_pid* | |||
############################## | |||
## Maven | |||
############################## | |||
target/ | |||
pom.xml.tag | |||
pom.xml.releaseBackup | |||
pom.xml.versionsBackup | |||
pom.xml.next | |||
pom.xml.bak | |||
release.properties | |||
dependency-reduced-pom.xml | |||
buildNumber.properties | |||
.mvn/timing.properties | |||
.mvn/wrapper/maven-wrapper.jar | |||
############################## | |||
## Gradle | |||
############################## | |||
bin/ | |||
build/ | |||
.gradle | |||
.gradletasknamecache | |||
gradle-app.setting | |||
!gradle-wrapper.jar | |||
############################## | |||
## IntelliJ | |||
############################## | |||
out/ | |||
.idea/ | |||
.idea_modules/ | |||
*.iml | |||
*.ipr | |||
*.iws | |||
############################## | |||
## Eclipse | |||
############################## | |||
.settings/ | |||
bin/ | |||
tmp/ | |||
.metadata | |||
.classpath | |||
.project | |||
*.tmp | |||
*.bak | |||
*.swp | |||
*~.nib | |||
local.properties | |||
.loadpath | |||
.factorypath | |||
############################## | |||
## NetBeans | |||
############################## | |||
nbproject/private/ | |||
build/ | |||
nbbuild/ | |||
dist/ | |||
nbdist/ | |||
nbactions.xml | |||
nb-configuration.xml | |||
############################## | |||
## Visual Studio Code | |||
############################## | |||
.vscode/ | |||
.code-workspace | |||
############################## | |||
## OS X | |||
############################## | |||
.DS_Store |
@@ -0,0 +1,25 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project xmlns="http://maven.apache.org/POM/4.0.0" | |||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||
<modelVersion>4.0.0</modelVersion> | |||
<groupId>be.syntra</groupId> | |||
<artifactId>spring-core-exercise-java</artifactId> | |||
<version>1.0-SNAPSHOT</version> | |||
<packaging>jar</packaging> | |||
<properties> | |||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |||
<maven.compiler.source>11</maven.compiler.source> | |||
<maven.compiler.target>11</maven.compiler.target> | |||
</properties> | |||
<dependencies> | |||
<dependency> | |||
<groupId>org.junit.jupiter</groupId> | |||
<artifactId>junit-jupiter</artifactId> | |||
<version>5.7.1</version> | |||
<scope>test</scope> | |||
</dependency> | |||
</dependencies> | |||
</project> |
@@ -0,0 +1,17 @@ | |||
package be.syntra; | |||
public class App { | |||
public static void main(String[] args) { | |||
Coach coach = new SwimCoach(); | |||
//call method from bean | |||
System.out.println(coach.getDailyWorkout()); | |||
//get diet recommendation | |||
System.out.println(coach.getDailyMeal()); | |||
} | |||
} |
@@ -0,0 +1,7 @@ | |||
package be.syntra; | |||
public interface Coach { | |||
String getDailyWorkout(); | |||
String getDailyMeal(); | |||
} |
@@ -0,0 +1,5 @@ | |||
package be.syntra; | |||
interface DietService { | |||
String getRecommendation(); | |||
} |
@@ -0,0 +1,8 @@ | |||
package be.syntra; | |||
public class PaleoService implements DietService{ | |||
@Override | |||
public String getRecommendation() { | |||
return "Eat Meat"; | |||
} | |||
} |
@@ -0,0 +1,22 @@ | |||
package be.syntra; | |||
public class SwimCoach implements Coach { | |||
private DietService dietService; | |||
public SwimCoach() { | |||
this.dietService = new VeggieService(); | |||
} | |||
@Override | |||
public String getDailyWorkout() { | |||
return "Swim 1000 meters"; | |||
} | |||
@Override | |||
public String getDailyMeal() { | |||
return dietService.getRecommendation(); | |||
} | |||
} |
@@ -0,0 +1,24 @@ | |||
package be.syntra; | |||
public class TennisCoach implements Coach { | |||
private DietService dietService; | |||
public TennisCoach() { | |||
this.dietService = new VeganService(); | |||
} | |||
@Override | |||
public String getDailyWorkout() { | |||
return "Practice backhand volley"; | |||
} | |||
@Override | |||
public String getDailyMeal() { | |||
return dietService.getRecommendation(); | |||
} | |||
} |
@@ -0,0 +1,8 @@ | |||
package be.syntra; | |||
public class VeganService implements DietService { | |||
@Override | |||
public String getRecommendation() { | |||
return "Avoid everything that tastes good"; | |||
} | |||
} |
@@ -0,0 +1,9 @@ | |||
package be.syntra; | |||
public class VeggieService implements DietService { | |||
@Override | |||
public String getRecommendation() { | |||
return "Salad and veggie wraps"; | |||
} | |||
} |
@@ -0,0 +1,21 @@ | |||
package be.syntra; | |||
import static org.junit.jupiter.api.Assertions.assertTrue; | |||
import org.junit.jupiter.api.Test; | |||
/** | |||
* Unit test for simple App. | |||
*/ | |||
public class AppTest | |||
{ | |||
/** | |||
* Rigorous Test :-) | |||
*/ | |||
@Test | |||
public void shouldAnswerWithTrue() | |||
{ | |||
assertTrue( true ); | |||
} | |||
} |