File tree Expand file tree Collapse file tree 3 files changed +11
-22
lines changed
interpreter/src/main/java/com/iluwatar
mediator/src/main/java/com/iluwatar
model-view-presenter/src/main/java/com/iluwatar Expand file tree Collapse file tree 3 files changed +11
-22
lines changed Original file line number Diff line number Diff line change @@ -50,11 +50,7 @@ public static void main(String[] args) {
5050 }
5151
5252 public static boolean isOperator (String s ) {
53- if (s .equals ("+" ) || s .equals ("-" ) || s .equals ("*" )) {
54- return true ;
55- } else {
56- return false ;
57- }
53+ return s .equals ("+" ) || s .equals ("-" ) || s .equals ("*" );
5854 }
5955
6056 public static Expression getOperatorInstance (String s , Expression left ,
Original file line number Diff line number Diff line change @@ -6,23 +6,16 @@ public enum Action {
66
77 public String toString () {
88
9- String s = "" ;
109 switch (this ) {
1110 case ENEMY :
12- s = "spotted enemies" ;
13- break ;
11+ return "spotted enemies" ;
1412 case GOLD :
15- s = "found gold" ;
16- break ;
13+ return "found gold" ;
1714 case HUNT :
18- s = "hunted a rabbit" ;
19- break ;
15+ return "hunted a rabbit" ;
2016 case TALE :
21- s = "tells a tale" ;
22- break ;
23- default :
24- break ;
17+ return "tells a tale" ;
2518 }
26- return s ;
27- };
19+ return "" ;
20+ }
2821}
Original file line number Diff line number Diff line change @@ -29,17 +29,17 @@ public String loadData() {
2929 try {
3030 BufferedReader br = new BufferedReader (new FileReader (new File (
3131 this .fileName )));
32- String text = "" ;
33- String line = "" ;
32+ StringBuilder sb = new StringBuilder () ;
33+ String line ;
3434
3535 while ((line = br .readLine ()) != null ) {
36- text += line + " \n " ;
36+ sb . append ( line ). append ( '\n' ) ;
3737 }
3838
3939 this .loaded = true ;
4040 br .close ();
4141
42- return text ;
42+ return sb . toString () ;
4343 }
4444
4545 catch (Exception e ) {
You can’t perform that action at this time.
0 commit comments