Untitled

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 4

State Board of Cricket Council – Running Case study

Requirement 2: Parse the player details and create a player profile

This functionality deals with getting the basic details of players such as player id, player name,
number of matches played, runs scored and playing zone of the player. Create a player object and
display as specified in the sample input and output.

The input string that has the player details will be stored in the following format.

playerId:playerName:matchesPlayed:runScoredInEachMatchSeperatedByColon:playingZ
one:playerType:numberOfHundredsOrMaidenOvers:numberOfFiftiesOrHatrickWickets

For eg:

HXCB1234D:Dhoni:5:20:130:55:102:100:North:Batsman:3:1

SAFG1243P:Mahee:3:20:30:55:South:Bowler:4:0

Note: In the provided input string, if a player has played N matches, then there will be runs
scored in N matches. In the above example Dhoni has played 5 matches so there are runs scored
in 5 matches.

The parsePlayerDetails method in the SBCCUtility class should take this input string as an
argument and should parse the String and create a Player by setting the values for all the
attributes of the Player and return the same.

Note: To calculate the value for the attribute runScored, this method has to invoke the
calculateTotalRuns method in the Player class by passing the details of runs scored by the
player in each match as an argument.

Component Specification: SBCCUtility Class

Component Type(Class) Attributes Methods Responsibilities


Name
Parse the SBCCUtility public Player This method takes the String
player parsePlayerDetail which holds all the player
details and s( String details as argument, it should
create a playerDetails) parse the data stored in the
Player String, Invoke the
calculateTotalRuns method
in the player class and create
the Player object and return
the same.

The calculateTotalRuns method in the Player class takes a string array as an argument. This string
array will have the details of runs scored by the player in each match. This method has to sum the
runs scored by the player in each match and return the sum.

For eg: If the string array passed as an argument contains the following values,

Runs scored by player in 5 matches = 20, 130, 55, 102, 100

Then, total runs can be calculated as 20 + 130 + 55 + 102 +100 ==> 407

Component Specification: Player (Model Class)

Component Type Attributes Methods Responsibilities


Name (Class)
Player String playerId Include all necessary
String playerName Getters and Setters for
int matchesPlayed all the attributes
int runScored Provide a no argument
String playingZone and a five-argument
constructor in the given
order
playerId, playerName,
matchesPlayed,
runScored and
playingZone.
Calculate the Player public int This method takes the
total runs calculateTotalRuns(St String array as an
scored by ring[] runScored) argument which
the Player contains the runs
scored by the player
in each match. It has
to calculate the total
runs scored by the
player by summing
the runs scored by the
player in each match
and return the sum.

In the UserInterface class, in the main method provided, fill the code to produce the output as
shown in the Sample input and Output.

When the user selects option 1 i.e., Parse the player details and create player, it should get the
player details from the user and display the player details.
When the user selects option 2 i.e., Exit, display the message "Thank you for using SBCC
application" and end the program.

OVERALL DESIGN CONSTRAINTS:


 The Player class should be inside the package com.sbcc.model
 The SBCCUtility class should be inside the package com.sbcc.utility
 The UserInterface class should be inside the package com.sbcc.main
 Adhere to the design specifications mentioned in the case study.
 The classes and methods should be declared as public and all the attributes should be
declared as private.
 Do not change or delete the class/method/attributes, names or return types which are
provided to you as a part of the base code skeleton.
 Please make sure that your code does not have any compilation errors while submitting.

Sample Input and Output 1 [Values given in bold represents the input]:

1. Parse the player details and create player

2. Exit

Enter your choice

Enter the player details


HXCB1234D:Dhoni:5:20:130:55:102:100:North:Batsman:3:1

Player id: HXCB1234D

Player name: Dhoni

Matches played: 5

Total runs scored: 407

Playing zone: North

1. Parse the player details and create player

2. Exit

Enter your choice

Thank you for using SBCC application

You might also like