/* APersonTest.java 1.0 1 December 2002 */ /* by V. Proulx */ /* modified by Sharon Tuttle, 2-11-03 */ public class APersonTest extends JPFalt { public static void main(String[] args) { new APersonTest(); } /** Test suite for the abstract class APerson */ /*------------------------------------------------------------------------- Define an Instructor object and print the member data values, and test accessor and modifier methods of Instructor and APerson (note that APerson's modifier methods are indeed being implicitly tested, since Instructor's constructor ends up calling them) ------------------------------------------------------------------------*/ void TestInstructor() { println("\nDefine Instructor object, print member data values"); Instructor inst1 = new Instructor("Dreamer", 1999, "Math", "Professor"); println(inst1); println(inst1.getName()); println(inst1.getDob()); println(inst1.getDepartment()); println(inst1.getTitle()); } /*------------------------------------------------------------------------- Define an Staff object and print the member data values, and test accessor and modifier methods of Instructor and APerson (note that APerson's modifier methods are indeed being implicitly tested, since Staff's constructor ends up calling them) ------------------------------------------------------------------------*/ void TestStaff() { println("\nDefine Staff object, print member data values"); Staff worker1 = new Staff("Sweeper", 1999, "Math", 12); println(worker1); println(worker1.getName()); println(worker1.getDob()); println(worker1.getDepartment()); println(worker1.getPayRate()); } /*------------------------------------------------------------------------ Test method for inDepartment() (in abstract class APerson) -----------------------------------------------------------------------*/ void inDepartmentTest() { testHeader("inDepartment()"); /*-------------------------------------------------------------------- Define an Instructor object and a Staff object ---------------------------------------------------------------------*/ Instructor eeny = new Instructor("Dreamer", 1944, "Math", "Professor"); Staff meeny = new Staff("Weaver", 1966, "Physics", 25.50); expected(true); actual( eeny.inDepartment("Math") ); expected(false); actual( eeny.inDepartment("Physics") ); expected(false); actual( meeny.inDepartment("Math")); expected(true); actual( meeny.inDepartment("Physics")); } /*------------------------------------------------------------------ test method for olderThan() (in abstract class APerson) -------------------------------------------------------------------*/ void olderThanTest() { testHeader("olderThan()"); /*-------------------------------------------------------------------- Define an Instructor object and a Staff object ---------------------------------------------------------------------*/ Instructor eeny = new Instructor("Dreamer", 1944, "Math", "Professor"); Staff meeny = new Staff("Weaver", 1966, "Physics", 25.50); expected(true); actual( eeny.olderThan(meeny) ); expected(false); actual( meeny.olderThan(eeny) ); expected(false); actual( meeny.olderThan(meeny)); } /*------------------------------------------------------------------ Test method for computePay() (in class Staff) -------------------------------------------------------------------*/ void computePayTest() { testHeader("computePay()"); /*-------------------------------------------------------------------- Define a Staff object ---------------------------------------------------------------------*/ Staff meeny = new Staff("Weaver", 1966, "Physics", 25.50); expected(255.00); actual( meeny.computePay(10) ); expected(943.5); actual( meeny.computePay(37) ); } }