2025-08-28 21:08:16 -04:00
|
|
|
|
package lodge;
|
|
|
|
|
|
|
|
|
|
|
|
import lodge.reservationsystem.AccomodationManager;
|
|
|
|
|
|
import lodge.reservationsystem.Account;
|
|
|
|
|
|
import lodge.reservationsystem.Address;
|
|
|
|
|
|
import lodge.reservationsystem.EmailAddress;
|
2025-08-31 18:59:49 -04:00
|
|
|
|
import lodge.reservationsystem.CabinReservation;
|
|
|
|
|
|
import lodge.reservationsystem.HouseReservation;
|
|
|
|
|
|
import lodge.reservationsystem.HotelReservation;
|
2025-08-29 07:26:53 -04:00
|
|
|
|
import lodge.reservationsystem.Reservation;
|
2025-08-28 21:08:16 -04:00
|
|
|
|
|
|
|
|
|
|
public final class TestReservations {
|
|
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
|
|
|
|
|
|
|
|
|
AccomodationManager mgr = new AccomodationManager();
|
|
|
|
|
|
String home = System.getenv("HOMEDRIVE")+System.getenv("HOMEPATH");
|
2025-08-30 11:26:49 -04:00
|
|
|
|
home= home.replace("\\", "/")
|
|
|
|
|
|
+ "/workspace/reservationsystem/src/resources";
|
2025-08-29 10:32:10 -04:00
|
|
|
|
mgr.setDataStoreRoot(home);
|
2025-08-28 21:08:16 -04:00
|
|
|
|
// 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"));
|
2025-08-29 07:26:53 -04:00
|
|
|
|
mgr.AddAccount(acct);
|
2025-08-28 21:08:16 -04:00
|
|
|
|
|
|
|
|
|
|
// 4. Request that Manager updates specific account’s files with data stored in
|
|
|
|
|
|
// memory
|
2025-08-29 07:26:53 -04:00
|
|
|
|
mgr.UpdateAccount(mgr.retrieveAccount(acct.account_number()));
|
2025-08-28 21:08:16 -04:00
|
|
|
|
// 5. Add draft lodging reservation to an account (if reservation object already
|
|
|
|
|
|
// exists with the same reservation number, it is considered an error)
|
|
|
|
|
|
|
2025-08-31 18:59:49 -04:00
|
|
|
|
HotelReservation cabin = new HotelReservation();
|
2025-08-29 07:26:53 -04:00
|
|
|
|
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);
|
2025-08-29 10:32:10 -04:00
|
|
|
|
Reservation rsrv = cabin;
|
2025-08-31 18:59:49 -04:00
|
|
|
|
String reservationId = rsrv.getReservation_number();
|
|
|
|
|
|
|
|
|
|
|
|
mgr.UpdateAccount(mgr.retrieveAccount(acct.account_number()));
|
|
|
|
|
|
|
2025-08-29 07:26:53 -04:00
|
|
|
|
// 6. Complete reservation that is associated with an account
|
2025-08-29 10:32:10 -04:00
|
|
|
|
rsrv = mgr.retreiveReservation(reservationId);
|
2025-08-29 07:26:53 -04:00
|
|
|
|
rsrv.Complete();
|
|
|
|
|
|
|
2025-08-29 10:32:10 -04:00
|
|
|
|
mgr.UpdateAccount(mgr.retrieveAccount(acct.account_number()));
|
|
|
|
|
|
|
|
|
|
|
|
// 7. Cancel reservation that is associated with an account
|
|
|
|
|
|
rsrv = mgr.retreiveReservation(reservationId);
|
|
|
|
|
|
rsrv.Cancel();
|
|
|
|
|
|
mgr.UpdateAccount(mgr.retrieveAccount(acct.account_number()));
|
|
|
|
|
|
/*
|
2025-08-28 21:08:16 -04:00
|
|
|
|
*
|
|
|
|
|
|
* 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.");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|