Tester.rotate() modified
This commit is contained in:
		| @@ -43,7 +43,7 @@ public class Tester { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     void boxLift(String param) { |     String boxLift(String param) { | ||||||
|         switch (param) { |         switch (param) { | ||||||
|             case "O" : |             case "O" : | ||||||
|                 oneill.boxLift(); |                 oneill.boxLift(); | ||||||
| @@ -52,9 +52,10 @@ public class Tester { | |||||||
|                 jaffa.boxLift(); |                 jaffa.boxLift(); | ||||||
|                 break; |                 break; | ||||||
|         } |         } | ||||||
|  |         return "box lifted"; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     void boxDrop(String param) { |     String boxDrop(String param) { | ||||||
|         switch (param) { |         switch (param) { | ||||||
|             case "O" : |             case "O" : | ||||||
|                 oneill.boxDrop(); |                 oneill.boxDrop(); | ||||||
| @@ -63,6 +64,7 @@ public class Tester { | |||||||
|                 oneill.boxDrop(); |                 oneill.boxDrop(); | ||||||
|                 break; |                 break; | ||||||
|         } |         } | ||||||
|  |         return "box dropped"; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     void shootONeillsGun(String param) { |     void shootONeillsGun(String param) { | ||||||
| @@ -76,26 +78,29 @@ public class Tester { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     void rotate(String playerParam, String directionParam) { |     String rotate(String playerParam, String directionParam) { | ||||||
|         switch (playerParam) { |         switch (playerParam) { | ||||||
|             case "O" : |             case "O" : | ||||||
|                 switch (directionParam) { |                 switch (directionParam) { | ||||||
|                     case "L" : |                     case "L" : | ||||||
|                         oneill.rotateLeft(); |                         oneill.rotateLeft(); | ||||||
|                         break; |                         return oneill.getFacingDirection().toString(); | ||||||
|                     case "R" : |                     case "R" : | ||||||
|                         oneill.rotateRight(); |                         oneill.rotateRight(); | ||||||
|                         break; |                         return oneill.getFacingDirection().toString(); | ||||||
|  |                     default: return "Hiba, nem fordult!"; | ||||||
|                 } |                 } | ||||||
|             case "J" : |             case "J" : | ||||||
|                 switch (directionParam) { |                 switch (directionParam) { | ||||||
|                     case "L" : |                     case "L" : | ||||||
|                         jaffa.rotateLeft(); |                         jaffa.rotateLeft(); | ||||||
|                         break; |                         return jaffa.getFacingDirection().toString(); | ||||||
|                     case "R" : |                     case "R" : | ||||||
|                         jaffa.rotateRight(); |                         jaffa.rotateRight(); | ||||||
|                         break; |                         return jaffa.getFacingDirection().toString(); | ||||||
|  |                     default: return "Hiba, nem fordult!"; | ||||||
|                 } |                 } | ||||||
|  |             default: return "Hiba, nem létező játékos!"; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -297,21 +302,20 @@ public class Tester { | |||||||
|  |  | ||||||
|     @Test |     @Test | ||||||
|     boolean testBoxes(){ |     boolean testBoxes(){ | ||||||
|         String[] commands = {"loadMap testBoxes\n", |         boolean succes = true; | ||||||
|                 "boxLift\n", |  | ||||||
|                 "boxDrop\n"}; |  | ||||||
|  |  | ||||||
|         String[] expectedOutputs = {"boc3 lifted\n", |         if(!boxLift("O").equals("box lifted")) | ||||||
|                 "box3 dropped\n"}; |             succes = false; | ||||||
|  |          | ||||||
|         boolean results = testOnSequenceOfCommands(commands, expectedOutputs); |         if(!boxDrop("O").equals("box dropped")) | ||||||
|  |             succes = false; | ||||||
|  |  | ||||||
|         System.out.print("testBoxes: "); |         System.out.print("testBoxes: "); | ||||||
|         if(results) |         if(succes) | ||||||
|             System.out.println("Sikeres!"); |             System.out.println("Sikeres!"); | ||||||
|         else System.out.println("Sikertelen!"); |         else System.out.println("Sikertelen!"); | ||||||
|  |  | ||||||
|         return results; |         return succes; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private boolean testOnSequenceOfCommands(String[] commands, String[] expectedOutputs) { |     private boolean testOnSequenceOfCommands(String[] commands, String[] expectedOutputs) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user