Class BattingAverage

java.lang.Object
  |
  +--BattingAverage

public class BattingAverage
extends java.lang.Object

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


Constructor Summary
BattingAverage()
          Constructor
BattingAverage(BattingAverage obj)
          Clone Constructor
BattingAverage(int hits, int atBats)
          Full Constructor
 
Method Summary
 boolean equals(java.lang.Object obj)
          Determine if an object is equal to this object.
 int getAtBats()
          Get the value of atBats.
 double getBattingAverage()
          Calculate and return a player's batting average.
 int getHits()
          Get the value of hits.
 void setAtBats(int atBats)
          Set the value of atBats
 void setHits(int hits)
          Set the value of hits
 java.lang.String toString()
          Convert object to String
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

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.
Method Detail

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 java.lang.String toString()
Convert object to String
Overrides:
toString in class java.lang.Object
Returns:
a String representation of a BattingAverage object.

equals

public boolean equals(java.lang.Object obj)
Determine if an object is equal to this object.
Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to test.
Returns:
true if obj is equal to this 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.