Question: Part 1-1: Write a java class encapsulating the concept of statistics for a baseball team, which has the following attributes: an array of number of

Part 1-1: Write a java class encapsulating the concept of statistics for a baseball team, which has the following attributes: an array of number of hits for each player, an array of number of at-bats for each player.

Write the following methods:

(a) A constructor with two equal-length arrays as parameters, one represents the number of hits per player, and the other represent number of at-bats per player.

(b) Accessors, mutators, toString, and equals methods.

Hint: in the mutator, you need to make sure that the two arrays' lengths are still the same after one mutator is called.

(c) Generate and return an array of batting average based on the attributes given.

(d) Calculate and return the number of players with a batting average greater than 0.3.

(e) A method returning an array holding the number of hits, sorted in ascending order.

Part 1-2: Write a java client class to test all the methods in your class.

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!