Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(Java Only) Design a class BallGame that has the following instance variables and properties: Name of first team and name of second team Number of

(Java Only)

Design a class BallGame that has the following instance variables and properties:

Name of first team and name of second team

Number of players in each team (one single variable)

Number of substitutes (one single variable)

Score of first and second team

- Provide a default constructor that sets names of teams to Unknown, number of players, substitutes and scores to 0.

- Provide a constructor that accepts specific values for each of the private members. Throw an exception (of your design) if the numbers are negative.

- Provide accessors for each of the members

- Provide mutators for each of the private members. Throw an exception (of your design) if the numbers are negative.

- Provide a method TeamAScored and TeamBScored that increases the score of the appropriate team by a specified value (i.e TeamAScored accepts an integer). Throw an exception (of your choice) if the values are negative.

- A method display that displays all attributes of an object

- Povide a method Equal that accepts an object BallGame and returns true if the object is equal to current object and false otherwise.

- Provide a method WhoIsWinning that returns the name of the winning team or Draw if both have same score.

B. Derive a class SoccerGame that has in addition the following:

Principal Referees name

Number of players substituted

- Provide a default constructor that sets team names and referees name to unknown, number of payers to 11, number of substitutes to 5 and the score of each team as well as number of players substituted to 0.

- Provide a constructor that accepts the names of the teams and the referees name.

- Provide accessors and mutators for referees name and number of players substituted. Throw an exception (of your design) if the numbers are negative.

- Override the method display to display all private attributes.

- Override the method Equal to compare two SoccerGames

- Override TeamAScored and TeamBScored that accepts an integer to increase the score of the appropriate team by 1 even if the number specified is larger than 1.

- Overload TeamAScored and TeamBScored (no input parameter) to increase the score of the appropriate team by 1.

- Provide a method SubstitutionA, SubstitutionB that increases the number of players substituted for the appropriate team by 1 if it is less than 3, otherwise it displays No more substitutions allowed.

C. Write a class tester (main) where you test every method and constructor of both classes. Print the output of your program.

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

Recommended Textbook for

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions

Question

1. Design an effective socialization program for employees.

Answered: 1 week ago