public class Office
{
	//Declare object arrays to hold owners, appointments, and pets.
	//These have class scope.
	Owner[] owners = new Owner[3];
	Appt[] appts = new Appt[4];
	Pet[] pets;

	public static void main (String[] args)
	{
		Office test = new Office();		//instantiate the Office class
		test.addOwners();			//create owners and pets
		test.makeAppts();			//schedule appointments
		test.showOwners();			//print owners with their pets
		test.showAppts();			//print appointments
		//*nonstatic methods above can be called only from object (not from class)*
	}

	//This adds owner and pet data to the arrays. In the "real world",
	//this data would be read from a file or database.
	private void addOwners()
	{
		//create owner Joe Shmo with pets Rufus and Fifi
		pets = new Pet[2];
		pets[0] = new Pet ("Rufus", "rottweiler", 'M');
		pets[1] = new Pet ("Fifi", "toy poodle", 'F');
		owners[0] = new Owner ("Joe Shmo", "123 Elm", pets);

		//create owner Sally Sanchez with pets Oliver, Cole and Angel
		pets = new Pet[3];
		pets[0] = new Pet ("Oliver", "cat", 'M');
		pets[1] = new Pet ("Cole", "lab", 'M');
		pets[2] = new Pet ("Angel", "cockatoo", 'F');
		owners[1] = new Owner ("Sally Sanchez", "245 Oak", pets);

		//create owner Mona Lisa with pet Sammy
		pets = new Pet[1];
		pets[0] = new Pet ("Sammy", "rat", 'M');
		owners[2] = new Owner ("Mona Lisa", "987 Pine", pets);
	}

	private void makeAppts()			//schedule appointments
	{
		appts[0] = new Appt ("4/10/04", "3:30 pm", 3, owners[0].getPet("Rufus"));
		appts[1] = new Appt ("4/15/01", "10:00 am", 2, owners[0].getPet("Fifi"));
		appts[2] = new Appt ("4/15/04", "10:00 pm", 3, owners[2].getPet("Sammy"));
		appts[3] = new Appt ("4/16/01", "1:00 am", 2, owners[1].getPet("Brutus")); //no such pet
	}

	//Print a report of owner names and their pet names and breeds
	private void showOwners()
	{
		System.out.println ("OWNERS AND PETS: \n");		//header
		for (int i=0; i<owners.length; i++)											//loop through owners
		{
			System.out.println (owners[i].getName());	//print owner name
			pets = owners[i].getPets();			//get the owner's pets

			for (int j=0; j<pets.length; j++)		//loop through pet array
			{
				System.out.println ("\t"		// print pet name and breed						//print pet name & breed
				+ pets[j].getName() + ", "
				+ pets[j].getBreed());
			}
			System.out.println();													//print a space
		}
	}

	private void showAppts()				//print a summary of appointments		
	{
		System.out.println ("APPOINTMENTS: \n");	//header
		for (int i=0; i<appts.length; i++)		//loop through the appointments array
		{
			System.out.println (appts[i].toString());	//print appointment
		}
		System.out.println ("\n");
	}
}
