Untitled
Untitled
Untitled
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.
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,
Then, total runs can be calculated as 20 + 130 + 55 + 102 +100 ==> 407
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.
Sample Input and Output 1 [Values given in bold represents the input]:
2. Exit
Matches played: 5
2. Exit