Question: ...Player.java... /** * Class Player defines data and method members for Player class objects * which represent soccer players on a team */ public class
...Player.java...
/**
* Class Player defines data and method members for Player class objects * which represent soccer players on a team */ public class Player { private int jerseyNum; private int rating;
/** * default constructor */ public Player() { jerseyNum = 0; rating = 0; }
/** * constructor with parameters * * @param jerseyNum * @param rating */ public Player(int jerseyNum, int rating) { this.jerseyNum = jerseyNum; this.rating = rating; }
/** * getter * * @return rating */ public int getRating() { return rating; }
/** * setter * * @param rating */ public void setRating(int rating) { this.rating = rating; }
/** * getter * * @return jerseyNum */ public int getJerseyNum() { return jerseyNum; }
/** * setter * * @param jerseyNum */ public void setJerseyNum(int jerseyNum) { this.jerseyNum = jerseyNum; } }
...PlayerArrayImpl?...
/** * Class to define data fields and methods for an array of Players * which represents a roster for a soccer team * @author */
import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.util.Scanner;
public class PlayerArrayImpl { public final static int ROSTER_MAX = 11; // size of array private Player [] playerArray; // list of players private int numPlayers; // number of players in list /** * Constructor */ public PlayerArrayImpl() { this.numPlayers = 0; playerArray = new Player[ROSTER_MAX]; } /** * getter * @return numPlayers */ public int getNumPlayers() { return numPlayers; }
/** * setter * @param numPlayers */ public void setNumPlayers(int numPlayers) { this.numPlayers = numPlayers; } /** * Method to read player data from file specified by filename * Each line of the file will contain a player number and a player rating, * separated by a space. Sample file lines: * 45 8 * 33 6 * The method will create a player object from each line of data, * and place the object into the playerArray * * @param filename - name of file containing player data * @throws IOException - to be handled by caller */ public void readRosterFile(String filename) throws IOException, ArrayIndexOutOfBoundsException {
}
/** * Method to display player jersey numbers and player ratings * for each player in playerArray */ public void displayRoster() {
} /** * Method to add a player to the playerArray, if there is room * * @param jerseyNum - of player to add * @param rating - of player to add */ public void addPlayer(int jerseyNum, int rating) {
} /** * Method to update one player's rating * @param jerseyNum - of player to update * @param rating - player's new rating */ public void updatePlayerRating(int jerseyNum, int rating) {
} /** * Method to save the data from playerArray to a file * (IOExceptions handled within the method) * Each line of the file will contain a player number and a player rating, * separated by a space. Sample file lines: * 45 8 * 33 6 * * @param filename - name of file to write data to */ public void writeRosterFile(String filename) {
}
/** * getter - FOR TESTING USE ONLY -- STUDENTS SHOULD NOT CALL THIS METHOD IN THEIR PROGRAMS * @return array of players */ public Player[] getPlayerArray() { return playerArray; } }
...RosterManager?...
/** * Program to manage a soccer team roster of up to 11 players * Roster data will be read from a file and stored * User will be able to display the roster, add a player, * update a player rating, and re-save the roster data. * * @author */
import java.io.IOException; import java.util.Scanner;
public class RosterManager {
/** * @param args the command line arguments */ public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); PlayerArrayImpl roster = new PlayerArrayImpl(); String inputFilename; System.out.println("Enter input data filename:"); inputFilename = keyboard.next();
} /** * Method displays menu to user * Reads, uppercases, and returns choice from menu * * @param keyboard - Scanner to read user data from * @return choice - uppercased menu choice entered by user */ public static char getChoice(Scanner keyboard) { char choice = '?'; return choice; } }







Problem Summary This program will store roster for a soccer team. Coaches rate players to ensure a balanced team Each player has a jersey number (0-99) and a rating (1 -9). The roster is stored in a data file. Each line of the file stores data for one player (jersey number and rating) Test Data Files (included in the zyLab) r2.txt 8 7 55 9 r5.txt 55 9 14 8 22 6 34 8 Problem Summary This program will store roster for a soccer team. Coaches rate players to ensure a balanced team Each player has a jersey number (0-99) and a rating (1 -9). The roster is stored in a data file. Each line of the file stores data for one player (jersey number and rating) Test Data Files (included in the zyLab) r2.txt 8 7 55 9 r5.txt 55 9 14 8 22 6 34 8
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
