package lodge; import java.net.URI; import lodge.reservationsystem.AccomodationManager; import lodge.reservationsystem.Account; import lodge.reservationsystem.Address; import lodge.reservationsystem.CabinReservation; import lodge.reservationsystem.DataRepository; import lodge.reservationsystem.EmailAddress; import lodge.reservationsystem.Reservation; public final class TestReservations { public static void main(String[] args) throws Exception { AccomodationManager mgr = new AccomodationManager(); String home = System.getenv("HOMEDRIVE")+System.getenv("HOMEPATH"); home= home.replace("\\", "/") + "/data"; DataRepository.setDataStoreRoot(home); // 1. Get the list of loaded accounts from Manager mgr.loadAll(); // 2. Retrieve a loaded account object that matches a specific account number mgr.retrieveAccount("A######"); // 3. Add new account object to the list managed by Manager (if account object // already exists on add action with the same account number, it is considered // an error) Account acct = mgr.newAccount("767-456-7890", new Address("10 wilco ave", "wilco", "WY", "82801"), new EmailAddress("wilco@wyommin.net")); mgr.AddAccount(acct); // 4. Request that Manager updates specific account’s files with data stored in // memory mgr.UpdateAccount(mgr.retrieveAccount(acct.account_number())); // 5. Add draft lodging reservation to an account (if reservation object already // exists with the same reservation number, it is considered an error) CabinReservation cabin = new CabinReservation(); cabin.setPhysical_address(new Address("30 cabin ave", "Carnelian", "CA", "96140")); cabin.setMailing_address(new Address("40 cabin ave", "Carnelian Bay", "CA", "96140")); cabin.setNumberOfBeds(4); cabin.setNumberOfFloors(2); cabin.setNumberOfBedRooms(3); cabin.setSquareFeet(806); mgr.addReservation( mgr.retrieveAccount(acct.account_number()), cabin); // 6. Complete reservation that is associated with an account Reservation rsrv = mgr.retreiveReservation("R######"); rsrv.Complete(); //mgr.UpdateAccount(mgr.retrieveAccount(acct.account_number())); /* * // 7. Cancel reservation that is associated with an account * if (acct != null) { * rsrv = acct.retrieve("?######"); * if (rsrv != null) * rsrv.Cancel(); * } * * if (rsrv != null) { * // 8. Change reservation values that can be changed (if reservation is * // cancelled, completed, or for past date, it is considered an error) * rsrv = Reservation.update(rsrv); * * // 9. Request for price per night to be calculated and returned for a * specific * // reservation * * rsrv = Reservation.calculatePricePerNight(rsrv); * // 10. Request for total reservation price to be calculated and returned for * a * // specific reservation * } */ System.out.println("Program Completed."); } }