public class Dog { int height; String name; //reasonable for a dog to have no name, but not no size! (esp not 0 size) //our first non-default constructor public Dog(int dogHeight) { height = dogHeight; } //another constructor public Dog(int dogHieght, String dogName) { height = dogHeight; name = dogName; } //Better bark method that depends on an instance variable value void bark() { if (height < 3) { System.out.println("Yip yip!"); } else { System.out.println("Arf arf!"); } } } public class Doghouse { int height; Dog resident; //Doghouses have to have heights too! public Doghouse(int houseHeight) { height = houseHeight; } //a "default" height for a new Doghouse public Doghouse() { height = 3; } //method with an argument and return value // object equality - will discuss this more thoroughly later boolean canFitDog(Dog d) { return (resident == null && d.height < height); } } public class Kennel { Doghouse[] houses; //note that there are no houses yet!! just references public Kennel(int numHouses) { houses = new Doghouse[numHouses]; } // will build houses "by hand" just saying // k.houses[0] = new Doghouse(3); , etc. void takeDog(Dog d) { boolean has_home = false; //had to initialize this local var! //put it in first available house for(Doghouse h : houses) { //cool new for loop! if (!has_home && h.canFitDog(d)) { h.resident = d; has_home = true; } } if (!has_home) { System.out.println("Dog won't fit!"); } } } What if we want to expand the kennel? If there isn't space in the array we made, we're stuck; we need to make a whole new array and copy everything over - essentially raze the kennel and build a new one. This is ugly and inefficient! Use an ArrayList! //new Kennel code: public class Kennel { ArrayList houses; //note that there are no houses yet!! just references //no longer need to give a size to start! public Kennel() { houses = new ArrayList(); } // will build houses "by hand" just saying // k.houses.add(new Doghouse(3)); , etc. //the takeDog method is the same! } //Doing some things in main to test our classes. public class KennelTest { public static void main (String [] args) { Kennel k = new Kennel(); k.houses.add(new Doghouse(3)); k.houses.add(new Doghouse(1)); k.houses.add(new Doghouse(5)); Dog d = new Dog(2); k.takeDog(d); Dog e = new Dog(6); k.takeDog(e); //etc. } } A better takeDog method might : ask user their dog's name and how tall they are create a new dog with those properties try to house it Can you write this?