Question: For this exercise, you are given a Team superclass with a BaseballTeam and FootballTeam subclass. Take a moment to examine these classes and the instance

For this exercise, you are given a Team superclass with a BaseballTeam and FootballTeam subclass. Take a moment to examine these classes and the instance variables and methods in each.

In the TeamTester class, you will see three objects declared and instantiated using the Team, FootballTeam, or BaseballTeam classes.

For each object, print out all available information that you can get from the getters or the toString.

Hint: Remember, for the program to compile and run, Java looks for methods to exist in certain classes.

public class Team {

private String name; private String location; private int wins; private int losses;

public Team(String name, String location, int wins, int losses) { this.name = name; this.location = location; this.wins = wins; this.losses = losses; }

public String getName() { return name; }

public void setName(String name) { this.name = name; }

public String getLocation() { return location; }

public void setLocation(String location) { this.location = location; }

public int getWins() { return wins; }

public void setWins(int wins) { this.wins = wins; }

public int getLosses() { return losses; }

public void setLosses(int losses) { this.losses = losses; }

public String toString(){ return wins + " - " + losses; } }

public class BaseballTeam extends Team {

private String league;

public BaseballTeam(String name, String location, int wins, int losses, String league) { super(name, location, wins, losses); this.league = league; }

public String getLeague() { return league; }

public void setLeague(String league) { this.league = league; }

}

public class TeamTester {

public static void main(String[] args) { FootballTeam dolphins = new FootballTeam("Dolphins", "Miami", 8, 4, 1); Team cubs = new BaseballTeam("Cubs", "Chicago", 80, 65, "National"); Team lizards = new Team("Lizards", "New York", 9, 5);

//Print out all available information for the Dolphins

//Print out all available information for the Cubs

//Print out all available information for the Lizards

} }

public class FootballTeam extends Team {

private int ties;

public FootballTeam(String name, String location, int wins, int losses, int ties) { super(name, location, wins, losses); this.ties = ties; }

public int getTies() { return ties; }

public void setTies(int ties) { this.ties = ties; }

@Override public String toString(){ return super.getWins() + " - " + super.getLosses() + " - " + ties; } }

For this exercise, you are given a Team superclass with a BaseballTeamand FootballTeam subclass. Take a moment to examine these classes and theinstance variables and methods in each. In the TeamTester class, you willsee three objects declared and instantiated using the Team, FootballTeam, or BaseballTeam

COM Which Team? CodeHS C Get Homework Help With Chegg X + c codehs.com/student/2052620/section/164847/assignment/28754623/ : Sandbox My Sections Practice + Resume All Waseem Status: Not Submitted 9.6.6: Which Team? Save Submit + Continue RUN CODE TEST CASES ASSIGNMENT DOCS | GRADE MORE 5 points Status: Not Submitted FILES For this exercise, you are given a Team superclass with a Baseballteam and FootballTeam subclass. Take a moment to examine these classes and the instance variables and methods in each. Team.java In the TeamTester class, you will see three objects declared and instantiated using the Team, FootballTeam, or Baseballteam classes. Baseball Team.java L TeamTester.java For each object, print out all available information that you can get from the getters or the toString. Football Team.java 1- public class Team { 2 3 private String name; 4 private String location; 5 private int wins; 6 private int losses; 7 8- public Team(String name, String location, int wins, int losses) { 9 this.name = name; 10 this. location = location; 11 this.wins = wins; 12 this. losses = losses; 13 } 14 15 - public String getName() { 16 return name; 17 } 18 19- public void setName(String name) { 20 this.name = name; 21 } 22 23 public String getLocation() { 24 return location; 25 } 26 27 public void setLocation(String location) { 28 this. location = location; Hint: Remember, for the program to compile and run, Java looks for methods to exist in certain classes. Inheritance 9.1 9. 9.3 9.4 9.5 9.7 9.8 O Sign out 0 i 2:20 COM Which Team? CodeHS C Get Homework Help With Chegg X + c codehs.com/student/2052620/section/164847/assignment/28754623/ : Sandbox My Sections Practice + Resume All Waseem Status: Not Submitted 9.6.6: Which Team? Save Submit + Continue RUN CODE TEST CASES ASSIGNMENT DOCS | GRADE MORE 5 points Status: Not Submitted FILES For this exercise, you are given a Team superclass with a Baseballteam and FootballTeam subclass. Take a moment to examine these classes and the instance variables and methods in each. 6 Team.java In the TeamTester class, you will see three objects declared and instantiated using the Team, FootballTeam, or BaseballTeam classes. Baseball Team.java 1. public class Baseballteam extends Team { 2 3 private String league; 4 5 public BaseballTeam(String name, String location, int wins, int losses, String league) { 7 super (name, location, wins, losses); 8 this. league = league; 9 } 10 11 - public String get League() { 12 return league ; 13 } 14 15 - public void setLeague(String league) { 16 this.league = league; 17 } 18 19 } 20 L TeamTester.java For each object, print out all available information that you can get from the getters or the toString. Football Team.java Hint: Remember, for the program to compile and run, Java looks for methods to exist in certain classes.

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