Question: Java In the main() method: o Create an ArrayList at the beginning of the method called players that will contain Player objects, i.e. new ArrayList().

Java In the main() method: o Create an ArrayList at the beginning of the method called players that will contain Player objects, i.e. new ArrayList(). o Read the lines from team.txt using Scanner and a loop just. Within each iteration of the loop that reads the lines from team.txt: Based on the changes you made to createPlayer() above, the method now returns a Player object rather than a double, so assign the returned Player object into a local variable called player and discard any references to totalScoringAverage. Add player to the players list. o When all lines have been read from the file, your players variable should now be an ArrayList of 10 Player object instances. o Declare a String[ ] array called opponents and populate it with the name of any 5 opposing teams or schools. For example: String[] opponents = new String[] {"BY", "Oxford", "Wale", "Harvard", "Uniben"}; o Loop through all members of the opponents array. In each loop iteration: Create a new instance of Game (instantiated with no arguments) in a local variable of type Game called game. Call game.setTeamName(), passing whatever you want to call your team. Call game.setOpponentName(), passing the opponent name (the current loop value). Call game.setDate(), passing whatever date values you wish (it's OK to pass the same date values each time through the loop). Call game.setPlayers(), passing the players ArrayList. The players will always be the same for all 5 Game objects you are creating. Call game.simulateGame(). This will produce the output you added in that method. o Retain the user-friendly exception handling .

For a clearer understanding of the question team.txt is a java file that contains about 10players. This won't run the program as they are previous linking questions, I just want to learn how to do this part.

Java In the main() method: o Create an ArrayList at the beginning

of the method called players that will contain Player objects, i.e. new

(45) Jav... 4. Copy TeamTest.java from Assignment 3 into cs520.hw4 and change its package name accordingly. Make the following changes: Remove the totalScoringAverage variable. Modify the createPlayer() method: Make it return Player instead of double. Remove the lines of code that reference scoringAverage. O Return the new player instance at the end of the method. O In the main() method: Create an ArrayList at the beginning of the method called players that will contain Player objects, i.e. new ArrayList(). Read the lines from team.txt using Scanner and a loop just as in the previous assignment. Within each iteration of the loop that reads the lines from team.txt: Based on the changes you made to createPlayer() above, the method now returns a Player object rather than a double, so assign the returned Player object into a local variable called player and discard any references to tota/ScoringAverage. Add player to the players list. When all lines have been read from the file, your players variable should now be an ArrayList of 10 O Player object instances. uloto it with the name of any 5. annosing teams or When all lines have been read from the file, your players variable should now be an ArrayList of 10 Player object instances. Declare a String[] array called opponents and populate it with the name of any 5 opposing teams or schools. For example: String[] opponents = new String[] {"BC", "Northeastern", "Harvard", "MIT", "UMass"}} Loop through all members of the opponents array. In each loop iteration: Create a new instance of Game (instantiated with no arguments) in a local variable of type Game called game. Call game.setTeamName(), passing whatever you want to call your team. Call game.setOpponentName(), passing the opponent name (the current loop value). Call game.setDate(), passing whatever date values you wish (it's OK to pass the same date values each time through the loop). Call game.setPlayers(), passing the players ArrayList. The players will always be the same for all 5 Game objects you are creating. (45) Jav... 4. Copy TeamTest.java from Assignment 3 into cs520.hw4 and change its package name accordingly. Make the following changes: Remove the totalScoringAverage variable. Modify the createPlayer() method: Make it return Player instead of double. Remove the lines of code that reference scoringAverage. O Return the new player instance at the end of the method. O In the main() method: Create an ArrayList at the beginning of the method called players that will contain Player objects, i.e. new ArrayList(). Read the lines from team.txt using Scanner and a loop just as in the previous assignment. Within each iteration of the loop that reads the lines from team.txt: Based on the changes you made to createPlayer() above, the method now returns a Player object rather than a double, so assign the returned Player object into a local variable called player and discard any references to tota/ScoringAverage. Add player to the players list. When all lines have been read from the file, your players variable should now be an ArrayList of 10 O Player object instances. uloto it with the name of any 5. annosing teams or When all lines have been read from the file, your players variable should now be an ArrayList of 10 Player object instances. Declare a String[] array called opponents and populate it with the name of any 5 opposing teams or schools. For example: String[] opponents = new String[] {"BC", "Northeastern", "Harvard", "MIT", "UMass"}} Loop through all members of the opponents array. In each loop iteration: Create a new instance of Game (instantiated with no arguments) in a local variable of type Game called game. Call game.setTeamName(), passing whatever you want to call your team. Call game.setOpponentName(), passing the opponent name (the current loop value). Call game.setDate(), passing whatever date values you wish (it's OK to pass the same date values each time through the loop). Call game.setPlayers(), passing the players ArrayList. The players will always be the same for all 5 Game objects you are creating

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!