Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You will create a class diagram for the unit assignment. This diagram will be used as you move into the coding phase. You are designing

You will create a class diagram for the unit assignment. This diagram will be used as you move into the coding phase. You are designing the classes for a program that will act as a generic scorekeeper. Then, through inheritance, you will extend this functionality to handle fouls, balls, strikes, outs, and innings for baseball. Create a class diagram for both the base class and inherited subclass listed below.

Generate your class diagram using Microsoft Visio. Microsoft Visio can be obtained for free from Purdue Globals Microsoft Azure Development Tools for Teaching website.

  1. Create a class diagram for a base class called scoreKeeper.
    1. Include a private property called gamePlayed to contain the name of the game being played.
    2. Add a private property which will allow for any number of players. A dictionary or dynamic array would be a good option. The container will hold the names and scores of the players.
    3. Include a new public method, addName(), to accept a players name and insert it into the container.
    4. Include a public method, getPlayerName(), to accept the number of the player and return the players name.
    5. Include a public method, setGame(), to update the gamePlayed property by passing it a string containing the name of the game.
    6. Include a public method, getGame(), to retrieve the name of the game.
    7. Include a public method, addScore(), to update a players score by passing it the players name and the points to be added. Return the updated score.
    8. Include a public method, subScore(), to update a players score by passing it the players name and the points to be subtracted. Return the updated score.
    9. Include a new public method, listAllScores(), to print the name of the game being played, the names of each player, and their respective scores.
    10. Include two constructors. The first one is a default constructor. The second is a constructor method which will accept the name of the game and call the setGame().
  2. Some games have additional information that must be monitored during play. Create a class diagram for a sub-class called baseball that inherits from the base class scoreKeeper.
    1. Add private integer properties for fouls, balls, strikes, and outs.
    2. Add a private decimal property to hold the inning number. Whole numbers will indicate the top of the inning, and half numbers will indicate the bottom: e.g., 5.5 would indicate the bottom of the 5th.
    3. Include a public method, advOuts(), to add 1 to the number of outs. If the number of outs reaches 3, reset balls, strikes, fouls, and outs to 0 and add .5 to innings.
    4. Include a public method, getOuts(), to return the current number of outs.
    5. Include a public method, advStrikes(), to add 1 to the number of strikes. If the number of strikes reaches 3, call advOuts().
    6. Include a public method, getStrikes(), to return the current number of strikes.
    7. Include a public method, advFouls(), to add one to the number of fouls. If the number of strikes is less than 2, advFouls() should also add one to strikes.
    8. Include a public method, getFouls(), to return the current number of fouls.
    9. Include a public method, advBalls(), to add one to the number of balls. If the number of balls reaches 4, reset balls, strikes, and fouls. (This means the player has been given a walk to first base but does not guarantee and runs were scored.)
    10. Include a public method, getBalls(), to return the current number of balls.
    11. Include a public method, getInning(), to return the current inning.
    12. Include two constructors. The first one is a default constructor. The second is a constructor method which will accept the name of the home team followed by the name of the visiting team. It will then call the setGame() and pass it a combined name such as Cubs vs Braves. It will also call the addName() method to add the two teams to the players property.

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

Students also viewed these Databases questions

Question

Describe the relationship between annual objectives and policies.

Answered: 1 week ago

Question

What five factors help determine if you have lost attention?

Answered: 1 week ago