methods modified in Tester, StarGate.toString() fixed
This commit is contained in:
parent
be87c7f18a
commit
67cbdc7ba7
@ -52,6 +52,8 @@ public class Stargate {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
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() {
|
String listStargates() {
|
||||||
System.out.println(Stargate.blueStargate);
|
String blue = Stargate.blueStargate.toString();
|
||||||
System.out.println(Stargate.yellowStargate);
|
String yellow = Stargate.yellowStargate.toString();
|
||||||
System.out.println(Stargate.redStargate);
|
String red = Stargate.redStargate.toString();
|
||||||
System.out.println(Stargate.greenStargate);
|
String green = Stargate.greenStargate.toString();
|
||||||
|
|
||||||
|
return blue + " " + yellow + " " + red + " " + green;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* custom Test annotation */
|
/* custom Test annotation */
|
||||||
@ -155,36 +157,32 @@ public class Tester {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
boolean testStargates(){
|
boolean testStargates() throws IOException{
|
||||||
String[] commands = {"loadMap testStargates\n",
|
boolean succes = true;
|
||||||
"shootONeillsGun B\n",
|
|
||||||
"rotate O L\n",
|
|
||||||
"shootOneillsGun Y\n",
|
|
||||||
"listStargates\n",
|
|
||||||
"move\n",
|
|
||||||
"listPlayers\n"};
|
|
||||||
|
|
||||||
String[] expectedOutputs = {"BlueStargate: 5, 10\n",
|
|
||||||
"YellowStargate: 5, 9\n",
|
|
||||||
"ONeill: 5, 9\n"};
|
|
||||||
loadMap("testStargates");
|
loadMap("testStargates");
|
||||||
|
|
||||||
shootONeillsGun("B");
|
shootONeillsGun("B");
|
||||||
|
|
||||||
rotate("O", "L");
|
rotate("O", "L");
|
||||||
|
|
||||||
shootONeillsGun("Y");
|
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: ");
|
System.out.print("testStargates: ");
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -197,6 +195,8 @@ public class Tester {
|
|||||||
|
|
||||||
String[] expectedOutputs = {};
|
String[] expectedOutputs = {};
|
||||||
|
|
||||||
|
loadMap("testExtraZPMs");
|
||||||
|
|
||||||
boolean results = testOnSequenceOfCommands(commands, expectedOutputs);
|
boolean results = testOnSequenceOfCommands(commands, expectedOutputs);
|
||||||
|
|
||||||
System.out.print("testExtraZPMs: ");
|
System.out.print("testExtraZPMs: ");
|
||||||
@ -207,21 +207,27 @@ public class Tester {
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean testScalesAndGates(){
|
boolean testScalesAndGates() throws IOException {
|
||||||
|
boolean succes = true;
|
||||||
|
|
||||||
String[] commands = {"loadMap testScalesAndGates\n",
|
String[] commands = {"loadMap testScalesAndGates\n",
|
||||||
"boxLift O\n",
|
"boxLift O\n",
|
||||||
"rotate O L\n",
|
"rotate O L\n",
|
||||||
"boxDrop O\n"};
|
"boxDrop O\n"};
|
||||||
|
|
||||||
String[] expectedOutputs = {"door open\n"};
|
String[] expectedOutputs = {"door open\n"};
|
||||||
boolean results = testOnSequenceOfCommands(commands, expectedOutputs);
|
|
||||||
|
loadMap("testScalesAndGates");
|
||||||
|
boxLift("O");
|
||||||
|
rotate("O", "L");
|
||||||
|
boxDrop("O");
|
||||||
|
|
||||||
System.out.print("testScalesAndGates: ");
|
System.out.print("testScalesAndGates: ");
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -241,19 +247,23 @@ public class Tester {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
boolean ZPMTest(){
|
boolean ZPMTest() throws IOException{
|
||||||
|
boolean succes = true;
|
||||||
|
|
||||||
String[] commands = {"loadMap ZPMTest\n",
|
String[] commands = {"loadMap ZPMTest\n",
|
||||||
"move O\n"};
|
"move O\n"};
|
||||||
|
|
||||||
String[] expectedOutputs = {};
|
String[] expectedOutputs = {};
|
||||||
boolean results = testOnSequenceOfCommands(commands, expectedOutputs);
|
|
||||||
|
|
||||||
|
loadMap("ZPMTest");
|
||||||
|
move("O");
|
||||||
|
|
||||||
System.out.print("ZPMTest: ");
|
System.out.print("ZPMTest: ");
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user