Class ScoreKeeper

java.lang.Object
  extended by ScoreKeeper

public class ScoreKeeper
extends java.lang.Object

A class that models a simple basketball scorekeeper, keeping track of overall score and shooting percentages for 3 point field goals, 2 point field goals, and free throws.


Constructor Summary
ScoreKeeper()
          Creates a new ScoreKeeper object.
 
Method Summary
 double getPercent(int points)
          Gets the current shooting percentage for a type of shot.
 int getScore()
          Gets the current score.
 void made(int points)
          Records a made shot, either a 3 point FG, 2 point FG, or free throw.
 void missed(int points)
          Records a missed shot, either a 3 point FG, 2 point FG, or free throw.
 void reset()
          Resets the score and all related stats.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScoreKeeper

public ScoreKeeper()
Creates a new ScoreKeeper object.

Method Detail

reset

public void reset()
Resets the score and all related stats.


missed

public void missed(int points)
Records a missed shot, either a 3 point FG, 2 point FG, or free throw.

Parameters:
points - the number of points associated with the shot (3, 2 or 1)

made

public void made(int points)
Records a made shot, either a 3 point FG, 2 point FG, or free throw.

Parameters:
points - the number of points associated with the shot (3, 2 or 1)

getScore

public int getScore()
Gets the current score.

Returns:
the score

getPercent

public double getPercent(int points)
Gets the current shooting percentage for a type of shot.

Parameters:
points - the type of shot (3 = 3pt FG, 2 = 2pt FG, 1 = free throw)
Returns:
the shooting percentage (rounded to 1 decimal place)