methods modified in Tester, StarGate.toString() fixed
This commit is contained in:
parent
be87c7f18a
commit
67cbdc7ba7
@ -52,6 +52,8 @@ public class Stargate {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s: %s", name, currentWall);
|
||||
if(isSpawned)
|
||||
return String.format("%s: %s", name, currentWall);
|
||||
else return String.format("%s: not spawned", name, currentWall);
|
||||
}
|
||||
}
|
||||
|
@ -99,11 +99,13 @@ public class Tester {
|
||||
}
|
||||
}
|
||||
|
||||
void listStargates() {
|
||||
System.out.println(Stargate.blueStargate);
|
||||
System.out.println(Stargate.yellowStargate);
|
||||
System.out.println(Stargate.redStargate);
|
||||
System.out.println(Stargate.greenStargate);
|
||||
String listStargates() {
|
||||
String blue = Stargate.blueStargate.toString();
|
||||
String yellow = Stargate.yellowStargate.toString();
|
||||
String red = Stargate.redStargate.toString();
|
||||
String green = Stargate.greenStargate.toString();
|
||||
|
||||
return blue + " " + yellow + " " + red + " " + green;
|
||||
}
|
||||
|
||||
/* custom Test annotation */
|
||||
@ -155,36 +157,32 @@ public class Tester {
|
||||
}
|
||||
|
||||
@Test
|
||||
boolean testStargates(){
|
||||
String[] commands = {"loadMap testStargates\n",
|
||||
"shootONeillsGun B\n",
|
||||
"rotate O L\n",
|
||||
"shootOneillsGun Y\n",
|
||||
"listStargates\n",
|
||||
"move\n",
|
||||
"listPlayers\n"};
|
||||
boolean testStargates() throws IOException{
|
||||
boolean succes = true;
|
||||
|
||||
String[] expectedOutputs = {"BlueStargate: 5, 10\n",
|
||||
"YellowStargate: 5, 9\n",
|
||||
"ONeill: 5, 9\n"};
|
||||
loadMap("testStargates");
|
||||
|
||||
shootONeillsGun("B");
|
||||
|
||||
rotate("O", "L");
|
||||
|
||||
shootONeillsGun("Y");
|
||||
|
||||
String listOfStargates = listStargates();
|
||||
if(!listOfStargates.equals("BlueStargate: 5, 10 YellowStargate: 10, 5 RedStargate: not spawned GreenStargate: not spawned"))
|
||||
succes = false;
|
||||
|
||||
move("O");
|
||||
move("O");
|
||||
move("O");
|
||||
|
||||
boolean results = testOnSequenceOfCommands(commands, expectedOutputs);
|
||||
String listOfPlayers = listPlayers();
|
||||
if(!listOfPlayers.equals("ONeill: 5, 9 Jaffa: -666, -666 Replicator: -666, -666"))
|
||||
succes = false;
|
||||
|
||||
System.out.print("testStargates: ");
|
||||
if(results)
|
||||
if(succes)
|
||||
System.out.println("Sikeres!");
|
||||
else System.out.println("Sikertelen!");
|
||||
|
||||
return results;
|
||||
return succes;
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -197,6 +195,8 @@ public class Tester {
|
||||
|
||||
String[] expectedOutputs = {};
|
||||
|
||||
loadMap("testExtraZPMs");
|
||||
|
||||
boolean results = testOnSequenceOfCommands(commands, expectedOutputs);
|
||||
|
||||
System.out.print("testExtraZPMs: ");
|
||||
@ -207,21 +207,27 @@ public class Tester {
|
||||
return results;
|
||||
}
|
||||
|
||||
boolean testScalesAndGates(){
|
||||
boolean testScalesAndGates() throws IOException {
|
||||
boolean succes = true;
|
||||
|
||||
String[] commands = {"loadMap testScalesAndGates\n",
|
||||
"boxLift O\n",
|
||||
"rotate O L\n",
|
||||
"boxDrop O\n"};
|
||||
|
||||
String[] expectedOutputs = {"door open\n"};
|
||||
boolean results = testOnSequenceOfCommands(commands, expectedOutputs);
|
||||
|
||||
loadMap("testScalesAndGates");
|
||||
boxLift("O");
|
||||
rotate("O", "L");
|
||||
boxDrop("O");
|
||||
|
||||
System.out.print("testScalesAndGates: ");
|
||||
if(results)
|
||||
if(succes)
|
||||
System.out.println("Sikeres!");
|
||||
else System.out.println("Sikertelen!");
|
||||
|
||||
return results;
|
||||
return succes;
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -241,19 +247,23 @@ public class Tester {
|
||||
}
|
||||
|
||||
@Test
|
||||
boolean ZPMTest(){
|
||||
boolean ZPMTest() throws IOException{
|
||||
boolean succes = true;
|
||||
|
||||
String[] commands = {"loadMap ZPMTest\n",
|
||||
"move O\n"};
|
||||
|
||||
String[] expectedOutputs = {};
|
||||
boolean results = testOnSequenceOfCommands(commands, expectedOutputs);
|
||||
|
||||
loadMap("ZPMTest");
|
||||
move("O");
|
||||
|
||||
System.out.print("ZPMTest: ");
|
||||
if(results)
|
||||
if(succes)
|
||||
System.out.println("Sikeres!");
|
||||
else System.out.println("Sikertelen!");
|
||||
|
||||
return results;
|
||||
return succes;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user