/**
 * Class that extends BallPlayer to model a batter.
 *   @author Dave Reed
 *   @version 4/17/12
 */
public class Batter extends BallPlayer {
    private int hits, atBats;
    
    /**
     * Constructs a Batter object.
     * @param num the player's uniform number
     * @param fname the player's first name
     * @param lname te player's last name
     * @param pos the player's position
     * @param h the number of hits for the player
     * @param ab the number of at bats for the player
     */
    public Batter(int num, String fname, String lname, String pos, int h, int ab) {
        super(num, fname, lname, pos);
        this.hits = h;
        this.atBats = ab;
    }
    
    /**
     * @return the number of hits for the player
     */
    public int hits() {
        return this.hits;
    }
    
    /**
     * @return the number of at bats for the player
     */
    public int atBats() {
        return this.atBats;
    }
    
    /**
     * Calculate the player's batting average.
     *   @return the batting average (scaled between 0.0 and 1000.0)
     */
    public double battingAverage() {
        if (this.atBats == 0) {
            return 0.0;
        }
        else {
            return 1000.0*this.hits/this.atBats;
        }
    }
    
    /**
     * @return the player's information in a String
     */
    public String toString() {
        return super.toString() + "\tBA = " + this.battingAverage();
    }
    
////////////////////////////////////////////////////////////////////////
    
    public static void main(String[] args) {
        Batter p = new Batter(12, "Joe", "Smith", "1B", 120, 360);
        System.out.println(p);
    }
}
