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, use a print statement to print out any public method that returns information that is available for that particular object, including the toString. For example, the dolphin object is a FootballTeam object. One of the pieces of information that can be printed is the getTies() method, so you will call that method in your TeamTester file: System.out.println(dolphins.getTies()); Do this for all the methods that each of the objects can call. 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 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; } } ================================= 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 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; } }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
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 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, use a print statement to print out any public method that returns information that is available for that particular object, including the toString.

For example, the dolphin object is a FootballTeam object. One of the pieces of information that can be printed is the getTies() method, so you will call that method in your TeamTester file:

System.out.println(dolphins.getTies());

Do this for all the methods that each of the objects can call.

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 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;
}
}

=================================

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 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;
}

}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Software Development
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education