OK I have a project due tonight at midnight and I know I should have posted sooner but it seemed like such simple things that I just knew I could do it on my own. I was wrong. I need your help. I have a program that essentially makes a database in the console by asking the user for names and stats of various sports players. It saves them to a txt file, sorts them, removes them and averages the stats. No problems there. The problems I am having are that I am supposed to do error detection using exception handling which I can't get to work and everything I find on it seems to not fit with my code (try/catch with external methods when im doing it in a single method or something). My second problem is that I am supposed to implement a load function with the following parameters:
LOAD: Prompts the user for a filename that was created by a previous SAVE operation. The
players represented in the SAVE file that do not already exist in the current list of players are added to the current list of players in the application. Each player may be assumed to have a unique name. Note, neither first nor last names alone can be assumed to be unique, but the combination of both first and last name can be assumed to be unique. E.g., Jane Doe, Jane Smith, and John Doe are all valid unique names for players. Each player class must implement a new constructor that takes a single formatted string as its parameter. This constructor should, in essence, create an object with the appropriate instanced information from a string produced previously by its own toString() method. Use these constructors in your LOAD implementation.
String playerInfo = “Jane Doe: Points: 4 Assists: %: 0.25”);
SoccerPlayer player = new SoccerPlayer(playerInfo);
I know I'll probably have to use a buffered IO stream or something but I can't find anything in my books or online that talks about loading, only saving. I'm aware of the oracle java tutorial for io streams but that website has been the least helpful thing when it comes to programming. Heres the code:
Main Class:
/**
* This program will asks the user what they want to do with a user prompt
* and then it calls the method that corresponds to the selected command. The
* commands will either add a player to the list, remove a player from the list,
* show the list in it's entirety, save the list to a file, or quit the program.
* This program uses a Player class that helps to define the player object that
* is in use.
*/
package cs241project2;
import java.util.*;
import java.io.*;
/**
* @author 24x24
*/
public class Main {
public static void main(String[] args) throws IOException {
Scanner keyboard = new Scanner(System.in);
String menuOperation;
ArrayList<PlayerStats> players = new ArrayList<PlayerStats>();
do {
menuOperation = getMenuChoice(keyboard);
// perform the method depending on the choice
if (menuOperation.equalsIgnoreCase("ADD")) {
add(keyboard, players);
} else if (menuOperation.equalsIgnoreCase("REMOVE")) {
remove(keyboard, players);
} else if (menuOperation.equalsIgnoreCase("SHOW")) {
show(players);
} else if (menuOperation.equalsIgnoreCase("SAVE")) {
save(keyboard, players);
} else if (menuOperation.equalsIgnoreCase("SORT")) {
sort(players);
} else if (menuOperation.equalsIgnoreCase("LOAD")) {
load(keyboard);
}
// repeat if the choice does not equal QUIT
} while (!(menuOperation.equalsIgnoreCase("QUIT")));
System.out.println();
System.out.println("** GOODBYE! **");
} // end method main
/**
* The getMenuChoice method asks the user to pick a menu option. They
* must pick one option: add player, remove player, show players statistics,
* save the players statistics, or quit the program. The
* case of the keyboard is unimportant.
* @param keyboard scanner for user to input choices
* @return the string of a valid menu option: add, remove, show, save,
* or quit.
*/
public static String getMenuChoice(Scanner keyboard) {
String choice;
System.out.println("What operation next? (ADD, REMOVE, SHOW, SAVE, LOAD, SORT, QUIT)?");
choice = keyboard.nextLine().trim();
while (!(choice.equalsIgnoreCase("ADD") || choice.equalsIgnoreCase("REMOVE") || choice.equalsIgnoreCase("SHOW") || choice.equalsIgnoreCase("SAVE") || choice.equalsIgnoreCase("LOAD") || choice.equalsIgnoreCase("SORT") || choice.equalsIgnoreCase("QUIT"))) {
System.out.println("Operation not recognized. Please choose from the available list.\n");
System.out.println("What operation next? (ADD, REMOVE, SHOW, SAVE, LOAD, SORT, QUIT)?");
choice = keyboard.nextLine().trim();
}
return choice;
} // end method getMenuChoice
/**
* The add method queries the user to keyboard the name of a player,
* along with the points scored, assists made, and the penalty kick
* rate for that player. The method uses an ArrayList to store Player
* objects into a string, separated by commas between the full name, the
* points scored, assists made, and penalty kick rate percentage.
* @param keyboard Scanner for user keyboard
* @param players ArrayList of all players and their stats
*/
public static void add(Scanner keyboard, ArrayList<PlayerStats> team) {
String sportChoice;
System.out.println("Please enter sport type (SOCCER, PAINTBALL, BASEBALL):");
sportChoice = keyboard.nextLine().trim();
// error checking for sport type
while (!(sportChoice.equalsIgnoreCase("SOCCER")
|| sportChoice.equalsIgnoreCase("PAINTBALL")
|| sportChoice.equalsIgnoreCase("BASEBALL"))) {
System.out.println("Operation not recognized. Please choose from the available list.\n");
sportChoice = keyboard.nextLine().trim();
}
//adds the appropriate type of player to the list
if (sportChoice.equalsIgnoreCase("SOCCER")) {
PlayerStats player = new Soccer();
player.getValuesFromConsole(keyboard);
team.add(player);
System.out.println(player.confirmPlayerAdd());
} else if (sportChoice.equalsIgnoreCase("PAINTBALL")) {
PlayerStats player = new Paintball();
player.getValuesFromConsole(keyboard);
team.add(player);
System.out.println(player.confirmPlayerAdd());
} else if (sportChoice.equalsIgnoreCase("BASEBALL")) {
PlayerStats player = new Baseball();
player.getValuesFromConsole(keyboard);
team.add(player);
System.out.println(player.confirmPlayerAdd());
}
keyboard.nextLine();
} // end method add
/**
* The remove method queries the user to remove a player from the
* players list. An ArrayList is used to query the statistics, searching first
* by last name and using the position of the first name to further verify
* before removing it. If successful, the player will be removed. If the
* player was not found, an error will appear and the user will be returned
* to the main menu.
* @param keyboard Scanner for user input
* @param players ArrayList of all players and their stats
*/
public static void remove(Scanner keyboard, ArrayList<PlayerStats> players) {
String lastName;
String firstName;
int indexNum;
if (players.isEmpty()) {
System.out.println("** NO RECORDS TO REMOVE! **\n");
} else {
System.out.println("Please enter the last name of the player to " + "remove:");
lastName = keyboard.nextLine().trim();
System.out.println("Please enter the first name of the player to " + "remove:");
firstName = keyboard.nextLine().trim();
indexNum = findPlayer(players, lastName, firstName);
if (indexNum == -1) {
System.out.println("** PLAYER NOT FOUND **\n");
} else {
players.remove(indexNum);
System.out.println("** REMOVED " + firstName + " " + lastName + " **\n");
}
}
} // end method remove
/**
* The show method displays a formatted table of data to the screen.
* An ArrayList holding Player objects is required for the data to show
* to the screen.
* @param players ArrayList of all players and their stats
*/
public static void show(ArrayList<PlayerStats> players) {
if (players.isEmpty()) {
System.out.println("** NO RECORDS TO SHOW **\n");
} else {
System.out.println("** SHOW ALL PLAYERS **\n");
System.out.println(sort(players));
}
} // end method show
/**
* The save method asks the user for a file name and saves all of
* the players statistics to that file. The method uses the sort method
* to make a string, which it will then print out to the file. An ArrayList
* holding Player objects is required for the data to be written to the
* file.
* @param keyboard Scanner for user keyboard
* @param players ArrayList of all players and their stats
* @throws IOException
*/
public static void save(Scanner keyboard, ArrayList<PlayerStats> players) throws IOException {
String fileName = null;
if (players.isEmpty()) {
System.out.println("** NO RECORDS TO SAVE **\n");
} else {
System.out.println("Please enter file name:");
fileName = keyboard.nextLine().trim();
FileWriter outFile = new FileWriter(fileName, true);
PrintWriter outputFile = new PrintWriter(outFile);
outputFile.println(sort(players));
System.out.println("** " + players.size() + " RECORD SAVED TO " + fileName + " **\n");
outputFile.close();
}
} // end method save
public static void load (Scanner keyboard) throws IOException{
String fileName = null;
System.out.println("Please enter a file name: ");
fileName = keyboard.nextLine().trim();
// http://download.oracle.com/javase/tutorial/essential/io/
// I thought this would be somewhat of how I should be doing it.
// Not very much help
// error checking for file name
// Needs to be better and have exception
if (fileName == null) {
System.out.println("File not found. Please choose an available file.\n");
fileName = keyboard.nextLine().trim();
}
System.out.println("Loading...");
// load the file here
/**
LOAD: Prompts the user for a filename that was created by a previous SAVE operation. The
players represented in the SAVE file that do not already exist in the current list of players are added
to the current list of players in the application. Each player may be assumed to have a unique name.
Note, neither first nor last names alone can be assumed to be unique, but the combination of both
first and last name can be assumed to be unique. E.g., Jane Doe, Jane Smith, and John Doe are all
valid unique names for players.
*/
}
/**
* The sort method sorts the list of players based on last name and sport type.
* A header is added to the beginning of the string and
* calculated averages are added to the bottom of the string. An
* ArrayList that contains Player objects is required.
* @param players ArrayList of all players and their stats
* @return a formatted list of all data and averages
*/
public static String sort(ArrayList<PlayerStats> players) {
String completeStats = "";
ArrayList<Baseball> basketballPlayers = new ArrayList<Baseball>();
ArrayList<Paintball> golfPlayers = new ArrayList<Paintball>();
ArrayList<Soccer> soccerPlayers = new ArrayList<Soccer>();
Collections.sort(players);
// make separate lists based on the type of player
for (int i = 0; i < players.size(); i++) {
if (players.get(i) instanceof Baseball) {
basketballPlayers.add((Baseball) players.get(i));
} else if (players.get(i) instanceof Paintball) {
golfPlayers.add((Paintball) players.get(i));
} else if (players.get(i) instanceof Soccer) {
soccerPlayers.add((Soccer) players.get(i));
}
}
// put all data into the string to return
if (!basketballPlayers.isEmpty()) {
completeStats = completeStats.concat(makeBasketballString(basketballPlayers) + "\n");
}
if (!golfPlayers.isEmpty()) {
completeStats = completeStats.concat(makePaintballString(golfPlayers) + "\n");
}
if (!soccerPlayers.isEmpty()) {
completeStats = completeStats.concat(makeSoccerString(soccerPlayers));
}
return completeStats;
} // end sort method
/**
* The findPlayer method searches through the players list for a specified player.
* If it is found, it will return the index in the ArrayList where the player was found.
* If the player was not found then it will return a -1.
* @param players ArrayList of all players and their data
* @param lastName last name of the player to search for
* @param firstName first name of the player to search for
* @return the index of the player found, or a -1 if not found
*/
public static int findPlayer(ArrayList<PlayerStats> team,
String lastName,
String firstName) {
int indexNum = 0;
for (int i = 0; i < team.size(); i++) {
// uses the first and last name to verify the player
if ((team.get(i).getFirstName().equals(firstName))
&& team.get(i).getLastName().equals(lastName)) {
indexNum = i;
} else {
indexNum = -1;
}
}
return indexNum;
} // end method findPlayer
/**
* The average method calculates an average and rounds up to the
* nearest hundredths place. It uses a double for the total amount that
* was summed up and the integer number amount of items the total was for.
* It returns a double that has been rounded to two decimal places.
* @param total total amount of items
* @param numberOfItems total number of items that are being averaged
* @return a double average amount, rounded to two decimal places
*/
public static double average(double total, int numberOfItems) {
return Math.round((total / (double) (numberOfItems)) * 100) / (double) 100;
} // end method average
public static String makeBasketballString(ArrayList<Baseball> baseballPlayers) {
String stats = null;
double totalOne = 0;
double totalTwo = 0;
double totalThree = 0;
stats = "\t\t** BASEBALL PLAYERS **\n";
for (int i = 0; i < baseballPlayers.size(); i++) {
stats = stats.concat(baseballPlayers.get(i).toString());
stats = stats.concat("\n");
}
stats = stats.concat("Total Records: " + baseballPlayers.size() + "\n");
// find the totals for baseball players
for (int i = 0; i < baseballPlayers.size(); i++) {
totalOne += baseballPlayers.get(i).getPointsScored();
totalTwo += baseballPlayers.get(i).getOuts();
totalThree += baseballPlayers.get(i).getBattingAverage();
}
// put the averages at the end
stats = stats.concat("AVERAGES\tPoints: "
+ average(totalOne, baseballPlayers.size())
+ " Homeruns: "
+ average(totalTwo, baseballPlayers.size())
+ " Batting Average %: "
+ average(totalThree, baseballPlayers.size())
+ "\n");
return stats;
}
public static String makePaintballString(ArrayList<Paintball> paintballPlayers) {
String stats = null;
double totalOne = 0;
double totalTwo = 0;
double totalThree = 0;
stats = "\t\t** PAINTBALL PLAYERS **\n";
for (int i = 0; i < paintballPlayers.size(); i++) {
stats = stats.concat(paintballPlayers.get(i).toString());
stats = stats.concat("\n");
}
stats = stats.concat("Total Records: " + paintballPlayers.size() + "\n");
// find the totals for paintball players
for (int i = 0; i < paintballPlayers.size(); i++) {
totalOne += paintballPlayers.get(i).getPointsScored();
totalTwo += paintballPlayers.get(i).getHeadShots();
totalThree += paintballPlayers.get(i).getBallsPerSecond();
}
// put the averages at the end
stats = stats.concat("AVERAGES\tPoints: "
+ average(totalOne, paintballPlayers.size())
+ " Head Shots: "
+ average(totalTwo, paintballPlayers.size())
+ " Balls Per Second: "
+ average(totalThree, paintballPlayers.size())
+ "\n");
return stats;
} // end makePaintballString
public static String makeSoccerString(ArrayList<Soccer> soccerPlayers) {
String stats = null;
double totalOne = 0;
double totalTwo = 0;
double totalThree = 0;
stats = stats = "\t\t** SOCCER PLAYERS **\n";
for (int i = 0; i < soccerPlayers.size(); i++) {
stats = stats.concat(soccerPlayers.get(i).toString());
stats = stats.concat("\n");
}
stats = stats.concat("Total Records: " + soccerPlayers.size() + "\n");
// find the totals for soccer players
for (int i = 0; i < soccerPlayers.size(); i++) {
totalOne += soccerPlayers.get(i).getPointsScored();
totalTwo += soccerPlayers.get(i).getAssists();
totalThree += soccerPlayers.get(i).getPenaltyKickRate();
}
// put the averages at the end
stats = stats.concat("AVERAGES\tPoints: "
+ average(totalOne, soccerPlayers.size())
+ " Assists: "
+ average(totalTwo, soccerPlayers.size())
+ " Penalty Kick %: "
+ average(totalThree, soccerPlayers.size())
+ "\n");
return stats;
} // end makeSoccerString
} // end class Main
Player Class:
package cs241project2;
/**
* The Player class creates Player objects based on a player's first and
* last names, the points scored, assists made, and the penalty kick rate
* percentage. It uses basic mutators to construct the object. Public
* accessors are available to view all of the data for the particular player.
* A toString method is provided to create strings of data that contain the
* player's data separated by commas, including the full name, points scored,
* assists made, and the penalty kick rate.
* @author 24x24
*/
public class Player
{
private String lastName;
private String firstName;
private int pointsScored;
private int assists;
private double penaltyKickRate;
/**
* The Player constructor creates a player based on their first name,
* last name, points scored, assists made, and the penalty kick rate. Basic
* mutators are used to construct the object. It requires strings of the
* first and last name, integers for points scored and assists made, and
* a double for the penalty kick rate.
* @param lastName the last name of the player
* @param firstName the first name of the player
* @param pointsScored the points scored by the player
* @param assists the assists made by the player
* @param penaltyKickRate penalty kick rate of the player
*/
public Player(String lastName, String firstName, int pointsScored,
int assists, double penaltyKickRate)
{
this.setLastName(lastName);
this.setFirstName(firstName);
this.setPointsScored(pointsScored);
this.setAssists(assists);
this.setPointsScored(pointsScored);
this.setPenaltyKickRate(penaltyKickRate);
} // end constructor Player
// ------------------
// Methods
// ------------------
/**
* The private method setLastName is used by the Player constructor as
* a mutator method to set the last name of the player. A string for the
* last name is required by the method.
* @param lastName the last name of the player
*/
private void setLastName(String lastName)
{
this.lastName = lastName;
} // end method setLastName
/**
* The private method setFirstName is used by the Player constructor as
* a mutator method to set the first name of the player. A string for the
* first name is required by the method.
* @param firstName the first name of the player
*/
private void setFirstName(String firstName)
{
this.firstName = firstName;
} // end method setFirstName
/**
* The private method setPointsScored is used by the Player constructor as
* a mutator method to set the points scored by the player. An integer
* for the amount of points scored is required by the method.
* @param pointsScored the amount of points scored by the player
*/
private void setPointsScored(int pointsScored)
{
this.pointsScored = pointsScored;
} // end method setPointsScored
/**
* The private method setAssists is used by the Player constructor as
* a mutator method to set the assists made by the player. An integer
* for the amount of assists made is required by the method.
* @param assists the amount of assists made by the player
*/
private void setAssists(int assists)
{
this.assists = assists;
} // end method setAssists
/**
* The private method setPenaltyKickRate is used by the Player constructor
* as a mutator method to set the penalty kick rate of the player. A double
* for the penalty kick rate (as a percentage) is required by the method.
* @param penaltyKickRate the rate of successful penalty kicks
*/
private void setPenaltyKickRate(double penaltyKickRate)
{
this.penaltyKickRate = penaltyKickRate;
} // end method setPenaltyKickRate
/**
* The getLastName method returns the last name of the player.
* @return the last name of the player
*/
public String getLastName()
{
return this.lastName;
} // end method getLastName
/**
* The getFirstName method returns the first name of the player.
* @return the first name of the player
*/
public String getFirstName()
{
return this.firstName;
} // end method getFirstName
/**
* The getPointsScored method returns the points scored by the player.
* @return number of points scored by the player
*/
public int getPointsScored()
{
return this.pointsScored;
} // end method getPointsScored
/**
* The getAssists method returns the assists made by the player.
* @return number of assists made by the player
*/
public int getAssists()
{
return this.assists;
} // end method getAssists
/**
* The getPenaltyKickRate method returns the penalty kick rate of the
* player.
* @return penalty kick rate of the player, in the form of a decimal
*/
public double getPenaltyKickRate()
{
return this.penaltyKickRate;
} // end method getPenaltyKickRate
} // end class Player
Player Stats Class:
package cs241project2;
import java.util.*;
/**
* The Player class creates Player objects based on a player's first and
* last names, the points scored, assists made, and the penalty kick rate
* percentage. It uses basic mutators to construct the object. Public
* accessors are available to view all of the data for the particular player.
* A toString method is provided to create strings of data that contain the
* player's data separated by commas, including the full name, points scored,
* assists made, and the penalty kick rate.
* @author 24x24
*/
public class PlayerStats implements Comparable {
private String lastName;
private String firstName;
private int pointsScored;
private String input;
/**
* The Player constructor creates a player based on their first name,
* last name, points scored. Basic mutators are used to construct the object.
* It requires strings of the first and last name and integers for points scored.
* @param lastName the last name of the player
* @param firstName the first name of the player
* @param pointsScored the points scored by the player
*/
public PlayerStats(String lastName, String firstName, int pointsScored) {
this.setLastName(lastName);
this.setFirstName(firstName);
this.setPointsScored(pointsScored);
} // end constructor Player
public PlayerStats() {
}
// ------------------
// Methods
// ------------------
public void getValuesFromConsole(Scanner input) {
System.out.println("Please enter the player's last name: ");
lastName = input.nextLine().trim();
// Need to find a way to not work with numbers
// Also find a way to allow ' and - but no other symbols
System.out.println("Please enter the player's first name: ");
firstName = input.nextLine().trim();
// Need to find a way to not work with numbers
// Also find a way to allow ' and - but no other symbols
System.out.println("Please enter the number of points scored for "
+ firstName + " " + lastName + ": ");
try {
pointsScored = input.nextInt();
while (pointsScored < 0) {
System.out.println("Please enter a non-negative number: ");
pointsScored = input.nextInt();
}
} catch (RuntimeException e) {
System.out.println("Please enter a number: ");
// pointsScored = input.nextInt();
}
//***********************
while (input.hasNextLine()) {
try {
if (pointsScored < 0) {
System.out.print("Please choose a positive number: ");
} else { /* Do stuff */ }
} catch (NumberFormatException e) {
pointsScored = 0;
}
}
//***********************
}
public String confirmPlayerAdd() {
return null;
}
/**
* The private method setLastName is used by the Player constructor as
* a mutator method to set the last name of the player. A string for the
* last name is required by the method.
* @param lastName the last name of the player
*/
private void setLastName(String lastName) {
this.lastName = lastName;
} // end method setLastName
/**
* The private method setFirstName is used by the Player constructor as
* a mutator method to set the first name of the player. A string for the
* first name is required by the method.
* @param firstName the first name of the player
*/
private void setFirstName(String firstName) {
this.firstName = firstName;
} // end method setFirstName
/**
* The private method setPointsScored is used by the Player constructor as
* a mutator method to set the points scored by the player. An integer
* for the amount of points scored is required by the method.
* @param pointsScored the amount of points scored by the player
*/
private void setPointsScored(int pointsScored) {
this.pointsScored = pointsScored;
} // end method setPointsScored
/**
* The getLastName method returns the last name of the player.
* @return the last name of the player
*/
public String getLastName() {
return this.lastName;
} // end method getLastName
/**
* The getFirstName method returns the first name of the player.
* @return the first name of the player
*/
public String getFirstName() {
return this.firstName;
} // end method getFirstName
/**
* The getPointsScored method returns the points scored by the player.
* @return number of points scored by the player
*/
public int getPointsScored() {
return this.pointsScored;
} // end method getPointsScored
@Override
public String toString() {
return this.firstName + " " + this.lastName + ":\t";
} // end toString
public int compareTo(Object o) {
PlayerStats c = (PlayerStats) o;
int nameCompare = lastName.compareTo(c.lastName);
return nameCompare != 0 ? nameCompare : lastName.compareTo(c.lastName);
} // end compareTo
} // end class Player
One of the sport classes (Polymorphism and all that means I shouldn't need to post the others, right?):
package cs241project2;
import java.util.Scanner;
/**
* @author 24x24
*/
public class Soccer extends PlayerStats {
private int assists;
private double penaltyKickRate;
/**
* The Player constructor creates a player based on their first name,
* last name, points scored, assists made, and the penalty kick rate. Basic
* mutators are used to construct the object. It requires strings of the
* first and last name, integers for points scored and assists made, and
* a double for the penalty kick rate.
* @param lastName the last name of the player
* @param firstName the first name of the player
* @param pointsScored the points scored by the player
* @param assists the assists made by the player
* @param penaltyKickRate penalty kick rate of the player
*/
public Soccer(String lastName, String firstName, int pointsScored, int assists, double penaltyKickRate) {
super(lastName, firstName, pointsScored);
setAssists(assists);
setPenaltyKickRate(penaltyKickRate);
} //end constructor Player
public Soccer() {
} // end of basic constructor
// ------------------
// Methods
// ------------------
@Override
public void getValuesFromConsole(Scanner input) {
super.getValuesFromConsole(input);
System.out.println("Please enter the number of assists for " + super.getFirstName() + " " + super.getLastName() + ": ");
assists = input.nextInt();
while (assists < 0){
System.out.println("Please enter a non-negative number: ");
assists = input.nextInt();
}
System.out.println("Please enter the penalty kick percentage (example 0.25 for 25%) for " + super.getFirstName() + " " + super.getLastName() + ": ");
penaltyKickRate = input.nextDouble();
while (penaltyKickRate < 0){
System.out.println("Please enter a non-negative number: ");
penaltyKickRate = input.nextInt();
}
} // end method getValuesFromConsole
@Override
public String confirmPlayerAdd() {
return "** PLAYER ADDED **\n " + super.getFirstName() + " " + super.getLastName() + "\tPoints: "
+ super.getPointsScored() + "\tAssists: " + assists + "\tPenalty Kick %: "
+ penaltyKickRate + "\n";
} // end method confirmPlayerAdd
/**
* The private method setPenaltyKickRate is used by the Soccer
* constructor as a mutator method to set the penalty kick rate of the
* player. A double for the penalty kick rate (as a percentage) is
* required by the method.
* @param penaltyKickRate the rate of successful penalty kicks
*/
private void setPenaltyKickRate(double penaltyKickRate) {
this.penaltyKickRate = penaltyKickRate;
} // end method setPenaltyKickRate
/**
* The private method setAssists is used by the Soccer
* constructor as a mutator method to set the assists made by the player.
* An integer for the amount of assists made is required by the method.
* @param assists the amount of assists made by the player
*/
private void setAssists(int assists) {
this.assists = assists;
} // end method setAssists
/**
* The getAssists method returns the assists made by the player.
* @return number of assists made by the player
*/
public int getAssists() {
return this.assists;
} // end method getAssists
/**
* The getPenaltyKickRate method returns the penalty kick rate of the
* player.
* @return penalty kick rate of the player, in the form of a decimal
*/
public double getPenaltyKickRate() {
return this.penaltyKickRate;
} // end method getPenaltyKickRate
@Override
public String toString() {
return super.toString() + "Points: " + super.getPointsScored()
+ " Assists: " + getAssists() + " Penalty Kick %: "
+ getPenaltyKickRate();
} // end toString method
} // end class Soccer
I'll be working on this all day being that it is due tonight so I will post if I have any results. I do have an exam in the middle of the day but I will get back to the code right after that. Thanks for any and all help that you can give. Also if you do need to see the paintball and baseball classes I can post those but all I did with those is change what stat it asked for. I figured I could save some space without repeating code.