/**
 * A weapon handy for killing zombies.
 * Every book has a weight, a range it can be thrown, and a damage potential.
 * 
 * @author Zach Tomaszewski
 * @version 12 Sept 2007
 */
public class Book {

  private int weight;  //how many pounds this book weighs (1 to 10)
  /*
   * Other details of a book are not stored, but calculated as follows:
   * A book's range is 11 - weight (so 1 to 10 yards).
   * A book's damage potential is weight/2 (so 0 to 5 points)
   */ 


  /**
   * Constructs a new book of random weight, between 1 and 10 pounds.
   * (Damage and range depend on the book's weight.)
   */
  public Book() {
    //generate random number between 1 and 10
    this.weight = (int) (Math.random() * 10 + 1);
  }

  /**
   * Constructs a book of the given weight.
   */
  public Book(int weight) {
    this.weight = weight;
  }


  /**
   * Returns how many points of damage this book can inflict.
   */
  public int getDamage() {
    return weight/2;
  }

  /**
   * Returns how many yards this book can be thrown.
   */
  public int getRange() {
    return 11 - weight;
  }

  /**
   * Returns how much this book weighs (in pounds).
   */
  public int getWeight(){
    return this.weight;
  }

  /**
   * Returns a string representation of this Book.
   */
  public String toString() {
    String result = weight + "-pound book";
    return result;
  }

  
  /**
   * Runs a few tests with a couple book objects.
   */
  public static void main(String[] args) {
    Book first = new Book();  //creates a book of random weight
    Book second = new Book(5);  //creates a 5-pound book

    System.out.println("My first book is a " + first.toString());
    System.out.println("My second book is a " + second);  //toString called implicitly

    System.out.println("My first book does " + first.getDamage() +
        " points of damage and has a range of " + first.getRange() + " yards.");
 }

}//end Book
