Commit e1032de
Changed files (2)
src
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()));
+ }
}
src/App.java
@@ -35,6 +35,9 @@ public class App {
case 7:
Q7.Person.main(args);
break;
+ case 8:
+ Q8.BadmintonScoring.main(args);
+ break;
default:
System.out.println("Bye");
System.exit(0);