Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The following code shows SportsInfo which is an abstract class that holds player statistics for sports. Write two classes that inherit from SprotsInfo. Each will

The following code shows SportsInfo which is an abstract class that holds player statistics for sports. Write two classes that inherit from SprotsInfo. Each will return a different type of Stats object depending on the sport.

public abstract class SportsInfo{

private String playerName;

Public SportsInfo (String name){

player Name= name;

}

public String getName() {return playerName;}

public abstract double getAverage();

}

Write two classes that inherit from SportInfo, one to handle bowling information (BowlingSportsInfo) and one to handle Baseball info (BaseballSportsInfo). They should make use of the superclass constructor, if possible. Only create members specifically needed by that type of SportsInfo.

The constructor for BowlingSportsInfo should have this signature:

Public BowlingSportsInfo(String name, int firstGameScore);

The constructor for BaseballSportsInfo should have this signature:

Public BaseballSportsInfo(String name, Boolean firstAtBatResult);

BowlingSportsInfo tracks scores for bowling games. It should have a member holding an array of integer game scores and a member that is an integer holding number of games. The array of game scores can be declared to hold 100 games. The getAverage() method should return the average score of all games on record. BowlingSportsInfo adds 1 method:

public void addGame(Int score);

BaseballSportsInfo should hold two integer members, the number of at bats (atBats) and the number of hits.

BaseballSportsInfos getAverage() returns the players batting average. The average is hits/atBats.

BaseballSportsInfo must implements 1 additional method:

public void addAtBat(Boolean hit);

The parameter hit indicates if the at bat was a hit.

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_2

Step: 3

blur-text-image_3

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

SQL For Data Science Data Cleaning Wrangling And Analytics With Relational Databases

Authors: Antonio Badia

1st Edition

3030575918, 978-3030575915

More Books

Students also viewed these Databases questions

Question

In what ways do organisations possess knowledge?

Answered: 1 week ago

Question

3. Would you say that effective teamwork saved their lives?

Answered: 1 week ago