Question
JAVA A BaseballPlayer has a name, a number of hits, and a number of at-bats. A BaseballPlayer can be created with a name, or with
JAVA
A BaseballPlayer has a name, a number of hits, and a number of at-bats. A BaseballPlayer can be created with a name, or with all three data. Provide a getter and setter for any one instance variable (your choice of which). Also, provide a getBattingAverage() method that calculates and returns the BaseballPlayer's batting average which is the number of hits divided by the number of at-bats.
NOTE: The BaseballPlayer class is an object class (a class designed to make objects from), not a driver class. So, there will be no main method. Please feel free to write a driver class to test your BaseballPlayer class in Eclipse if you wish!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started