diff --git a/src/ch/zhaw/catan/SiedlerBoard.java b/src/ch/zhaw/catan/SiedlerBoard.java index ce3ea15..adf84fb 100644 --- a/src/ch/zhaw/catan/SiedlerBoard.java +++ b/src/ch/zhaw/catan/SiedlerBoard.java @@ -25,7 +25,7 @@ public class SiedlerBoard extends HexBoard fields = new HashMap<>(); private Config.Faction longestRoadFaction = null; - private int longestRoadLenth = 0; + private int longestRoadLength = 0; /** * Method to create the predefined game field from Config. @@ -47,6 +47,15 @@ public class SiedlerBoard extends HexBoard longestRoadLenth && players.get(factionA) > 4) { + if (players.get(factionA) > longestRoadLength && players.get(factionA) > 4) { longestRoadFaction = factionA; - longestRoadLenth = players.get(factionA); + longestRoadLength = players.get(factionA); } } return longestRoadFaction; } - //todo javadoc - public int getLongestRoadLenth() { - return longestRoadLenth; - } - /** * This method is recursive and adds all roads which belongs to a specific players and stringing together to a HashSet. * The length of the HashSet represents the length of the longest Road the player has. diff --git a/test/ch/zhaw/catan/SiedlerBoardTest.java b/test/ch/zhaw/catan/SiedlerBoardTest.java index f083917..8452824 100644 --- a/test/ch/zhaw/catan/SiedlerBoardTest.java +++ b/test/ch/zhaw/catan/SiedlerBoardTest.java @@ -41,7 +41,7 @@ public class SiedlerBoardTest { System.out.println(board.getTextView()); assertEquals(Config.Faction.BLUE, board.getLongestRoadFaction(factionList)); - assertEquals(6, board.getLongestRoadLenth()); + assertEquals(6, board.getLongestRoadLength()); } @Test @@ -50,7 +50,7 @@ public class SiedlerBoardTest { System.out.println(board.getTextView()); assertEquals(Config.Faction.BLUE, board.getLongestRoadFaction(factionList)); - assertEquals(5, board.getLongestRoadLenth()); + assertEquals(5, board.getLongestRoadLength()); } }