Question
Need Help in turning Roster.java only. Help will be highly rated and appreciated.The question goes as: Assignment08.java: // !!! Make no changes to this .java
Need Help in turning Roster.java only. Help will be highly rated and appreciated.The question goes as:
Assignment08.java:
// !!! Make no changes to this .java file !!! import java.io.*; import java.util.Scanner;
import javax.lang.model.util.ElementScanner6;
class Assignment08 { static Scanner scnr = new Scanner(System.in);
public static void main(String[] args) throws IOException { Roster roster = new Roster();
int menuChoice = 0;
while (menuChoice != 8) { displayMenu(); menuChoice = getMenuChoice();
if (menuChoice == 1) roster = openRosterFile(); else if (menuChoice == 2) listAllPlayers(roster); else if (menuChoice == 3) listTopAttackers(roster); else if (menuChoice == 4) listTopBlockers(roster); else if (menuChoice == 5) addPlayer(roster); else if (menuChoice == 6) changePlayerStats(roster); else if (menuChoice == 7) countPlayers(roster); else if (menuChoice == 8) System.out.println("===== Quitting Program ====="); else System.out.println(" !!! Invalid Menu Choice !!!"); } }
static void displayMenu() { System.out.println("===== Menu ====="); System.out.println("1. Open a roster file"); System.out.println("2. List all players"); System.out.println("3. List top attackers"); System.out.println("4. List top blockers"); System.out.println("5. Add a player"); System.out.println("6. Change a player's stats"); System.out.println("7. Count players"); System.out.println("8. Quit program"); }
static int getMenuChoice() { System.out.print("Enter your menu Choice --> "); return scnr.nextInt(); }
static Roster openRosterFile() throws IOException { System.out.print("Enter roster file name --> "); String fileName = scnr.next();
return new Roster(fileName); }
static void listAllPlayers(Roster roster) { System.out.println("===== All Players ====="); roster.printAllPlayers(); }
static void listTopAttackers(Roster roster) { System.out.println("===== Top Attackers ====="); roster.printTopAttackers(); }
static void listTopBlockers(Roster roster) { System.out.println("===== Top Blockers ====="); roster.printTopBlockers(); }
static void addPlayer(Roster roster) { String fullName = getPlayerName(); double attackStat = getAttackStat(); double blockStat = getBlockStat();
roster.addPlayer(fullName, attackStat, blockStat); }
static void changePlayerStats(Roster roster) { String fullName = getPlayerName();
Player playerToUpdate = roster.getPlayerByName(fullName);
if (playerToUpdate != null) { double newAttackStat = getAttackStat(); double newBlockStat = getBlockStat();
playerToUpdate.setAttackStat(newAttackStat); playerToUpdate.setBlockStat(newBlockStat); } else { System.out.printf(" !!! No player with the name %s found !!! ", fullName); } }
static void countPlayers(Roster roster) { System.out.printf("There are %d players on this roster. ", roster.countPlayers()); }
static String getPlayerName() { System.out.print("Enter new player first name --> "); String firstName = scnr.next(); System.out.print("Enter new player last name --> "); String lastName = scnr.next(); return firstName + " " + lastName; }
static double getAttackStat() { System.out.print("Enter player's new attack stat --> "); return scnr.nextDouble(); }
static double getBlockStat() { System.out.print("Enter player's new block stat --> "); return scnr.nextDouble(); } } Roster1.dat:
Rachael Adams 3.36 1.93 Foluke Akinradewo 4.81 1.14 Kayla Banwarth 2.98 0.50 Michelle Bartsch 0.28 1.42 Krista Vansant 2.78 0.86 Courtney Thompson 0.59 0.93 Kelly Murphy 1.15 0.58 Lauren Gibbemeyer 2.25 0.50 Alexis Crimes 3.89 1.34 Tori Dixon 0.92 1.62 Nicole Fawcett 4.01 0.61 Alisha Glass 1.96 1.55 Natalie Hagglund 2.49 0.52 Kim Hill 1.53 1.76 Cursty Jackson 0.69 1.44
Need help on Roster.java only. Thanks!
CSE110 Principles of Programming Assignment 08::100 pts Assignment 08 - Monsters You must work in alone on this assignment. Do not use any Java language features we have not cover so far in this course. Assignment Objectives After completing this assignment the student should be able to: Implement a class according to given specifications Implement private instance variables Implement constructor methods Implement getter and setter methods Read input from files Assignment Requirements For this assignment you are given the following files: Assignment08.java (make no changes to this file) Roster1.dat (make no changes to this file) Roster2.dat (make no changes to this file) Player.java (you must complete this file) Roster.java (you must complete this file) Problem Description and Given Info 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 stats 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. P.Miller CSE110 Principles of Programming Assignment 08:100 pts 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 (double), and block stat (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 (given in Assignment08.java). Carefully review the code in the Assignment08.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 ArrayListStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started