//-------------------------------------------------------------------------------------------
// Test all Canines
//-------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------
// The Canine superclass
//-------------------------------------------------------------------------------------------
class Canine
{
    String  type;                           //define fields
    boolean domestic;       

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

    String toEat( ) {                       //define method
        return("must hunt");
    }
}
//-------------------------------------------------------------------------------------------
// The Dog Subclass
//-------------------------------------------------------------------------------------------
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 toString( ) 
    {           
        return("Type:" + this.type     +    //notice I can say "this"       
         "  Domestic:" + this.domestic +    //even though it belongs to Canine 
         "  Breed:"    + this.breed    + 
         "  Color:"    + this.color);
    }
}
//-------------------------------------------------------------------------------------------
// The Fox Subclass
//-------------------------------------------------------------------------------------------
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 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();

        Canine c = new Canine("unknown",false);         //create an unknown canine
        System.out.println(c);                          //call default toString() 
        System.out.println(c.type +" "+ c.domestic);
        System.out.println();

        Dog magic = new Dog("Dalmation","black&white"); //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","white");
        System.out.println(foxxy);                      //call Fox toString()
        System.out.println(whity);
    }
}