Cmpute the maximum points scored by player 1 and player 2


Badminton Scoring - Java program - using API

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 ArrayListin a class called BadmintonScoring.

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

I. Compute the maximum points scored by Player 1 and Player 2.

II. 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

III. 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 (refer to Chapter 7, section 7.4.2 for details). 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

IV. Store the following score of a single game using the modified BadmintonScoring class.

0

1

a

2

c

 

 

 

 

 

3

a

4

c

 

 

 

 

 

 

 

 

 

 

5

c

 

 

 

 

 

 

0

 

 

1

d

2

e

3

d

4

e

5

d

 

 

6

e

7

e

8

a

9

d

10

e

11

e

12

e

13

e

14

e

15

e

 

16

e

17

e

18

e

19

e

20

e

21

a

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

BadmintonScoring

Attributes
+ int[][] scores
+ static final int PLAYER1
+ static final int PLAYER2
- Operations
+ public int getContinuousPointsPlayerl()
+ public int getContinuousPointsPlayer2()
+ public int getPlayerlPoints()
+ public int getPlayer2Points()

BadmintonScoringWithStroke

- Attributes
+ ArrayList scores
+ int scorel
+ int score2
+ static final int PLAYER1
+ static final int PLAYER2
- Operations
+ public String getMostUsedStrokePlayerl()
+ public String getMostUsedStrokePlayer2()

Point

- Attributes
+ private int player
+ private int score
+ private static final int PLAYER1
+ private static final int PLAYER2
+ private String stroke
- Operations
+ public int getPlayer()
+ public int getScore()
+ public Point(int player, String stroke, int value)
+ public String getStroke()

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Cmpute the maximum points scored by player 1 and player 2
Reference No:- TGS01460064

Now Priced at $35 (50% Discount)

Recommended (92%)

Rated (4.4/5)