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!.
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.
Program Screen Shot:




Sample output:
Program code to copy:
// The 'Team' class that holds high school sports team data
class Team{
// required fields (data members) as specified in the statement
private String highSchoolName;
private String sport;
private String teamName;
// A public final static String named MOTTO and initialize it to Sportsmanship!
public final static String MOTTO = "Sportsmanship!";
// A constructor that takes parameters for each field & initializes all of them
public Team(String highSchoolName, String sport, String
teamName) {
this.highSchoolName = highSchoolName;
this.sport = sport;
this.teamName = teamName;
}
// Get methods for all fields
public String getHighSchoolName() {
return highSchoolName;
}
public String getSport() {
return sport;
}
public String getTeamName() {
return teamName;
}
}
// The 'Game' class according to requirements of the question
class Game{
// Two team fields that holds data about teams participating in the game
private Team teamA;
private Team teamB;
// A field for game time
private String gameTime;
// A constructor that takes parameters for two Team objects and a time
public Game(Team teamA, Team teamB, String gameTime) {
this.teamA = teamA;
this.teamB = teamB;
this.gameTime = gameTime;
}
// All Get & set methods for all fields
public Team getTeamA() {
return teamA;
}
public void setTeamA(Team teamA) {
this.teamA = teamA;
}
public Team getTeamB() {
return teamB;
}
public void setTeamB(Team teamB) {
this.teamB = teamB;
}
public String getGameTime() {
return gameTime;
}
public void setGameTime(String gameTime) {
this.gameTime = gameTime;
}
// A toString() to show information of match time & both teams
public String toString() {
return
"\n\n\n\t\t\t\t\t********************
"+Team.MOTTO+"\t"+getGameTime()+" *****************\n"+
"\n\n\t\t\t\t\t"+teamA.getTeamName()+"\t\t\tVS\t\t\t"+teamB.getTeamName()+"\n"+
"\t\t\t\t\t"+teamA.getHighSchoolName()+"\t|\t"+teamB.getHighSchoolName()+"\n"+
"\t\t\t\t\t"+teamA.getSport()+"\t|\t"+teamB.getSport()+"\n";
}
}
public class DriverCode {
public static void main(String[] args) {
// Driver code to test these classes work correctly
// Creating Two objects of Team class
Team teamA = new Team(" Roosevelt High School", "Girls' BasketBall","Dolphins");
// For testing get Methods, show information of team A using their get methods
System.out.println("\n------------------------"+teamA.getTeamName().toUpperCase()+"------------------------\n"
+
"****************************"+Team.MOTTO+"****************************"+"\n"+
"High School name: "+teamA.getHighSchoolName()+"\n"+
"Sport: "+teamA.getSport()+"\n"+
"Team Name: "+teamA.getTeamName()+"\n");
// Creating another team
Team teamB = new Team("Howard High School","Boys's Cricket","Legends");
// Now passing both teams and time to Game class
Game game = new Game(teamA, teamB, "7 pm");
// Using set method , change the time from 7 pm to 5 pm
game.setGameTime("5 pm");
// And just showing these teams using toString() method of Game class
System.out.println(game.toString());
}
}
---------------------------------------------------------------------------------
COMMENT DOWN FOR ANY QUERIES........................
HIT A THUMBS UP IF YOU DO LIKE IT!!
Create a class to hold data about a high school 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.
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
C++ Program 1. Create a class named BaseballGame that has fields for two team names and a final score for each team. Include methods to set and get the values for each data field. Your application declares an array of 12 BaseballGame objects. Prompt the user for data for each object, and display all the values. Then pass each object to a method that displays the name of the winning team or “Tie” if the score is a tie. (main.cpp,...
Create a class named BaseballGame that contains data fields for two team names and scores for each team in each of nine innings. names should be an array of two strings and scores should be a two-dimensional array of type int; the first dimension indexes the team (0 or 1) and the second dimension indexes the inning. Create get and set methods for each field. The get and set methods for the scores should require a parameter that indicates which...
a. Create a class named Lease with fields that hold an apartment tenant's name, apartment Number, monthly rent amount, and term of the lease in months. Include a constructor that initializes the name. "XXX", the apartment number to O, the rent to 1000, and the term to 12. Also include methods to get and set each of the fields. Include a nonstatic method named addPetFee() that adds $10 to the monthly rent value and calls a static method named explainPetPolicy...
c ++ Create a class Book with the data members listed below. title, which is a string (initialize to empty string) sales, which is a floating point value (as a double, initialize to 0.0) Include the following member functions: Include a default constructor, a constructor with parameters for each data member (in the order given above), getters and setter methods for each data member named in camel-case. For example, if a class had a data...
Programming Language is Java 1. Create a class to describe a car. Include fields like: make, model, year and color. Add all the accessors and mutators for these fields. Add a constructor that can initialize the fields. 2. Create a class that will enable you to handle standard mail communication with a customer. Add all accessors and mutators, as well as a constructor. Add a method named fullAddress that will return the address formatted for a standard mail. Add a...
1. Create a class named Pizza with data fields dor desceiption
( such as sasuage and onion) and price. include a constructor fhay
requires arguments for borh fields ans a method to diplay the data.
Create a subclass names DelicedPizza that inherits from Pizza bit
adds a delivery fee and a delicery address. The description, price,
and delicery address are required as arguments to the constructor.
The delivery fee is $3 if the pizza ordered cost more that $15;
otherwise...
Write a class called Player that has four data members: a string for the player's name, and an int for each of these stats: points, rebounds and assists. The class should have a default constructor that initializes the name to the empty string ("") and initializes each of the stats to -1. It should also have a constructor that takes four parameters and uses them to initialize the data members. It should have get methods for each data member. It...