Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need help creating the last class (FantasyFootballTester) of the program below. I also get an error in the FantasyFootballTeam class, findPlayerbyPosition, where FootBallPlayer is
I need help creating the last class (FantasyFootballTester) of the program below. I also get an error in the FantasyFootballTeam class, findPlayerbyPosition, where FootBallPlayer is underlined saying "FootBallPlayer cannot be resolved to a variable" ?
FootBallPlayer.java
public abstract class FootBallPlayer implements Comparable{ private String playerName; private Position pos; private String team; private int noOfGames; public enum Position { quarterBack, runningBack, defensiveBack }; public FootBallPlayer() { this.pos=null; this.playerName = ""; this.noOfGames = 0; this.team=""; } public FootBallPlayer(String playerName,Position pos,String team, int noOfGames) { this.pos=pos; this.playerName = playerName; this.noOfGames = noOfGames; this.team=team; } abstract int playersRating(); @Override public int compareTo(FootBallPlayer o) { return this.playersRating()-o.playersRating(); } public String getPlayerName() { return playerName; } public Position getPos() { return pos; } public String getTeam() { return team; } public int getNoOfGames() { return noOfGames; } public void setPlayerName(String playerName) { this.playerName = playerName; } public void setPos(Position pos) { this.pos = pos; } public void setTeam(String team) { this.team = team; } public void setNoOfGames(int noOfGames) { this.noOfGames = noOfGames; } @Override public String toString() { return "Name: "+playerName+",Position: "+pos.toString()+", NFL Team: "+team; } }
QuarterBack.java
public class QuarterBack extends FootBallPlayer { private int passAttempted; private int passCompleted; private int touchdownsPassing; private int totalyardsPassing; public QuarterBack() { super(); this.passAttempted = 0; this.passCompleted = 0; this.touchdownsPassing = 0; this.totalyardsPassing = 0; } public QuarterBack(String playerName, Position pos, String team, int noOfGames, int passAttempted, int passCompleted, int touchdownsPassing, int totalyardsPassing) { super(playerName, pos, team, noOfGames); this.passAttempted = passAttempted; this.passCompleted = passCompleted; this.touchdownsPassing = touchdownsPassing; this.totalyardsPassing = totalyardsPassing; } double completionPercentage(){ double val = (passCompleted/passAttempted); return val; } double averagePassingyardsPerGame(){ double val = (totalyardsPassing/getNoOfGames()); return val; } double averageTouchDownsPerGame(){ double val = (touchdownsPassing/getNoOfGames()); return val; } public int getPassAttempted() { return passAttempted; } public int getPassCompleted() { return passCompleted; } public int getTouchdownsPassing() { return touchdownsPassing; } public int getTotalyardsPassing() { return totalyardsPassing; } public void setPassAttempted(int passAttempted) { this.passAttempted = passAttempted; } public void setPassCompleted(int passCompleted) { this.passCompleted = passCompleted; } public void setTouchdownsPassing(int touchdownsPassing) { this.touchdownsPassing = touchdownsPassing; } public void setTotalyardsPassing(int totalyardsPassing) { this.totalyardsPassing = totalyardsPassing; } @Override int playersRating() { int val = (int)(averageTouchDownsPerGame()+averagePassingyardsPerGame()/5+completionPercentage()*100); return val; } @Override public String toString() { return super.toString()+" "+" Completion Percentage: "+completionPercentage()+", Average passing yards per game :"+averagePassingyardsPerGame()+ ",Average touchdowns per game: "+averageTouchDownsPerGame()+", player's rating: "+playersRating(); } }
RunningBack.java
public class RunningBack extends FootBallPlayer { private int runningAttempts; private int totallRunningYards; private int totalTouchdowns; public RunningBack() { super(); this.runningAttempts = 0; this.totallRunningYards = 0; this.totalTouchdowns = 0; } public RunningBack(String playerName, Position pos, String team, int noOfGames, int runningAttempts, int totallRunningYards, int totalTouchdowns) { super(playerName, pos, team, noOfGames); this.runningAttempts = runningAttempts; this.totallRunningYards = totallRunningYards; this.totalTouchdowns = totalTouchdowns; } double averageYardsPerAttempt() { double val = (totallRunningYards / runningAttempts); return val; } double averageYardsPerGame() { double val = (totallRunningYards / getNoOfGames()); return val; } double averageTouchDownsPerGame() { double val = (totalTouchdowns / getNoOfGames()); return val; } public int getRunningAttempts() { return runningAttempts; } public int getTotallRunningYards() { return totallRunningYards; } public int getTotalTouchdowns() { return totalTouchdowns; } public void setRunningAttempts(int runningAttempts) { this.runningAttempts = runningAttempts; } public void setTotallRunningYards(int totallRunningYards) { this.totallRunningYards = totallRunningYards; } public void setTotalTouchdowns(int totalTouchdowns) { this.totalTouchdowns = totalTouchdowns; } @Override int playersRating() { int val = (int) (averageTouchDownsPerGame() + averageYardsPerGame() / 5 + averageYardsPerAttempt()); return val; } @Override public String toString() { return super.toString() + " " + " AverageYardsPerGame: " + averageYardsPerGame() + ", Average yards per attempt :" + averageYardsPerAttempt() + ",Average touchdowns per game: " + averageTouchDownsPerGame() + ", player's rating: " + playersRating(); } }
DefenciveBack.java
public class DefensiveBack extends FootBallPlayer { private int tackles; private int interceptions; private int forcedFumbles; public DefensiveBack() { super(); this.tackles = 0; this.interceptions = 0; this.forcedFumbles = 0; } public DefensiveBack(String playerName, Position pos, String team, int noOfGames, int tackles, int interceptions, int forcedFumbles) { super(playerName, pos, team, noOfGames); this.tackles = tackles; this.interceptions = interceptions; this.forcedFumbles = forcedFumbles; } double averageTacklesPerGame() { double val = (tackles / getNoOfGames()); return val; } double averageInterceptionsPerGame() { double val = (interceptions / getNoOfGames()); return val; } double averageForcedFumblesPerGame() { double val = (forcedFumbles / getNoOfGames()); return val; } public int getTackles() { return tackles; } public int getInterceptions() { return interceptions; } public int getForcedFumbles() { return forcedFumbles; } public void setTackles(int tackles) { this.tackles = tackles; } public void setInterceptions(int interceptions) { this.interceptions = interceptions; } public void setForcedFumbles(int forcedFumbles) { this.forcedFumbles = forcedFumbles; } @Override int playersRating() { int val = (int) (averageInterceptionsPerGame() + averageForcedFumblesPerGame() / 5 + averageTacklesPerGame()); return val; } @Override public String toString() { return super.toString() + " " + " AverageTacklesPerGame: " + averageTacklesPerGame() + ", Average interceptions per game :" + averageInterceptionsPerGame() + ",Average force fumbles per game: " + averageForcedFumblesPerGame() + ", player's rating: " + playersRating(); } }
FantasyFootball Team.java File: import java.util.Arrays; public class FantasyFootball Team { private String teamName; private String teamOwner; private FootballPlayer(footballPlayers; private int index; public Fantasy Football Team(String teamName, String teamOwner, int size OfTeam) { this.setTeamName(teamName); this.setTeamOwner(team Owner); // Creates array with size this.footballPlayers = new FootballPlayer(size OfTeam]; this.index = 0; } public String getTeamName() { return teamName; } public void setTeamName(String teamName) { this.teamName = teamName; I } public String getTeamOwner() { return teamOwner; } public void setTeamOwner(String teamOwner) { this.teamOwner = teamOwner: } public void addPlayer(FootballPlayer player) { if(player != null && index
Step 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