/* PersonTestHarness.java example code AC Chapin */ package cis214_07methods; /** * test harness for Person class **/ public class PersonTestHarness { /** * report on whether Persons given are siblings **/ public static void checkSibs(Person p1, Person p2) { if (p1.sibling(p2)) { System.out.println(p1.getName() + " and " + p2.getName() + " are siblings "); } } /** * main method to demonstrate Person behavior **/ public static void main(String[] args) { // alice and don are parents of don, edith, and charlie, who has // children fiona and george // using different parameterized constructors Person alice = new Person("Alice", 81); Person bob = new Person("Bob", 79); Person don = new Person("Don", 40, alice, bob); Person edith = new Person("Edith", 48, alice, bob); Person fiona = new Person("Fiona", 18); Person george = new Person("George", 24); // without parameterized constructor, this would take 9 statements Person charlie = new Person("Charlie", 45, alice, bob, edith, don, fiona, george); // using mutators alice.setSon(charlie); alice.setDaughter(edith); bob.setSon(charlie); bob.setDaughter(edith); // several more to set for completeness... // print results System.out.println(charlie); System.out.println(alice); System.out.println(bob); checkSibs(charlie, edith); checkSibs(alice, edith); } }