Question: FantasyFootballTeam Class Methods: PLEASE HELP MAKE EXCEPTIONS 1. addPlayer 1. Takes in a FootBallPlayer object and adds it to the Array. 2. Ensures the parameter

FantasyFootballTeam Class Methods: PLEASE HELP MAKE EXCEPTIONS 1. addPlayer 1. Takes in a FootBallPlayer object and adds it to the Array. 2. Ensures the parameter is not null and the array is not full. 3. Throws user-defined exceptions (one exception for each error) 1. if array is full 2. if parameter is null.

2. findPlayerbyPosition 1. search the array for all players at a particular position (ignores case) 2. returns a string of all the players at that position or a string stating no players at that position. Such as No player at QuarterBack found.


3. toString - a String representation of the object. See sample run below for format. 4. Two user Defined exceptions classes to handle 1. Array is full 2. Football player object is null.


FantasyFootballTeam.java

public class FantasyFootballTeam{    private String owner;  private String name;  private FootballPlayer fbArray[];  private int index;    public FantasyFootballTeam() {  owner = "";  name = "";  }  public FantasyFootballTeam(String name, String owner, int size) {  this.owner = owner;  this.name = name;  this.fbArray =  new FootballPlayer[size];  this.index = 0;  }    public String getName() {  return name;  }  public void setName(String name) {  this.name = name;  }  public String getOwner() {  return owner;  }  public void setOwner(String owner) {  this.owner = owner;  }  //ADD EXCEPTION  public void addPlayer(FootballPlayer player) {   if(player != null && index < fbArray.length) {  fbArray[index] = player;  index++;  }else{              System.out.println("Unable to add player.");  }  }  //ADD EXCEPTION  public String findPlayerbyPosition(String position) {  String allPlayers = "";          for(int i = 0; i < index; i++){                  if(fbArray[i].getPost() == position) {                          allPlayers += fbArray[i].toString() + "\n";                  }          }          if(allPlayers == ""){                  allPlayers = "No player found at: " + position + "\n";          }          return allPlayers;  }  @Override      public String toString() {                String allString = "Team Name: " + this.getName() +              " Owner: " + this.getOwner() + "\n\n";              for(int i = 0; i < index; i++) {                      allString += fbArray[i].toString() + "\n";              }              return allString;      }    }   

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 Programming Questions!