From 020bdb2be9cae939584226b07b18343cc25cd220 Mon Sep 17 00:00:00 2001 From: Sherwin Price Date: Wed, 27 Aug 2025 18:32:02 -0400 Subject: [PATCH] changed --- src/lodge/TestReservations.java | 18 +++++++++++------- src/lodge/reservationsystem/Accounts.java | 12 ++++++------ .../ReservationSystemManager.java | 8 ++++++++ 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/lodge/TestReservations.java b/src/lodge/TestReservations.java index 65edda2..3e69fa2 100644 --- a/src/lodge/TestReservations.java +++ b/src/lodge/TestReservations.java @@ -1,19 +1,22 @@ package lodge; +import lodge.reservationsystem.Account; +import lodge.reservationsystem.Address; +import lodge.reservationsystem.EmailAddress; //import lodge.reservationsystem.Address; //import lodge.reservationsystem.EmailAddress; import lodge.reservationsystem.ReservationSystemManager; public final class TestReservations { public static void main(String[] args) throws Exception { -/* + ReservationSystemManager mgr = new ReservationSystemManager(); mgr.setDataStoreRoot("~/data"); // 1. Get the list of loaded accounts from Manager - mgr.retrieveAccounts(); + mgr.loadAll(); // 2. Retrieve a loaded account object that matches a specific account number @@ -23,18 +26,19 @@ public final class TestReservations { // already exists on add action with the same account number, it is considered // an error) - mgr.UpdateAccount( mgr.newAccount("456-7890", new Address(), new EmailAddress() )); - */ + mgr.newAccount( "456-7890", new Address(), new EmailAddress() ); + // 4. Request that Manager updates specific account’s files with data stored in // memory // 5. Add draft lodging reservation to an account (if reservation object already // exists with the same reservation number, it is considered an error) + Account acct = mgr.retrieveAccount("A######"); + + mgr.UpdateAccount( mgr.retrieveAccount("A######") ); -/* - acct = mgr.retrieveAccount("A######"); - if (acct != null) +/* if (acct != null) acct.addReservation(new HotelReservation()); // 6. Complete reservation that is associated with an account diff --git a/src/lodge/reservationsystem/Accounts.java b/src/lodge/reservationsystem/Accounts.java index d793de2..fad8b8f 100644 --- a/src/lodge/reservationsystem/Accounts.java +++ b/src/lodge/reservationsystem/Accounts.java @@ -5,12 +5,6 @@ import java.util.Optional; public class Accounts extends ArrayList { - // ** Find account return null not-existing. */ - public Account retrieveAccount(Accounts account_list, String account_number) { - Optional account = account_list.stream().filter(e -> e.getAnumber() == account_number).findFirst(); - return account.isPresent() ? account.get() : null; - } - // ** Add account throw error if account number is pre-existing. */ public Account addAccount(Accounts account_list, Account account) throws NullPointerException, Exception { @@ -31,4 +25,10 @@ public class Accounts extends ArrayList { public static void save(Accounts account_list, Account acct) { } + + // ** Find account return null not-existing. */ + public static Account retrieveAccount(Accounts account_list, String account_number) { + Optional account = account_list.stream().filter(e -> e.getAnumber() == account_number).findFirst(); + return account.isPresent() ? account.get() : null; + } } diff --git a/src/lodge/reservationsystem/ReservationSystemManager.java b/src/lodge/reservationsystem/ReservationSystemManager.java index cd66bdb..fd5ff90 100644 --- a/src/lodge/reservationsystem/ReservationSystemManager.java +++ b/src/lodge/reservationsystem/ReservationSystemManager.java @@ -15,6 +15,14 @@ public class ReservationSystemManager { DATASTOREROOT = filePath; } + public void loadAll(){ + + } + + public Account retrieveAccount(String acct_id){ + return Accounts.retrieveAccount( account_list, acct_id ); + } + public void UpdateAccount(Account acct) { Accounts.save(account_list, acct);