Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Create a class to hold data about a high school sports team. The Team class holds data fields for high school name (such as

1. Create a class to hold data about a high school sports team. The Team class holds data fields for high school name (such as Roosevelt High), sport (such as Girls Basketball), and team name (such as Dolphins). Include a constructor that takes parameters for each field, and include get methods that return the values of the fields. Also include a public final static String named MOTTO and initialize it to Sportsmanship!.

2. Create a class named Game. Include two Team fields that hold data about the teams participating in the game. Also include a field for game time (for example, 7 PM). Include a constructor that takes parameters for two Team objects and a time.

public class Game {

private Team team1;

private Team team2;

private String time;

public Game(Team t1, Team t2, String time) {

}

public Team getTeam1() {

}

public Team getTeam2() {

}

public String getTime() {

}

}

public class Team {

private String name;

private String sport;

private String mascot;

public final static String MOTTO = "Sportsmanship!";

public Team(String name, String sport, String mascot) {

}

public String getName() {

}

public String getSport() {

}

public String getMascot() {

}

}

public class TestGame

{

public static void main(String[] args)

{

Team team1 = new Team("Roosevelt High", "Girls Basketball", "Dolphins");

Team team2 = new Team("Hoover High", "Girls Basketball", "Tigers");

Game game1 = new Game(team1, team2, "7 PM");

display(game1);

}

public static void display(Game g)

{

Team t1 = g.getTeam1();

Team t2 = g.getTeam2();

System.out.println("The game between " + t1.getName() + " " + t1.getSport() + " " + t1.getMascot());

System.out.println(" and " + t2.getName() + " " + t2.getSport() + " " + t2.getMascot());

System.out.println(" takes place at " + g.getTime());

}

}

public class TestTeam

{

public static void main(String[] args)

{

Team team1 = new Team("Roosevelt High", "Girls Basketball", "Dolphins");

Team team2 = new Team("Hoover High", "Boys Wrestling", "Tigers");

Team team3 = new Team ("Lincoln High", "Girls Field Hockey", "Gators");

display(team1);

display(team2);

display(team3);

}

public static void display(Team t)

{

System.out.println(t.getName() + " " + t.getSport() + " team " + t.getMascot() + " Our motto is " + t.MOTTO);

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions