/**
 * @author CPSC Instructors
 * @date 14 Apr 2010
 *
 * Extend NamedBunny class and implement Comparable interface.
 *
 * Dynamically check if we're passed a bunny type before trying to use
 * bunny-specific methods.
 */

public class SafeBunny extends NamedBunny implements Comparable {
 public SafeBunny() {
  super();
 } 
 public SafeBunny(int x, int y, int carrots, String name) {
  super(x,y,carrots,name);
 }
 /* compare by name alphabetical order */
 /* check if it's the right type before call the getName method! */
 public int compareTo(Object other) 
 {
     if (other instanceof SafeBunny) { 
	 return this.getName().compareTo( ( (SafeBunny) other ).getName() );
     } else {
	 return 0;
     }
 }
}

