Merge branch 'cica'

Tester methods modified
This commit is contained in:
ericnerdo 2016-04-26 00:57:22 +02:00
commit 651069d762
3 changed files with 87 additions and 30 deletions

View File

@ -30,4 +30,8 @@ public class Player extends PlayerBase {
public void shootStargate(Stargate stargate) { public void shootStargate(Stargate stargate) {
this.currentTile.getAdjacentTile(facingDirection).spawnStargate(stargate, facingDirection); this.currentTile.getAdjacentTile(facingDirection).spawnStargate(stargate, facingDirection);
} }
public int getZPMCount(){
return zpmContainer.size();
}
} }

View File

@ -5,11 +5,13 @@ public class PlayerBase implements Destroyable {
protected Tile currentTile; protected Tile currentTile;
protected Direction facingDirection; protected Direction facingDirection;
protected String name; protected String name;
protected boolean destroyed;
public PlayerBase(String name, Tile startTile, Direction startDirection) { public PlayerBase(String name, Tile startTile, Direction startDirection) {
this.name = name; this.name = name;
currentTile = startTile; currentTile = startTile;
facingDirection = startDirection; facingDirection = startDirection;
destroyed = false;
} }
@Override @Override
@ -18,6 +20,7 @@ public class PlayerBase implements Destroyable {
} }
public void destroy() { public void destroy() {
destroyed = true;
} }
public Tile getCurrentTile() { public Tile getCurrentTile() {
@ -78,4 +81,8 @@ public class PlayerBase implements Destroyable {
public void setFacingDirection(Direction direction) { public void setFacingDirection(Direction direction) {
facingDirection = direction; facingDirection = direction;
} }
public boolean isDestroyed(){
return destroyed;
}
} }

View File

@ -145,31 +145,31 @@ public class Tester {
@Test @Test
boolean moveTest() throws IOException{ boolean moveTest() throws IOException{
boolean succes = true; boolean success = true;
loadMap("moveTest"); loadMap("moveTest");
String listOfPlayers = listPlayers(); String listOfPlayers = listPlayers();
if(!listOfPlayers.equals("ONeill: 1, 1 Jaffa: -666, -666 Replicator: -666, -666")) if(!listOfPlayers.equals("ONeill: 1, 1 Jaffa: -666, -666 Replicator: -666, -666"))
succes = false; success = false;
move("O"); move("O");
listOfPlayers = listPlayers(); listOfPlayers = listPlayers();
if(!listOfPlayers.equals("ONeill: 1, 2 Jaffa: -666, -666 Replicator: -666, -666")) if(!listOfPlayers.equals("ONeill: 1, 2 Jaffa: -666, -666 Replicator: -666, -666"))
succes = false; success = false;
System.out.print("moveTest: "); System.out.print("moveTest: ");
if(succes) if(success)
System.out.println("Sikeres!"); System.out.println("Sikeres!");
else System.out.println("Sikertelen!"); else System.out.println("Sikertelen!");
return succes; return success;
} }
@Test @Test
boolean testStargates() throws IOException{ boolean testStargates() throws IOException{
boolean succes = true; boolean success = true;
loadMap("testStargates"); loadMap("testStargates");
shootONeillsGun("B"); shootONeillsGun("B");
@ -178,7 +178,7 @@ public class Tester {
String listOfStargates = listStargates(); String listOfStargates = listStargates();
if(!listOfStargates.equals("BlueStargate: 5, 10 YellowStargate: 10, 5 RedStargate: not spawned GreenStargate: not spawned")) if(!listOfStargates.equals("BlueStargate: 5, 10 YellowStargate: 10, 5 RedStargate: not spawned GreenStargate: not spawned"))
succes = false; success = false;
move("O"); move("O");
move("O"); move("O");
@ -186,19 +186,23 @@ public class Tester {
String listOfPlayers = listPlayers(); String listOfPlayers = listPlayers();
if(!listOfPlayers.equals("ONeill: 5, 9 Jaffa: -666, -666 Replicator: -666, -666")) if(!listOfPlayers.equals("ONeill: 5, 9 Jaffa: -666, -666 Replicator: -666, -666"))
succes = false; success = false;
System.out.print("testStargates: "); System.out.print("testStargates: ");
if(succes) if(success)
System.out.println("Sikeres!"); System.out.println("Sikeres!");
else System.out.println("Sikertelen!"); else System.out.println("Sikertelen!");
return succes; return success;
} }
@Test @Test
boolean testScalesAndGates() throws IOException { boolean testScalesAndGates() throws IOException {
<<<<<<< HEAD
boolean succes = true; boolean succes = true;
=======
boolean success = true;
>>>>>>> cica
loadMap("testScalesAndGates"); loadMap("testScalesAndGates");
boxLift("O"); boxLift("O");
@ -208,50 +212,52 @@ public class Tester {
String gateOpen = getConnectedGateOpen((Scale)oneill.getCurrentTile().getAdjacentTile(oneill.facingDirection)); String gateOpen = getConnectedGateOpen((Scale)oneill.getCurrentTile().getAdjacentTile(oneill.facingDirection));
if(!gateOpen.equals("gate open")) if(!gateOpen.equals("gate open"))
<<<<<<< HEAD
succes = false; succes = false;
=======
success = false;
>>>>>>> cica
System.out.print("testScalesAndGates: "); System.out.print("testScalesAndGates: ");
if(succes) if(success)
System.out.println("Sikeres!"); System.out.println("Sikeres!");
else System.out.println("Sikertelen!"); else System.out.println("Sikertelen!");
return succes; return success;
} }
@Test @Test
boolean gapTest(){ boolean gapTest() throws IOException{
String[] commands = {"loadMap gapTest\n",
"move O\n"};
String[] expectedOutputs = {}; loadMap("gapTest");
boolean results = testOnSequenceOfCommands(commands, expectedOutputs); move("O");
boolean success = oneill.isDestroyed();
System.out.print("gapTest: "); System.out.print("gapTest: ");
if(results) if(success)
System.out.println("Sikeres!"); System.out.println("Sikeres!");
else System.out.println("Sikertelen!"); else System.out.println("Sikertelen!");
return results; return success;
} }
@Test @Test
boolean ZPMTest() throws IOException{ boolean ZPMTest() throws IOException{
boolean succes = true; boolean success = true;
String[] commands = {"loadMap ZPMTest\n",
"move O\n"};
String[] expectedOutputs = {};
loadMap("ZPMTest"); loadMap("ZPMTest");
move("O"); move("O");
if(oneill.getZPMCount() != 1)
success = false;
System.out.print("ZPMTest: "); System.out.print("ZPMTest: ");
if(succes) if(success)
System.out.println("Sikeres!"); System.out.println("Sikeres!");
else System.out.println("Sikertelen!"); else System.out.println("Sikertelen!");
return succes; return success;
} }
@Test @Test
@ -285,17 +291,30 @@ public class Tester {
return results; return results;
} }
<<<<<<< HEAD
@Test @Test
boolean rotationTest() { boolean rotationTest() {
String[] commands = {"loadMap rotationTest\n", String[] commands = {"loadMap rotationTest\n",
"Rotate O L\n", "Rotate O L\n",
"Rotate O R\n"}; "Rotate O R\n"};
=======
>>>>>>> cica
String[] expectedOutputs = {}; @Test
boolean results = testOnSequenceOfCommands(commands, expectedOutputs); boolean rotationTest() throws IOException {
boolean success = true;
loadMap("rotationTest");
if(!rotate("O", "L").equals("WEST"))
success = false;
if(!rotate("O", "R").equals("NORTH"))
success = false;
System.out.print("rotationTest: "); System.out.print("rotationTest: ");
<<<<<<< HEAD
return true; //TODO check this return true; //TODO check this
} }
@ -316,6 +335,33 @@ public class Tester {
else System.out.println("Sikertelen!"); else System.out.println("Sikertelen!");
return succes; return succes;
=======
if(success)
System.out.println("Sikeres!");
else System.out.println("Sikertelen!");
return success;
}
@Test
boolean testBoxes() throws IOException{
boolean success = true;
loadMap("testBoxes");
if(!boxLift("O").equals("box lifted"))
success = false;
if(!boxDrop("O").equals("box dropped"))
success = false;
System.out.print("testBoxes: ");
if(success)
System.out.println("Sikeres!");
else System.out.println("Sikertelen!");
return success;
>>>>>>> cica
} }
private boolean testOnSequenceOfCommands(String[] commands, String[] expectedOutputs) { private boolean testOnSequenceOfCommands(String[] commands, String[] expectedOutputs) {