a. Create a class named BaseballGame that contains data fields for two team names. Include a two-dimensional

Question:

a. Create a class named BaseballGame that contains data fields for two team names. Include a two-dimensional array that can hold the scores for each of two teams in each inning of the game. The BaseballGame class includes a final int that represents the number of innings in a BaseballGame—nine. The constructor initializes the two-dimensional array to dummy values for each team for the number of innings. Create set methods for the team names and the individual inning scores. The setScore () method requires parameters for the team, inning, and score for that inning. Create get methods for the names and inning scores. Save the file as BaseballGame.java.

b. Create two subclasses from BaseballGame: High School Baseball Game and Little League Baseball Game. High school baseball games have seven innings, and Little League games have six innings; override the parent class final int to represent the correct number of innings for each subclass. The constructor for each class should set the scores to a default value for the appropriate number of innings. Save the files as HighSchoolBaseballGame.java and LittleLeagueBaseballGame.java.

c. Write an application that allows the user to select a game type and enter two team names. Then, for each inning, allow the user to enter an inning score for each team and display the running scores so far. After all the innings are complete, display a message indicating which team won or if the result was a tie. Save the file as DemoBaseballGame.java.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  answer-question

Java Programming

ISBN: 9780357673423

10th Edition

Authors: Joyce Farrell

Question Posted: