# 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.

##

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

##

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

##

BattingAverage

     public BattingAverage()

  Constructor

BattingAverage

     public BattingAverage(BattingAverage obj)

  Clone Constructor

  Parameters:
    obj - clone this object.

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.

##

setHits

     public void setHits(int hits)

  Set the value of hits

  Parameters:
    hits - The number of hits a player has.

getHits

     public int getHits()

  Get the value of hits.

  Returns:
    The number of hits a player has.

setAtBats

     public void setAtBats(int atBats)

  Set the value of atBats

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

getAtBats

     public int getAtBats()

  Get the value of atBats.

  Returns:
    The number of "at bat" attempts a player has.

toString

     public String toString()

  Convert object to String

  Returns:
    a String representation of a BattingAverage object.
  Overrides:
    toString in class Object

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

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.