Question

java

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 name1198965d-7188-45cd-b25f-3bf067a732f8.png

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please upvote!

Check out the solution and let me know if you have any queries through COMMENTS.

___________

public class Game {
private Team team1;
private Team team2;
private String time;
public Game(Team team1, Team team2, String time) {
this.team1 = team1;
this.team2 = team2;
this.time = time;
}
public Team getTeam1() {
return team1;
}
public Team getTeam2() {
return team2;
}
public String getTime() {
return time;
}
} // class ends



public class Team {
private String name;
private String sport;
private String mascot;
public final static String MOTTO = "Sportmanship!";
public Team(String name, String sport, String mascot) {
this.name = name;
this.sport = sport;
this.mascot = mascot;
}
public String getName() {
return name;
}
public String getSport() {
return sport;
}
public String getMascot() {
return mascot;
}
} // class ends


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());
}
} // class ends


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() + "\n Our motto is " + t.MOTTO);
}
} // class ends

_______

answered by: Book Solutions
Add a comment
Answer #2

answered by: Book Solutions
Add a comment
Know the answer?
Add Answer to:
java
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a class Team to hold data about a college sports team. The Team class holds...

    Create a class Team to hold data about a college sports team. The Team class holds data fields for college name (such as Hampton College), sport (such as Soccer), and team name (such as Tigers). Include a constructor that takes parameters for each field, and get methods that return the values of the fields. Also include a public final static String named MOTTO and initialize it to Sportsmanship! Save the class in Team.java. Create a UML class diagram as well.

  • Winning-team data were collected for teams in different sports, with the results given in the accompanying...

    Winning-team data were collected for teams in different sports, with the results given in the accompanying table. Use a 0.05 significance to test the claim that home/ visitor wins are independent of the sport. Please show ALL steps. 4-Winning-team data were collected for teams in different sports, with the results given in the accompanying table. Use a 0.05 significance to test the claim that homel visitor wins are independent of the sport. Home team wins Basketball Baseball Hockey Football 127...

  • Create a C# Console program. Add a class named Employee that has the following public fields:...

    Create a C# Console program. Add a class named Employee that has the following public fields: • Name. The name field references a String object that holds the employee’s name. • IDNumber. The IDNumber is an int that holds the employee’s ID number. • Department. The department field is a String that holds the name of the department where the employee works. • Position. The position field is a String that holds the employee’s job title. Once you have written...

  • U Winning team data were collected for teams in different sports, with the results given in...

    U Winning team data were collected for teams in different sports, with the results given in the table below. Use TH-43/34 PLUS the TH-6384 Plus results at 0.05 level of significance to test the claim that home visitor wins we Independent of the sport Y - Test Y-5.344751050 -0.142241792 ar Hockey Football Home team wins 113 57 42 40 Visiting team wins 00 39 51 33 the null hypothesis that home visitor wins are independent of the sport. It appears...

  • WRITE THE PROGRAM IN JAVA. gram 3: Olympians I C 1 Goals To write your own...

    WRITE THE PROGRAM IN JAVA. gram 3: Olympians I C 1 Goals To write your own class in a program To write a constructor with parameters, an method and a toString) method. To use ArrayList To use a for-each loo . p *l . To use text file for output 2 The Context This is a single-class project, the first for which I have not given you code to start from. It is not realistic, or useful, but it gives...

  • You are building a system to keep track of matches played by a soccer team. You...

    You are building a system to keep track of matches played by a soccer team. You need to create a class to represent your matches. Call this class Soccer Match. The class will have the following data fields and methods: • A Date data field called startTime to register the date and time for the start of the match. • A Date data field called endTime to register the date and time for the end of the match. A String...

  • marks) Ben runs a sports program for high school students. Each student that ooses one of...

    marks) Ben runs a sports program for high school students. Each student that ooses one of the following three sports: volleyball, basketball and netball. The heights of the first 15 students, and the sports they chose, were Volleyball 183, 176, 170, 179 Basketball 165, 169, 171, 154, 165, 159 Netball 167, 160, 177, 173, 170 Ben runs an analysis of variance with these data. A partially complete ANOVA table from his analysis is given below. Source df SS MS F...

  • 2. Create a class named Student that contains the following » idStudent. The idStudent is an...

    2. Create a class named Student that contains the following » idStudent. The idStudent is an int variable that holds the student's matric number. name. The name field references a String object holds the student's name. . major. The major field references a String object holds the student's major. . classification. The classification field references a String object holds the student's classification level (bongsu, kecil, muda, sulung) . Constructor should accept the student's matric number, name, major and classification as...

  • Write a Gui programming by using JavaFx menus, stage and screen concepts to the RetailItem class,...

    Write a Gui programming by using JavaFx menus, stage and screen concepts to the RetailItem class, Write a class named Retailltem that holds data about an item in a retail store. The class should have the following fields description: The description field is a String object that holds a brief description of the item . unitsOnHand: The unitsOnHand field is an int variable that holds the number of units currently in inventory Price: The price field is a double that...

  • List the independent and dependent variables for each research experiment below: a. Who has more team...

    List the independent and dependent variables for each research experiment below: a. Who has more team spirit: college football fans or college basketball fans? To find out, we visit ten colleges that have both football and basketball teams. We go to games and count how many people are wearing team colors or logos. The variables are sport (football or basketball) and percent wearing school colors/logos. b. A legislator in DC says that teachers need to be paid on a sliding...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT