// create 2 objects which do method calls on each other
public class ApplicationRunner{
public static void main(String [] args){
Cat c1 = new Cat("Ralph");
System.out.println("We have created a cat named " + c1.CatName);
Hat h1 = c1.findAPlaceToHide("Suzie's Hat ");
System.out.println( c1.CatName + " is now hiding in Hat " + Hat.hatName );
System.out.println("The cat is OK " + h1.wellnessCheckForCat());
}
} class Cat{
public String CatName;
public Hat hatName;
public Cat(String name){
this.CatName = name;
} public Hat findAPlaceToHide(String HatName){
this.hatName = new Hat(HatName);
this.hatName.hidingPlaceForACat = this;
return this.hatName ;
}
} class Hat{
// data field :
public Hat(String hName){this.hatName = hName;} public static String hatName;
public static Cat hidingPlaceForACat; public static boolean wellnessCheckForCat(){
if (hidingPlaceForACat !=null) {return true;}
return false;
}
}