The volleyball coach at Verde Valley High School would like some help managing her team. She would like a program to hel

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

The volleyball coach at Verde Valley High School would like some help managing her team. She would like a program to hel

Post by answerhappygod »

The Volleyball Coach At Verde Valley High School Would Like Some Help Managing Her Team She Would Like A Program To Hel 1
The Volleyball Coach At Verde Valley High School Would Like Some Help Managing Her Team She Would Like A Program To Hel 1 (30.58 KiB) Viewed 17 times
The Volleyball Coach At Verde Valley High School Would Like Some Help Managing Her Team She Would Like A Program To Hel 2
The Volleyball Coach At Verde Valley High School Would Like Some Help Managing Her Team She Would Like A Program To Hel 2 (36.19 KiB) Viewed 17 times
The Volleyball Coach At Verde Valley High School Would Like Some Help Managing Her Team She Would Like A Program To Hel 3
The Volleyball Coach At Verde Valley High School Would Like Some Help Managing Her Team She Would Like A Program To Hel 3 (15.17 KiB) Viewed 17 times
The Volleyball Coach At Verde Valley High School Would Like Some Help Managing Her Team She Would Like A Program To Hel 4
The Volleyball Coach At Verde Valley High School Would Like Some Help Managing Her Team She Would Like A Program To Hel 4 (43.62 KiB) Viewed 17 times
The Volleyball Coach At Verde Valley High School Would Like Some Help Managing Her Team She Would Like A Program To Hel 5
The Volleyball Coach At Verde Valley High School Would Like Some Help Managing Her Team She Would Like A Program To Hel 5 (30.75 KiB) Viewed 17 times
The Volleyball Coach At Verde Valley High School Would Like Some Help Managing Her Team She Would Like A Program To Hel 6
The Volleyball Coach At Verde Valley High School Would Like Some Help Managing Her Team She Would Like A Program To Hel 6 (44.64 KiB) Viewed 17 times
The Volleyball Coach At Verde Valley High School Would Like Some Help Managing Her Team She Would Like A Program To Hel 7
The Volleyball Coach At Verde Valley High School Would Like Some Help Managing Her Team She Would Like A Program To Hel 7 (52.88 KiB) Viewed 17 times
The Volleyball Coach At Verde Valley High School Would Like Some Help Managing Her Team She Would Like A Program To Hel 8
The Volleyball Coach At Verde Valley High School Would Like Some Help Managing Her Team She Would Like A Program To Hel 8 (22.42 KiB) Viewed 17 times
The Volleyball Coach At Verde Valley High School Would Like Some Help Managing Her Team She Would Like A Program To Hel 9
The Volleyball Coach At Verde Valley High School Would Like Some Help Managing Her Team She Would Like A Program To Hel 9 (26.97 KiB) Viewed 17 times
The Volleyball Coach At Verde Valley High School Would Like Some Help Managing Her Team She Would Like A Program To Hel 10
The Volleyball Coach At Verde Valley High School Would Like Some Help Managing Her Team She Would Like A Program To Hel 10 (44.13 KiB) Viewed 17 times
The Volleyball Coach At Verde Valley High School Would Like Some Help Managing Her Team She Would Like A Program To Hel 11
The Volleyball Coach At Verde Valley High School Would Like Some Help Managing Her Team She Would Like A Program To Hel 11 (53.71 KiB) Viewed 17 times
The Volleyball Coach At Verde Valley High School Would Like Some Help Managing Her Team She Would Like A Program To Hel 12
The Volleyball Coach At Verde Valley High School Would Like Some Help Managing Her Team She Would Like A Program To Hel 12 (40.85 KiB) Viewed 17 times
The Volleyball Coach At Verde Valley High School Would Like Some Help Managing Her Team She Would Like A Program To Hel 13
The Volleyball Coach At Verde Valley High School Would Like Some Help Managing Her Team She Would Like A Program To Hel 13 (44.23 KiB) Viewed 17 times
The Volleyball Coach At Verde Valley High School Would Like Some Help Managing Her Team She Would Like A Program To Hel 14
The Volleyball Coach At Verde Valley High School Would Like Some Help Managing Her Team She Would Like A Program To Hel 14 (15.77 KiB) Viewed 17 times
The Volleyball Coach At Verde Valley High School Would Like Some Help Managing Her Team She Would Like A Program To Hel 15
The Volleyball Coach At Verde Valley High School Would Like Some Help Managing Her Team She Would Like A Program To Hel 15 (25.21 KiB) Viewed 17 times
The volleyball coach at Verde Valley High School would like some help managing her team. She would like a program to help her identify the best players. She has team rosters stored in text files that contain the names of her players (first name, then last name separated by a space), and their stats as attacks per set (a double) followed by blocks per set (a double). Higher stat scores are better. Each data field is separated by a space. For example, one line in a roster file would look like: Gabrielle Reece 4.57 1.79 The coach would like the program to do the following: Present a menu with the following options: 1. Open a roster file 2. List all players. 3. List top attackers 4. List top blockers. 5. Add a player 6. Change a player's stats 7. Count players 8. Quit program
When the user chooses 1 to open a roster file, then the program will ask for the filename of a roster file, then open and read the data from that file into an ArrayList. When the user chooses 2 to list all players, then the program will list the names and stats of all player players. When the user chooses 3 to list top attackers, then the program will determine and list the names and stats of the players with the top 2 attack stats. When the user chooses 4 to list top blockers, then the program will determine and list the names and stats of the players with the top 2 stats for blocks When the user chooses 5 to add a player, then the program will prompt the user to enter the new player's name (first and last), attack stat (double), and block stat (double). The program should collect this information from the user, and then instantiate a new Player object with the given name and stats, and add that Player to the roster. When the user chooses 6 to change a player's stats, then the program will prompt the user to enter the player's name (first and last). If there is a player on the roster with the given name, then the program will collect the new attack stat score (double), and block stat score (double), and will update the stat values for this player. When the user chooses 7 to count players, then the program will display the number of players on the current roster. When the user chooses 8 the program will end
The Main class has already been designed and written for this program. Carefully review the code in the Main.java file and be sure that you understand how it works. Your task is to implement the Player and Roster classes. The Player class will allow us to instantiate Player objects that will store the important information (name, attack stat, block stat) for a player. The Roster class will allow us to create and manage a roster of players- we will use an ArrayList to store the Player objects
Part 1 - Implement the Player Class In a file named Player.java, implement the class described below. The Player class must have the following private instance variables: • a variable named name that will store a String • a variable named attackScore that will store a double • a variable named blockScore that will store a double The Player class must have the following public constructor method: • an overloaded constructor that takes three arguments. The first argument will be a String (player's name). The second (attack score) and third (block score) arguments will be type double The Player class must have the following public methods: • a method named getName. This accessor method will take no arguments. This method will return a String. • a method named getAttackScore. This accessor method will take no arguments. This method will return a double • a method named setAttackScore. This mutator method will take one double argument. This method will not return anything. • a method named getBlockScore. This accessor method will take no arguments. This method will return a double. • a method named setBlockScore. This mutator method will take one double argument. This method will not return anything • a method named printInfo. This method will take no arguments. This method will not return anything.
Other Details • The overloaded constructor should initialize the object's name, attackScore and blockScore variables with the values passed in to the parameter variables. • The getName accessor method should simply return the value stored in the object's name variable. • The getAttackScore accessor method should simply return the value currently stored in the object's attackScore variable. • The setAttackScore mutator method should store the value passed in as an argument in the object's attackScore variable. • The getBlockScore accessor method should simply return the value currently stored in the object's blockScore variable. • The setBlockScore mutator method should store the value passed in as an argument in the object's blockscore variable. • The print Info method should print out to the console, the name and stats for this player object. The printout should look like this: Rachael Adams (attack 3.36, block = 1.93)
Part 2- Implement the Roster Class In a file named Roster.java, implement the class described below. The Roster class must have the following private instance variables: • a variable named playerList that will store a reference to an ArrayList The Roster class must have the following public constructor methods: • a default constructor • an overloaded constructor that takes one argument. This argument will be a string. The Roster class must have the following public methods: • a method named addPlayer. This method will take three arguments. The first argument will be a String (player's name). The second (attack score) and third (block sscore) arguments will be double. • a method named getPlayerCount. This method will take no arguments. This method will return an int • a method named getPlayerByName. This method will take one String argument. This method will return a Player reference. • a method named print TopAttackers. This method will take no arguments. This method will not return anything. • a method named printTopBlockers. This method will take no arguments. This method will not return anything. • a method named printAllPlayers. This method will take no arguments. This method will not return anything.
Other Details • The default constructor should instantiate a new ArrayList object, and store a reference to this object in the Roster's playerList instance variable. • The overloaded constructor should instantiate a new ArrayList object, and store a reference to this object in the Roster's playerList instance variable. It should then open the roster file named in the parameter variable. It should then read in the data from this roster file and, for each line in the file, it should create (instantiate) a new Player object with the player name and block and attack scores on that line, and add this Player to the ArrayList playerList. • The addPlayer method should instantiate a new Player object with the name and block and attack scores provided in the argument values, and then add this Player to the roster's ArrayList object • The getPlayerCount method should return the number of players currently stored in the roster's ArrayList object. The getPlayer ByName method should iterate through the roster's ArrayList object and search for a player with a name that is equal to the argument value. If such a Player is found, then this method should return a reference to that Player object, otherwise this method should return null. • The print TopBlockers method should determine the two Player objects with the best block scores (in descending order). It should then call the print Info method on these Player objects. • The print TopAttackers method should determine the two Player objects with the best attack stats (in descending order). It should then call the printInfo method on these Player objects. • The printAllPlayers method should iterate through the roster's ArrayList object and call the print Info method on each of these Player objects.
rosterl.txt and roster2.txt Download Current file: Player.java - 1 // Implement your Player class in this file Load default template...
V!!! Make no changes to this java file !!! 2 import java.io.*; 3 import java.util.Scanner; 4 5 import javax.lang.model.util. Element Scanner6; 6 7 class Main ( 8 static Scanner scnr- new Scanner(System.in); 9 10 11 12 13 Current file: Main.java - prin public static void main(String[] args) throws IOException { Roster roster new Roster(); int menuChoice 0; Load default template.
14 456739 15 16 17 18 19 20 21 22 23 24 25 25 7 28 29 12BH567 38 19 26 27 30 31 32 33 34 35 36 37 39 while (menuChoice !- 8) { displayMenu(); menuChoice - getMenuChoice(); } if (menuChoice <-1) openRosterFile(); roster else if (menuChoice - 2) listAllPlayers(roster); else if (menuChoice listTopAttackers(roster); else if (menuChoice 4) listTopBlockers(roster); else if (menuChoice addPlayer (roster); else if (menuChoice 6) changePlayerStats(roster); else if (menuChoice countPlayers(roster); else if (menuChoice System.out.println(" System.out.println(" else M Current file: Main.java - 3) 7) 8) Quitting Program=-=-=-"); !!! Invalid Menu Choice 111"); Load default template
40 41 42 43 44 static void displayMenu() { System.out.println("---- System.out.println("1. System.out.println("2. System.out.println("3. 45 System.out.println("4. System.out.println("5. System.out.println("6. System.out.println("7. 46 47 48 49 50 51 52 56 57 58 59 60 61 62 63 64 65 66 67 } } Current file: Main.java static int getMenuChoice() { System.out.print("Enter return scnr.nextInt(); } static Roster openRosterFile() throws IOException { System.out.print("Enter roster file name --> "); String fileName - scnr.next(); return new Roster(fileName); Menu -----"); Open a roster file"); List all players"); List top attackers"); List top blockers"); Add a player"); Change a player's stats"); Count players"); System.out.println("8. Quit program"); } your menu Choice --> "); static void listAllPlayers (Roster roster) { System.out.println(" ---All Players -----"); roster.printAllPlayers(); Load default template....
68 能的7份 123 74 75 69 70 71 72 73 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 static void list TopAttackers (Roster roster) { System.out.println(" roster.print TopAttackers(); } Current file: 'Main.java - } static void list TopBlockers (Roster roster) { Top Attackers"); } System.out.println("----- Top Blockers roster.printTopBlockers(); -"); static void addPlayer (Roster roster) { String fullName = getPlayerName(); double attackScore - getAttackScore(); double blockScore getBlockScore(); roster.addPlayer (fullName, attackScore, blockScore); static void changePlayerStats (Roster roster) { String fullName getPlayerName(); Player playerToUpdate roster.getPlayerByName(fullName); if (playerToUpdate - null) { double newAttackScore getAttackScore(); double newBlockScore getBlockScore(); Load default template...
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 } Current file: Main.java - static void countPlayers (Roster roster) { System.out.printf("There are %d players on this roster.\n", roster.getPlayerCount()); } playerToUpdate.setAttackScore(newAttackScore); player ToUpdate.setBlockScore(newBlockScore); } else { System.out.printf(" !!! No player with the name %s found !!!\n", fullName); } static String getPlayerName() { System.out.print("Enter new player first name MI "); String firstName- scnr.next(); →→>"); System.out.print("Enter new player last name String lastName - scnr.next(); return firstName + + lastName; } static double getAttackScore() { System.out.print("Enter player's new attack score --> return scnr.nextDouble(); "); Load default template..
120 121 static double getBlockScore() { System.out.print("Enter player's new block score --> "); return scnr.nextDouble(); 122 123 124 } 125}
Downloadable files rosterl.txt and roster2.txt Download Current file: Roster.java 1 // Implement your Roster class in this fileimport java.util.ArrayList; Load default template...
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply