82.1k views
7 votes
Write a constructor for BaseballPlayer. The constructor takes three int parameters: numHits, numRuns, and numRBIs storing the values within the class' ArrayList field named playerStats.

1 Answer

8 votes

Answer:

Following are the code to the given question:

public class BaseballPlayer//defining a class BaseballPlayer

{

BaseballPlayer(int numHits, int numRuns, int numRBIs)//defining a parameterized cons

{

}

}

Step-by-step explanation:

Some of the data is missing, which is why the solution can be represented as follows:

In this code, a class BaseballPlayer is defined, and inside the class a parameterized constructor is defined that holds three integer variable "numHits, numRuns, and numRBIs".

User Rdaniels
by
3.3k points