Class BattingAverage

java.lang.Object
   |
   +----BattingAverage

public class BattingAverage
extends Object
The BattingAverge class is used to store and calculate a player's batting average.


Constructor Index

 o BattingAverage()
Constructor
 o BattingAverage(BattingAverage)
Clone Constructor
 o BattingAverage(int, int)
Full Constructor

Method Index

 o equals(Object)
Determine if an object is equal to this object.
 o getAtBats()
Get the value of atBats.
 o getBattingAverage()
Calculate and return a player's batting average.
 o getHits()
Get the value of hits.
 o setAtBats(int)
Set the value of atBats
 o setHits(int)
Set the value of hits
 o toString()
Convert object to String

Constructors

 o BattingAverage
 public BattingAverage()
Constructor

 o BattingAverage
 public BattingAverage(BattingAverage obj)
Clone Constructor

Parameters:
obj - clone this object.
 o BattingAverage
 public BattingAverage(int hits,
                       int atBats)
Full Constructor

Parameters:
hits - - The number of hits a player has.
atBats - - The number of "at bat" attempts a player has.

Methods

 o setHits
 public void setHits(int hits)
Set the value of hits

Parameters:
hits - The number of hits a player has.
 o getHits
 public int getHits()
Get the value of hits.

Returns:
The number of hits a player has.
 o setAtBats
 public void setAtBats(int atBats)
Set the value of atBats

Parameters:
atBats - The number of "at bat" attempts a player has.
 o getAtBats
 public int getAtBats()
Get the value of atBats.

Returns:
The number of "at bat" attempts a player has.
 o toString
 public String toString()
Convert object to String

Returns:
a String representation of a BattingAverage object.
Overrides:
toString in class Object
 o equals
 public boolean equals(Object obj)
Determine if an object is equal to this object.

Parameters:
obj - the object to test.
Returns:
true if obj is equal to this object.
Overrides:
equals in class Object
 o getBattingAverage
 public double getBattingAverage()
Calculate and return a player's batting average.

Returns:
the player's batting average, or zero if there are no stats.