Question: Java programming: 2.Prepare program ,using abstract class(PlayerStats), that gives the statistics for the classes Baseball and Football sports. For the Football consider the: yards, and

Java programming:

2.Prepare program ,using abstract class(PlayerStats), that gives the statistics for the classes Baseball and Football sports.

For the Football consider the: yards, and the scores (+6). The statistics for Football should be the yards and the scores.

For the Baseball consider the score (+1), hit (+1), errors (+1). The statistics for Baseball objects should be : number of hits, scores, and number of errors.

You can use toString in both classes for the results (an in-built method in Java that returns the value given to it in string format).

The abstract class will be used for having common attributes (name, team) and methods for both classes. The driver class will test both classes.

Output:

For Baseball For Football

Name: Paul Name: Eric

Team: one Team: two

Score:1 Score: 6

Hits:1 Yards:15

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!