EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
8th Edition
ISBN: 9781305480537
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 7, Problem 11PE

Explanation of Solution

Program:

File name: “Team.java

//Define a class named Team

public class Team

{

    //Declare the private variables

    private String name;

    private String sport;

    private String mascot;

    //Initialize a final static variable

    public final static String MOTTO = "Sportsmanship!";

    //Define a Team method

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

    {

        //Refers to the instance variables

        this.name = name;

        this.sport = sport;

        this.mascot = mascot;

    }

    //Define a get method to display the name

    public String getName()

    {

        //Return the value

        return name;

    }

    //Define a get method to display the sport

    public String getSport()

    {

        //Return the value

        return sport;

    }

    //Define a get method to display the mascot

    public String getMascot()

    {

        //Return the value

        return mascot;

    }

}

File name: “Game.java

//Define a class named Game

public class Game

{

    //Declare the private variables

    private Team team1;

    private Team team2;

    private String time;

    //Define a Game method

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

    {

        team1 = t1;

        team2 = t2;

/*If the two teams in a game have the same value for the sport*/

        if(t1.getSport().equals(team2.getSport()))

            //Refers to the instance variables

            this.time = time;

        /*Else if the two teams in a game do not

        have the same value for the sport*/

        else

            //Refers to the instance variables

            this...

Blurred answer
Students have asked these similar questions
This is the question - In Chapter 4, you created a class named Game that included two Team objects that held data about teams participating in a game. Modify the Game class to set the game time to the message Game cancelled! if the two teams in a game do not have the same value for the sport. (In other words, a girls’ basketball team should not have a game scheduled with a boys’ tennis team.) Write a program to demonstrate a valid and an invalid game. This is the code that I have so far but can't seem to get them to compare correctly -    public class Game {     private Team team1;     private Team team2;     private String time;     public Game(Team t1, Team t2, String time) {         // your code here         this.team1=t1;         this.team2 = t2;         if(team1 == team2)         this.time = time;          else         this.time = "Game cancelled!";              }     public Team getTeam1() {         // your code here         return team1;     }     public Team getTeam2()…
This is the question - In Chapter 4, you created a class named Game that included two Team objects that held data about teams participating in a game. Modify the Game class to set the game time to the message Game cancelled! if the two teams in a game do not have the same value for the sport. (In other words, a girls’ basketball team should not have a game scheduled with a boys’ tennis team.) Write a program to demonstrate a valid and an invalid game.   This is the code it starts me with. I honestly have no clue where to start to change this - public class Game {     private Team team1;     private Team team2;     private String time;     public Game(Team t1, Team t2, String time) {         // your code here     }     public Team getTeam1() {         // your code here     }     public Team getTeam2() {         // your code here     }     public String getTime() {         // your code here     } } public class Team {    private String name;    private String sport;    private…
Please provide JAVA source code for following assignment. Please attach proper comments and read the full requirements. The local Driver’s License Office has asked you to write a program that grades the written portion of the driver’s license test The test has 20 multiple choice questions. Here are the correct answers:  B  D  A  A  C  A  B  A  C  D  B  C  D  A  D  C  C  D  D  A A student must correctly answer 15 of the 20 questions to pass the exam. Write a class named Drivertest that holds the correct answers to the test in an array field. The class should also have an array field that holds the student’s answers. The class should have the following methods: passed. Returns true if the student passed the test, or false if the student failed totalCorrect. Returns the total number of correctly answered questions totalIncorrect. Returns the total number of incorrectly answered questions questionsMissed. An int array containing the…
Knowledge Booster
Background pattern image
Computer Science
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
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Memory Management Tutorial in Java | Java Stack vs Heap | Java Training | Edureka; Author: edureka!;https://www.youtube.com/watch?v=fM8yj93X80s;License: Standard YouTube License, CC-BY