81 lines
3.2 KiB
Java
81 lines
3.2 KiB
Java
|
|
package lodge;
|
|||
|
|
|
|||
|
|
import java.net.URI;
|
|||
|
|
|
|||
|
|
import lodge.reservationsystem.AccomodationManager;
|
|||
|
|
import lodge.reservationsystem.Account;
|
|||
|
|
import lodge.reservationsystem.Address;
|
|||
|
|
import lodge.reservationsystem.DataRepository;
|
|||
|
|
import lodge.reservationsystem.EmailAddress;
|
|||
|
|
|
|||
|
|
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"));
|
|||
|
|
|
|||
|
|
// 4. Request that Manager updates specific account’s files with data stored in
|
|||
|
|
// memory
|
|||
|
|
mgr.AddAccount(acct);
|
|||
|
|
// 5. Add draft lodging reservation to an account (if reservation object already
|
|||
|
|
// exists with the same reservation number, it is considered an error)
|
|||
|
|
|
|||
|
|
mgr.UpdateAccount(mgr.retrieveAccount(acct.account_number()));
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
* if (acct != null)
|
|||
|
|
* acct.addReservation(new HotelReservation());
|
|||
|
|
*
|
|||
|
|
* // 6. Complete reservation that is associated with an account
|
|||
|
|
* Reservation rsrv = null;
|
|||
|
|
* acct = null;
|
|||
|
|
* acct = mgr.retrieveAccount("A######");
|
|||
|
|
* if (acct != null) {
|
|||
|
|
* rsrv = acct.retrieve("?######");
|
|||
|
|
* rsrv.Complete();
|
|||
|
|
* }
|
|||
|
|
*
|
|||
|
|
* // 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.");
|
|||
|
|
}
|
|||
|
|
}
|