summaryrefslogtreecommitdiff
path: root/src/Q8/README.md
blob: 90336a6b78d35f036fac2b02f1fd70e8a3ea490e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Learning Profile for Assignment #2 Question #8

## Name: Mo Khan
### Student ID: 3431709

1. Problem Statement

  The following is a score of a single game in badminton.
  The top row is the score for Player 1.
  The second row is the score for Player 2.
  Represent this data in an ArrayList in a class called `BadmintonScoring`.

  |  1 |  2 |  3 |  4 |  5 |  6 |  7 |  8 |  9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
  | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
  |  0 |  1 |  2 |    |    |    |    |    |  3 |  4 |    |    |    |    |    |    |    |    |    |    |  5 |    |    |    |    |    |    |
  |  0 |    |    |  1 |  2 |  3 |  4 |  5 |    |    |  6 |  7 |  8 |  9 | 10 | 11 | 12 | 13 | 14 | 15 |    | 16 | 17 | 18 | 19 | 20 | 21 |

  1. Compute the maximum points scored by Player 1 and Player 2.
  1. Compute the maximum number of points scored in a continuous sequence by Player 1 and Player 2.
    Hint: Player 1 scored the sequence 0-1-2, which implies s/he scored 2 points in a continuous sequence.
    Similarly, for Player 2, 16-17-18-19-20-21 implies that s/he scored 5 points in a continuous sequence.
  1. Extend `BadmintonScoring` to associate each point scored by a player with a particular stroke that earned that point, using the notion of association list.
    You can represent each point as an object and store the score of a player in an association list.
    For example, when Player 1 scored his/her first point, instead of just 1, it could have been {1, slice}.
    Thus, each point is augmented with the type of stroke from the following list:
      a. slice
      b. drive
      c. smash
      d. drop
      e. net-shot
  1. Store the following score of a single game using the modified `BadmintonScoring` class.

    | 01  | 02  | 03  | 04  | 05  | 06  | 07  | 08  | 09  | 10  | 11  | 12  | 13  | 14  | 15  | 16  | 17  | 18  | 19  | 20  | 21  | 22  | 23  | 24  | 25  | 26  | 27  |
    | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
    | 00  | 1a  | 2c  |     |     |     |     |     | 3a  | 4c  |     |     |     |     |     |     |     |     |     |     | 5c  |     |     |     |     |     |     |
    | 00  |     |     | 1d  | 2e  | 3d  | 4e  | 5d  |     |     | 6e  | 7e  | 8a  | 9d  | 10e | 11e | 12e | 13e | 14e | 15e |     | 16e | 17e | 18e | 19e | 20e | 21a |

  1. Identify the type of stroke that earned most points for each player.

1. Description of the Code

  The program includes 2 classes, `BadmintonScoring` and `BadmintonScoringWithStroke`.
  `BadmintonScoringWithStroke` inherits from `BadmintonScoring` and extends it
  with additional methods for calculating the preferred strokes for each player.

1. Errors and Warnings

  This program does not accept user input.

1. Sample Input and Output

  The output from running the program.

    ```bash
    $ java -cp target/assignment2*.jar ca.mokhan.comp268.App 8
    === Question 8 ===
    Player 1 points: 5
    Player 2 points: 21
    Player 1 streak: 2
    Player 2 streak: 9
    Player 1 favourite stroke: smash
    Player 2 favourite stroke: net-shot
    ```

1. Discussion