diff options
Diffstat (limited to 'src/Q8/BadmintonScoring.java')
| -rw-r--r-- | src/Q8/BadmintonScoring.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/Q8/BadmintonScoring.java b/src/Q8/BadmintonScoring.java index 927f417..56c8e40 100644 --- a/src/Q8/BadmintonScoring.java +++ b/src/Q8/BadmintonScoring.java @@ -59,4 +59,51 @@ public class BadmintonScoring { int player1PreviousScore = scores[round - 1][0]; return player1Score > player1PreviousScore ? PLAYER1 : PLAYER2; } + + public static void main(String[] args) { + ArrayList<Point> points = + new ArrayList<Point>() { + { + add(new Point(Point.PLAYER1, "a", 1)); + add(new Point(Point.PLAYER1, "c", 2)); + add(new Point(Point.PLAYER2, "d", 1)); + add(new Point(Point.PLAYER2, "e", 2)); + add(new Point(Point.PLAYER2, "d", 3)); + add(new Point(Point.PLAYER2, "e", 4)); + add(new Point(Point.PLAYER2, "d", 5)); + add(new Point(Point.PLAYER1, "a", 3)); + add(new Point(Point.PLAYER1, "c", 4)); + add(new Point(Point.PLAYER2, "e", 6)); + add(new Point(Point.PLAYER2, "e", 7)); + add(new Point(Point.PLAYER2, "a", 8)); + add(new Point(Point.PLAYER2, "d", 9)); + add(new Point(Point.PLAYER2, "e", 10)); + add(new Point(Point.PLAYER2, "e", 11)); + add(new Point(Point.PLAYER2, "e", 12)); + add(new Point(Point.PLAYER2, "e", 13)); + add(new Point(Point.PLAYER2, "e", 14)); + add(new Point(Point.PLAYER2, "e", 15)); + add(new Point(Point.PLAYER1, "c", 5)); + add(new Point(Point.PLAYER2, "e", 16)); + add(new Point(Point.PLAYER2, "e", 17)); + add(new Point(Point.PLAYER2, "e", 18)); + add(new Point(Point.PLAYER2, "e", 19)); + add(new Point(Point.PLAYER2, "e", 20)); + add(new Point(Point.PLAYER2, "e", 21)); + } + }; + BadmintonScoringWithStroke scoring = new BadmintonScoringWithStroke(points); + + System.out.println("=== Question 8 ==="); + System.out.println(String.format("Player 1 points: %d", scoring.getPlayer1Points())); + System.out.println(String.format("Player 2 points: %d", scoring.getPlayer2Points())); + + System.out.println(String.format("Player 1 streak: %d", scoring.getContinuousPointsPlayer1())); + System.out.println(String.format("Player 2 streak: %d", scoring.getContinuousPointsPlayer2())); + + System.out.println( + String.format("Player 1 favourite stroke: %s", scoring.getMostUsedStrokePlayer1())); + System.out.println( + String.format("Player 2 favourite stroke: %s", scoring.getMostUsedStrokePlayer2())); + } } |
