Your program should accept input that represents statistics for some number of baseball players, convert this input into an array of BaseballPlayer objects, and display specific results obtained by processing the array.
Each line of the input will consist of six values that will be separated by a # character. The six values in order from left to right are:Player Name (aHere is an example:String
)
Home Runs (anInteger
)
Batting Average (aDouble
)
Base Hits (anInteger
)
Runs Batted In (anInteger
)
Stolen Bases (anInteger
)
Aaron, Hank # 755 # .305 # 3771 # 2297 # 240Note that you should use thetrim
method of theString
class to remove all leading and trailing spaces from the parts of the input line that you split using "#" as the delimiter before processing the values in your program.
You will need to define a class in your NetBeans project to represent Baseball Players. The class definition should have a private data member for each of the values shown above, a constructor method that accepts as many parameters as the class has private data members, a "getter" method for each private data member, and a toString method.
The input data should be stored in an array of Baseball Player objects. See Lab # 12 for an example of how to do this.
The following should be displayed in the output text area, separated by several blank lines for readability:
- all of the data in the input, on separate lines (display the result of the toString method, so that all data are shown in the output area)
- all players who have hit 520 home runs or more
- all players who have a batting average of .310 or higher
- the single player with the most RBIs of any player in the input
Your program should be able to process both of these inputs correctly: