/****************************************************************************
 * Test all interfaces and classes together
 ***************************************************************************/
/****************************************************************************
 * Interface Animal
 ***************************************************************************/
interface Animal
{
    String PLACE = "Animal Kingdom";        //define a public static final constant

    public abstract String toEat( );        //define a public abstract method 
}

/****************************************************************************
 * Abstract Superclass Canine - Implements Animal
 ***************************************************************************/
abstract class Canine implements Animal
{
    String  type;                           //define fields
    boolean domestic;       

    Canine(String kind, boolean dom)        //constructor
    {
        type     = kind;
        domestic = dom;
    }
}

/****************************************************************************
 * Subclass Dog
 ***************************************************************************/
class Dog  extends  Canine              //subclass extends superclass
{
    String breed;                       //add additional fields
    String color;

    Dog(String breed, String color)     //constructor
    {
        super("dog",true);              //call the superclass constructor

        this.breed = breed;
        this.color = color;
    }

    public String toEat( )              //define method
    {
        return("beg for food");
    }

    public String toString( )           //define toString() method
    {
        return("Type:" + type     +
         "  Domestic:" + domestic + 
         "  Breed:"    + breed    + 
         "  Color:"    + color    +
         "  To eat:"   + toEat() );
    }
}

/****************************************************************************
 * Subclass Fox
 ***************************************************************************/
class Fox  extends  Canine              //subclass extends superclass
{
    String habitat;                     //add additional fields 
    String color;

    Fox(String habitat, String color)   //constructor
    {
        super("fox",false);             //call the superclass constructor

        this.habitat = habitat;
        this.color   = color;
    }

    public String toEat( )              //define method
    {
            return("must hunt");
    }

    public String toString( )           //define toString() method
    {
        return("Type:" + type     + 
         "  Domestic:" + domestic + 
         "  Habitat:"  + habitat  + 
         "  Color:"    + color    +
         "  To eat:"   + toEat() );
    }
}

/****************************************************************************
 * The tester class
 ***************************************************************************/
public class xCanineTest
{
    public static void main (String[ ] args) 
    {
        System.out.println(Animal.PLACE);
        System.out.println();

        Dog magic = new Dog("Dalmation","blackWhite");  //create 2 dogs
        Dog snowy = new Dog("mix breed","white     ");
        System.out.println(magic);                      //call Dog toString()
        System.out.println(snowy);
    
        System.out.println();

        Fox foxxy = new Fox("Near hen house ","red ");  //create 2 foxes
        Fox whity = new Fox("Northern Alaska","snow");
        System.out.println(foxxy);                      //call Fox toString()
        System.out.println(whity);
    }
}