update time function, rebased
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
package lodge;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import lodge.reservationsystem.AccomodationManager;
|
||||
import lodge.reservationsystem.Account;
|
||||
import lodge.reservationsystem.Address;
|
||||
@@ -13,9 +16,9 @@ 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("\\", "/")
|
||||
+ "/workspace/reservationsystem/src/resources";
|
||||
String home = System.getenv("HOMEDRIVE") + System.getenv("HOMEPATH");
|
||||
home = home.replace("\\", "/")
|
||||
+ "/workspace/reservationsystem/src/resources";
|
||||
mgr.setDataStoreRoot(home);
|
||||
// 1. Get the list of loaded accounts from Manager
|
||||
|
||||
@@ -29,9 +32,9 @@ public final class TestReservations {
|
||||
// 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"));
|
||||
Account acct = mgr.newAccount("701-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
|
||||
@@ -40,27 +43,57 @@ public final class TestReservations {
|
||||
// 5. Add draft lodging reservation to an account (if reservation object already
|
||||
// exists with the same reservation number, it is considered an error)
|
||||
|
||||
HotelReservation cabin = new HotelReservation();
|
||||
HotelReservation hotel = new HotelReservation();
|
||||
hotel.setPhysical_address(new Address("400 hotel ave", "Maryland City", "CA", "20723"));
|
||||
hotel.setMailing_address(new Address("400 hotel ave", "Maryland City", "MD", "20723"));
|
||||
hotel.setNumberOfBeds(3);
|
||||
hotel.setNumberOfFloors(1);
|
||||
hotel.setNumberOfBedRooms(2);
|
||||
hotel.setSquareFeet(450);
|
||||
boolean success1 = mgr.addReservation(mgr.retrieveAccount(acct.account_number()), hotel);
|
||||
assert success1;
|
||||
|
||||
mgr.UpdateAccount(mgr.retrieveAccount(acct.account_number()));
|
||||
|
||||
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);
|
||||
Reservation rsrv = cabin;
|
||||
String reservationId = rsrv.getReservation_number();
|
||||
|
||||
mgr.UpdateAccount(mgr.retrieveAccount(acct.account_number()));
|
||||
boolean success2 = mgr.addReservation(mgr.retrieveAccount(acct.account_number()), cabin);
|
||||
assert success2;
|
||||
|
||||
HouseReservation house = new HouseReservation();
|
||||
house.setPhysical_address(new Address("3000 Osage ave", "GreenBelt", "MD", "20740"));
|
||||
house.setMailing_address(new Address("40012 College ave", "College Park", "MD", "20740"));
|
||||
house.setNumberOfBeds(4);
|
||||
house.setNumberOfFloors(3);
|
||||
house.setNumberOfBedRooms(3);
|
||||
house.setSquareFeet(1400);
|
||||
house.setReservation_start_date(ZonedDateTime.of(2025, 07, 05, 10, 0, 0, 0, ZoneId.of("UTC")));
|
||||
house.setReservation_end_date(ZonedDateTime.of(2025, 11, 30, 22, 0, 0, 0, ZoneId.of("UTC")));
|
||||
boolean success3 = mgr.addReservation(mgr.retrieveAccount(acct.account_number()), house);
|
||||
assert success3;
|
||||
|
||||
Reservation rsrv = (Reservation) cabin;
|
||||
try {
|
||||
assert mgr.addReservation(acct, cabin);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Error: cabin already in list.");
|
||||
}
|
||||
|
||||
mgr.UpdateAccount(mgr.retrieveAccount(acct.account_number()));
|
||||
|
||||
// 6. Complete reservation that is associated with an account
|
||||
rsrv = mgr.retreiveReservation(reservationId);
|
||||
rsrv = mgr.retreiveReservation(cabin.getReservation_number());
|
||||
rsrv.Complete();
|
||||
|
||||
mgr.UpdateAccount(mgr.retrieveAccount(acct.account_number()));
|
||||
mgr.UpdateAccount(mgr.retrieveAccount(acct.account_number()));
|
||||
|
||||
// 7. Cancel reservation that is associated with an account
|
||||
rsrv = mgr.retreiveReservation(reservationId);
|
||||
rsrv = mgr.retreiveReservation(cabin.getReservation_number());
|
||||
rsrv.Cancel();
|
||||
mgr.UpdateAccount(mgr.retrieveAccount(acct.account_number()));
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user