changed
This commit is contained in:
@@ -1,19 +1,22 @@
|
|||||||
package lodge;
|
package lodge;
|
||||||
|
|
||||||
|
import lodge.reservationsystem.Account;
|
||||||
|
import lodge.reservationsystem.Address;
|
||||||
|
import lodge.reservationsystem.EmailAddress;
|
||||||
//import lodge.reservationsystem.Address;
|
//import lodge.reservationsystem.Address;
|
||||||
//import lodge.reservationsystem.EmailAddress;
|
//import lodge.reservationsystem.EmailAddress;
|
||||||
import lodge.reservationsystem.ReservationSystemManager;
|
import lodge.reservationsystem.ReservationSystemManager;
|
||||||
|
|
||||||
public final class TestReservations {
|
public final class TestReservations {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
/*
|
|
||||||
ReservationSystemManager mgr = new ReservationSystemManager();
|
ReservationSystemManager mgr = new ReservationSystemManager();
|
||||||
|
|
||||||
mgr.setDataStoreRoot("~/data");
|
mgr.setDataStoreRoot("~/data");
|
||||||
|
|
||||||
// 1. Get the list of loaded accounts from Manager
|
// 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
|
// 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
|
// already exists on add action with the same account number, it is considered
|
||||||
// an error)
|
// 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
|
// 4. Request that Manager updates specific account’s files with data stored in
|
||||||
// memory
|
// memory
|
||||||
|
|
||||||
// 5. Add draft lodging reservation to an account (if reservation object already
|
// 5. Add draft lodging reservation to an account (if reservation object already
|
||||||
// exists with the same reservation number, it is considered an error)
|
// exists with the same reservation number, it is considered an error)
|
||||||
|
Account acct = mgr.retrieveAccount("A######");
|
||||||
|
|
||||||
|
mgr.UpdateAccount( mgr.retrieveAccount("A######") );
|
||||||
|
|
||||||
/*
|
/* if (acct != null)
|
||||||
acct = mgr.retrieveAccount("A######");
|
|
||||||
if (acct != null)
|
|
||||||
acct.addReservation(new HotelReservation());
|
acct.addReservation(new HotelReservation());
|
||||||
|
|
||||||
// 6. Complete reservation that is associated with an account
|
// 6. Complete reservation that is associated with an account
|
||||||
|
|||||||
@@ -5,12 +5,6 @@ import java.util.Optional;
|
|||||||
|
|
||||||
public class Accounts extends ArrayList<Account> {
|
public class Accounts extends ArrayList<Account> {
|
||||||
|
|
||||||
// ** Find account return null not-existing. */
|
|
||||||
public Account retrieveAccount(Accounts account_list, String account_number) {
|
|
||||||
Optional<Account> 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. */
|
// ** Add account throw error if account number is pre-existing. */
|
||||||
public Account addAccount(Accounts account_list, Account account) throws NullPointerException, Exception {
|
public Account addAccount(Accounts account_list, Account account) throws NullPointerException, Exception {
|
||||||
|
|
||||||
@@ -31,4 +25,10 @@ public class Accounts extends ArrayList<Account> {
|
|||||||
public static void save(Accounts account_list, Account acct) {
|
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 = account_list.stream().filter(e -> e.getAnumber() == account_number).findFirst();
|
||||||
|
return account.isPresent() ? account.get() : null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,14 @@ public class ReservationSystemManager {
|
|||||||
DATASTOREROOT = filePath;
|
DATASTOREROOT = filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void loadAll(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Account retrieveAccount(String acct_id){
|
||||||
|
return Accounts.retrieveAccount( account_list, acct_id );
|
||||||
|
}
|
||||||
|
|
||||||
public void UpdateAccount(Account acct) {
|
public void UpdateAccount(Account acct) {
|
||||||
|
|
||||||
Accounts.save(account_list, acct);
|
Accounts.save(account_list, acct);
|
||||||
|
|||||||
Reference in New Issue
Block a user