Implemented longest Road logic in SiedlerGame

-adjusted Road and Settlement to return position
This commit is contained in:
Andrin Fassbind
2021-12-05 13:53:36 +01:00
parent 51e61a8e00
commit a79e1eefe3
6 changed files with 212 additions and 17 deletions
+33
View File
@@ -1,8 +1,14 @@
package ch.zhaw.catan;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.beryx.textio.TextIO;
import org.beryx.textio.TextIoFactory;
import org.beryx.textio.TextTerminal;
import org.junit.jupiter.api.Test;
import java.awt.*;
/***
* TODO Write your own tests in this class.
@@ -18,4 +24,31 @@ public class SiedlerGameTest {
assertTrue(false);
}
/**
* To Test getLongestRoad in SiedlerGame isolatet do:
* 1. make SiedlerGame.getLongestRoadFaction, Siedlergame.countRoad && Siedlergame.getNextPoint static
* 2. make SiedlerGame.getLongestRoadFaction public
* 3. add Parameter Board to SiedlerGame.getLongestRoadFaction and SiedlerGame.countRoad.
* 4. add Parameter faction to SiedlerGame.getLongestRoadFaction
* 5. Create Board in testLongestRoad() and Hashmap with faction
* Tipp: Logic Equivalent classes are: start counting at settlements with 0 or 1 or 2 or 3 own roads attached to it
* Make branches in between the road with diffrent lengths.
*
*/
@Test
public void testLongestRoad() {
SiedlerBoard board = new SiedlerBoard();
board.createFixGamefield();
board.setEdge(new Point(6, 6), new Point(5, 7), new Road(Config.Faction.BLUE,new Point(6, 6),new Point(5, 7)));
board.setEdge(new Point(4, 6), new Point(5, 7), new Road(Config.Faction.BLUE,new Point(4, 6),new Point(5, 7)));
board.setEdge(new Point(4, 6), new Point(4, 4), new Road(Config.Faction.BLUE,new Point(4, 6),new Point(4, 4)));
board.setEdge(new Point(4, 6), new Point(3, 7), new Road(Config.Faction.BLUE,new Point(4, 6),new Point(3, 7)));
board.setEdge(new Point(3, 7), new Point(3, 9), new Road(Config.Faction.BLUE,new Point(3, 7),new Point(3, 9)));
board.setEdge(new Point(3, 9), new Point(4, 10), new Road(Config.Faction.BLUE,new Point(3, 9),new Point(4, 10)));
board.setEdge(new Point(4, 10), new Point(5, 9), new Road(Config.Faction.BLUE,new Point(4, 10),new Point(5, 9)));
board.setCorner(new Point(3,7),new Settlement(Config.Faction.BLUE,new Point(3,7)));
//SiedlerGame.getLongestRoadFaction(board,faction);
}
}