public class Chicken implements Comparable<Chicken>
{
  private String name;
  private int age;
  private double weight;

  public Chicken(String n, int a, double w)
  {
    this.name = n;
    if(a > 0)
    {
      this.age = a;
    }
    else
    {
      System.out.println("No negative ages.");
      System.exit(1);
    }
    if(w > 0.0)
    {
      this.weight = w;
    }
    else
    {
      System.out.println("No floating chickens.");
      System.exit(1);
    }
  }

  public Chicken(Chicken original)
  {
    this(original.name, original.age, original.weight);
  }

  public String getName()
  {
    return this.name;
  }

  public int getAge()
  {
    return this.age;
  }

  public double getWeight()
  {
    return this.weight;
  }

  public void setAge(int a)
  {
    if(this.age < a)
    {
      this.age = a;
    }
    else
    {
      System.out.println("Chickens do not age backwards.");
      System.exit(1);
    }
  }

  public void setWeight(double w)
  {
    if(w > 0.0)
    {
      this.weight = w;
    }
    else
    {
      System.out.println("No floating chickens.");
    }
  }

  public void fly()
  {
    System.out.println(this.name + " flaps her wings and manages to fly a few feet.");
  }

  public void cluck()
  {
    System.out.println(this.name + " says buck buck buck.");
  }

  public void layEgg()
  {
    System.out.println(this.name + " lays an egg.");
  }

  public int compareTo(Chicken rhs)
  {
    if(this.weight > rhs.weight)
    {
      return 1;
    }
    else if (this.weight == rhs.weight)
    {
      return 0;
    }
    else
    {
      return -1;
    }
  }

  public String toString()
  {
    return "A Chicken-- Name:" + this.name + " Age:" + this.age + " Weight:" + this.weight;
  }

  public static void main(String args[])
  {
    Chicken c1;
    c1 = new Chicken("Henrietta", 1, 1.5);
    Chicken c2 = new Chicken("Eggletina", 2, 2.5);
    System.out.println(c1.compareTo(c2));
    System.out.println(c2.compareTo(c2));
    System.out.println(c2.compareTo(c1));
  }
}

/*
int a;//   1066 |?| <-a
a = 10;//  1066 |10| <-a

Chicken c1; //  1666 |?| <-c1
c1 = new Chicken("Henrietta", 1, 1.5);

----------------------------------  My new chicken
1776    |"Henrietta"| <-c1.name 
1777    | 1         | <-c1.age
1777    | 1.5       | <c1.weight 
----------------------------------
1666 |1777| <-c1  //c1 contains the address of the new chicken
*/

// Chicken c1, c2;
// c1.compareTo(c2) positive if c1 > c2, 0 if equal, netative if c1 < c2
