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) {
if (s.equals("+") || s.equals("-") || s.equals("*")) {
return true;
} else {
return false;
}
return s.equals("+") || s.equals("-") || s.equals("*");
}
public static Expression getOperatorInstance(String s, Expression left,

View File

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

View File

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