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.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter9: Records (struct)
Section: Chapter Questions
Problem 2PE
icon
Related questions
Question

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 String mascot;
   public final static String MOTTO = "Sportsmanship!";
   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;
   }
}
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Types of Loop
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
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning