Merge pull request #14 from mafagafogigante/master

Small refactorings
This commit is contained in:
Ilkka Seppälä 2014-11-09 12:57:24 +02:00
commit 86abc4177e
3 changed files with 11 additions and 22 deletions

View File

@ -50,11 +50,7 @@ public class App {
} }
public static boolean isOperator(String s) { public static boolean isOperator(String s) {
if (s.equals("+") || s.equals("-") || s.equals("*")) { return s.equals("+") || s.equals("-") || s.equals("*");
return true;
} else {
return false;
}
} }
public static Expression getOperatorInstance(String s, Expression left, public static Expression getOperatorInstance(String s, Expression left,

View File

@ -6,23 +6,16 @@ public enum Action {
public String toString() { public String toString() {
String s = "";
switch (this) { switch (this) {
case ENEMY: case ENEMY:
s = "spotted enemies"; return "spotted enemies";
break;
case GOLD: case GOLD:
s = "found gold"; return "found gold";
break;
case HUNT: case HUNT:
s = "hunted a rabbit"; return "hunted a rabbit";
break;
case TALE: case TALE:
s = "tells a tale"; return "tells a tale";
break;
default:
break;
} }
return s; return "";
}; }
} }

View File

@ -29,17 +29,17 @@ public class FileLoader {
try { try {
BufferedReader br = new BufferedReader(new FileReader(new File( BufferedReader br = new BufferedReader(new FileReader(new File(
this.fileName))); this.fileName)));
String text = ""; StringBuilder sb = new StringBuilder();
String line = ""; String line;
while ((line = br.readLine()) != null) { while ((line = br.readLine()) != null) {
text += line + "\n"; sb.append(line).append('\n');
} }
this.loaded = true; this.loaded = true;
br.close(); br.close();
return text; return sb.toString();
} }
catch (Exception e) { catch (Exception e) {