/** * This program tests the Hotel and Receptionist classes. * * @author JP Vergara * @version 28 July 2008 */ public class Tester { /** * Main method for the tester. Creates a Hotel object and * three receptionist objects. */ public static void main( String args[] ) { Hotel hotel = new Hotel(); Receptionist r1 = new Receptionist( hotel ); Receptionist r2 = new Receptionist( hotel ); Receptionist r3 = new Receptionist( hotel ); System.out.printf( "Total Sales : %8.2f\n", hotel.getTotalCash() ); System.out.printf( "Receptionist 1: %8.2f\n", r1.getCash() ); System.out.printf( "Receptionist 2: %8.2f\n", r2.getCash() ); System.out.printf( "Receptionist 3: %8.2f\n", r3.getCash() ); System.out.println( "---" ); System.out.println( "Room 101: " + r1.occupant( 101 ) ); System.out.println( "Room 102: " + r3.occupant( 102 ) ); System.out.println( "Room 103: " + r3.occupant( 103 ) ); r1.checkIn( 101, "Bob", 1 ); r2.checkIn( 102, "Joe", 2 ); r1.checkOut( 101, 3, 100.00 ); r1.checkIn( 101, "Ann", 3 ); r3.checkOut( 102, 3, 200.00 ); r2.checkIn( 103, "Liz", 3 ); System.out.println( "---" ); System.out.printf( "Total Sales : %8.2f\n", hotel.getTotalCash() ); System.out.printf( "Receptionist 1: %8.2f\n", r1.getCash() ); System.out.printf( "Receptionist 2: %8.2f\n", r2.getCash() ); System.out.printf( "Receptionist 3: %8.2f\n", r3.getCash() ); System.out.println( "---" ); System.out.println( "Room 101: " + r1.occupant( 101 ) ); System.out.println( "Room 102: " + r3.occupant( 102 ) ); System.out.println( "Room 103: " + r3.occupant( 103 ) ); System.out.println( "Room 104: " + r2.occupant( 104 ) ); r1.checkIn( 201, "Dan", 6 ); // error r1.checkIn( 101, "Dan", 6 ); // error r1.checkIn( 102, "Dan", 2 ); // error r1.checkIn( 102, "Dan", 6 ); System.out.println( "---" ); System.out.println( "Room 101: " + r1.occupant( 101 ) ); System.out.println( "Room 102: " + r3.occupant( 102 ) ); System.out.println( "Room 103: " + r3.occupant( 103 ) ); r2.checkOut( 101, 8, 0.50 ); r2.checkOut( 102, 6, 0.50 ); // error r2.checkOut( 102, 8, 0.50 ); r2.checkOut( 103, 8, 1.00 ); r2.checkOut( 103, 10, 1.00 ); // error System.out.println( "---" ); System.out.printf( "Total Sales : %8.2f\n", hotel.getTotalCash() ); System.out.printf( "Receptionist 1: %8.2f\n", r1.getCash() ); System.out.printf( "Receptionist 2: %8.2f\n", r2.getCash() ); System.out.printf( "Receptionist 3: %8.2f\n", r3.getCash() ); } }