Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion java/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apply plugin: 'java'

sourceCompatibility = 1.7
sourceCompatibility = 1.6
group = 'it.tug'
version = '0.1'

Expand Down
12 changes: 5 additions & 7 deletions java/src/main/java/it/tug/Main/Formatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ public Formatter(Service service) {

public String doTheJob(String theInput) {
String response = service.askForPermission();
switch (response) {
case "FAIL":
return "error";
case "OK":
return String.format("%s%s", theInput, theInput);
default:
return null;

try {
return Response.valueOf(response).getResponseValue(theInput);
} catch (IllegalArgumentException e) {
return null;
}
}
}
20 changes: 20 additions & 0 deletions java/src/main/java/it/tug/Main/response.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package it.tug.Main;

public enum Response {
FAIL {
@Override
public String getResponseValue(String theInput) {
return "error";
}
}, OK
{
@Override
public String getResponseValue(String theInput) {
return String.format("%s%s", theInput, theInput);
}
};

public String getResponseValue(String theInput) {
return null;
}
}