diff --git a/TestAccountLoadSequence.dot b/TestAccountLoadSequence.dot new file mode 100755 index 0000000..e69de29 diff --git a/src/java/lodge/TestAccountLoad.java b/src/java/lodge/TestAccountLoad.java new file mode 100755 index 0000000..d147de6 --- /dev/null +++ b/src/java/lodge/TestAccountLoad.java @@ -0,0 +1,60 @@ +/** + * license: GPLv3 + * lodge.reservationsystem +*/ + +package lodge; + +import lodge.data.Account; +import lodge.data.Address; +import lodge.data.EmailAddress; +import lodge.reservationsystem.AccomodationManager; + +/** + * The Tests for the ReservationSystem Module + * + *

+ * This class main function acts as a driver function to run the test functions. + *

+ * + * @author Sherwin Price + * @version 1.0 + * @since 2025 + */ +public final class TestAccountLoad { + // Request that Manager updates specific account’s files with data stored in + static void Test_AddAccount(AccomodationManager mgr, Account acct) throws Exception { + mgr.AddAccount(acct); + + // 4. Request that Manager updates specific account’s files with data stored in + // memory + mgr.UpdateAccount(acct); + } + public static void main(String[] args) throws Exception { + + // Configure data repository + AccomodationManager mgr = new AccomodationManager(getRepositoryConfig.getPath()); + + // 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) + Test_AddAccount(mgr, mgr.newAccount("701-456-7890", + new Address("10 wilco ave", "wilco", "WY", "82801"), + new EmailAddress("wilco@wyommin.net"))); + + Test_AddAccount(mgr, mgr.newAccount("701-456-7890", + new Address("10 wilco ave", "wilco", "WY", "82801"), + new EmailAddress("wilco@wyommin.net"))); + + mgr.showAccountList(); + System.out.println("Program Completed."); + } + + public final static class getRepositoryConfig { + public final static String getPath() { + String home = System.getenv("HOME") != null ? System.getenv("HOME") + : System.getenv("HOMEDRIVE") + System.getenv("HOMEPATH"); + return home.replace('\\', '/') + "/workspace/reservationsystem/src/resources"; + } + } +} diff --git a/src/java/lodge/TestReservations.java b/src/java/lodge/TestReservations.java index b0b0323..a54bbae 100644 --- a/src/java/lodge/TestReservations.java +++ b/src/java/lodge/TestReservations.java @@ -139,6 +139,8 @@ public final class TestReservations { // 9. Request for price per night to be calculated and returned for a // per night // reservation + System.out.println(String.format("%s Per Night Rate: %f", + rsrv.ReservationType().replace("Reservation", ""), rsrv.getPricePerNight())); // 10. Request for total reservation price to be calculated and returned for // specific reservation diff --git a/src/java/lodge/data/AccountList.java b/src/java/lodge/data/AccountList.java old mode 100644 new mode 100755 index d238f14..de39859 --- a/src/java/lodge/data/AccountList.java +++ b/src/java/lodge/data/AccountList.java @@ -65,10 +65,18 @@ public class AccountList extends ArrayList { return Collections.unmodifiableList(readList); } + // Show the different accounts lists of resverations public void showReservationList() { for (IReservation irsrv : this.getListOfReservations()) { System.out.println(String.format("Account %s: %s, %s", irsrv.getAccountNumber(), irsrv.getReservation_number(), irsrv.getPhysical_address().getStreet())); } } + + // show the accounts + public void showAccountList() { + for (Account acct : this) { + System.out.println(String.format("Account %s", acct.getAccount_number())); + } + } } diff --git a/src/java/lodge/data/AccountReservationList.java b/src/java/lodge/data/AccountReservationList.java old mode 100644 new mode 100755 diff --git a/src/java/lodge/reservationsystem/AccomodationManager.java b/src/java/lodge/reservationsystem/AccomodationManager.java index 76b7fe3..cb44cdf 100644 --- a/src/java/lodge/reservationsystem/AccomodationManager.java +++ b/src/java/lodge/reservationsystem/AccomodationManager.java @@ -104,4 +104,8 @@ public final class AccomodationManager { accounts.showReservationList(); } + public void showAccountList() { + accounts.showAccountList(); + } + } \ No newline at end of file diff --git a/src/java/lodge/reservationsystem/CabinReservation.java b/src/java/lodge/reservationsystem/CabinReservation.java index 40867aa..f708a70 100644 --- a/src/java/lodge/reservationsystem/CabinReservation.java +++ b/src/java/lodge/reservationsystem/CabinReservation.java @@ -51,7 +51,14 @@ public final class CabinReservation extends Reservation { @Override public float getPricePerNight() { - return 0.0f; + float calcprice = (getSquareFeet() > 900.0f) ? 120.0f + 15.0f : 120.0f; + if (getKitchen() == KitchenTypeEnum.FullKitchen) { + calcprice = calcprice + 20.0f; + } + if (getNumberOfBathRooms() > 1) { + setPrice(getPrice() + (getNumberOfBathRooms() * 5.0f)); + } + return calcprice; } // calculate and return the reservation's price @@ -62,7 +69,9 @@ public final class CabinReservation extends Reservation { ZonedDateTime enddt = getReservation_end_date().truncatedTo(ChronoUnit.DAYS); ZonedDateTime startdt = getReservation_start_date().truncatedTo(ChronoUnit.DAYS); long days = ChronoUnit.DAYS.between(startdt, enddt); + days = (days < 2) ? 1 : days - 1; + float calcprice = (getSquareFeet() > 900.0f) ? 120.0f + 15.0f : 120.0f; if (getKitchen() == KitchenTypeEnum.FullKitchen) { calcprice = calcprice + 20.0f; diff --git a/src/java/lodge/reservationsystem/HotelReservation.java b/src/java/lodge/reservationsystem/HotelReservation.java index b438188..a6727f7 100644 --- a/src/java/lodge/reservationsystem/HotelReservation.java +++ b/src/java/lodge/reservationsystem/HotelReservation.java @@ -73,7 +73,11 @@ public final class HotelReservation extends Reservation { @Override public float getPricePerNight() { - return 0.0f; + float calcprice = (getSquareFeet() > 900.0f) ? 120.0f + 15.0f : 120.0f; + if (getKitchen() == KitchenTypeEnum.FullKitchen) { + calcprice = calcprice + 10.0f; + } + return calcprice; } // calculate and return the reservation's price diff --git a/src/java/lodge/reservationsystem/HouseReservation.java b/src/java/lodge/reservationsystem/HouseReservation.java index 95e652f..51d3c7b 100644 --- a/src/java/lodge/reservationsystem/HouseReservation.java +++ b/src/java/lodge/reservationsystem/HouseReservation.java @@ -71,7 +71,9 @@ public final class HouseReservation extends Reservation { ZonedDateTime enddt = getReservation_end_date().truncatedTo(ChronoUnit.DAYS); ZonedDateTime startdt = getReservation_start_date().truncatedTo(ChronoUnit.DAYS); long days = ChronoUnit.DAYS.between(startdt, enddt); + days = (days < 2) ? 1 : days - 1; + float calcprice = getPricePerNight() * days; return calcprice; } diff --git a/src/resources/acc-A1450981765.json b/src/resources/acc-A1450981765.json old mode 100644 new mode 100755 index e9fcb96..64286ac --- a/src/resources/acc-A1450981765.json +++ b/src/resources/acc-A1450981765.json @@ -1 +1 @@ -{ "Account":{"account_number": "A1450981765","phone_number": "701-456-7890","mailing_address": { "Address":{"street": "10 wilco ave","city": "wilco","state": "WY","zip": "82801"}},"email_address": { "EmailAddress":{"email": "wilco@wyommin.net"}},"reservations":[{"CabinReservation":{"reservation_number":"R0535276622"}},{"HouseReservation":{"reservation_number":"R0499811708"}}]}} \ No newline at end of file +{ "Account":{"account_number": "A1450981765","phone_number": "701-456-7890","mailing_address": { "Address":{"street": "10 wilco ave","city": "wilco","state": "WY","zip": "82801"}},"email_address": { "EmailAddress":{"email": "wilco@wyommin.net"}},"reservations":[]}} \ No newline at end of file diff --git a/src/resources/acc-A2074212339.json b/src/resources/acc-A2074212339.json old mode 100644 new mode 100755 diff --git a/src/resources/rsv-R0123087344.json b/src/resources/rsv-R0123087344.json old mode 100644 new mode 100755 diff --git a/src/resources/rsv-R0499811708.json b/src/resources/rsv-R0499811708.json old mode 100644 new mode 100755 diff --git a/src/resources/rsv-R0535276622.json b/src/resources/rsv-R0535276622.json old mode 100644 new mode 100755 diff --git a/src/resources/rsv-R2042828431.json b/src/resources/rsv-R2042828431.json old mode 100644 new mode 100755 diff --git a/uml/sequencediagram.dot b/uml/sequencediagram.dot new file mode 100755 index 0000000..bbbd57d --- /dev/null +++ b/uml/sequencediagram.dot @@ -0,0 +1,77 @@ +digraph TestAccountLoadSequence { + { + // Make sure they're on the same row + rank=same; + // Style the actor nodes + node [shape=box]; + + actor1_top [label="TestAddAccount"]; + actor2_top [label="AccomondationManager"]; + actor3_top [label="AccountList"]; + + // Tie them together in the right order + edge [style = invis]; + actor1_top -> actor2_top -> actor3_top; + } + + // Define the actor nodes in the bottom. This is a copy paste + //of the top subgraph - s/top/bottom/g + { + rank=same; + node [shape=box]; + + actor1_bottom [label="TestAddAccount"]; + actor2_bottom [label="AccomondationManager"]; + actor3_bottom [label="AccountList"]; + + edge [style = invis]; + actor1_bottom -> actor2_bottom -> actor3_bottom; + } + + // Style the event nodes + node [shape=point]; + edge [arrowhead=none]; + + // Define the event nodes. Here they are prefixed with + // the actor name. + actor1_event1 + actor1_event3 + + // Now we connect each of the events like pearls on a string. + actor1_top -> + actor1_event1 -> + actor1_event3 -> + actor1_bottom; + + // Repeat. The event above has a corresponding node in the + // destination actor. + actor2_event1 + actor2_event2 + + actor2_top -> + actor2_event1 -> + actor2_event2 -> + actor2_bottom; + + // And one more time. + actor3_event2 + actor3_event3 + + actor3_top -> + actor3_event2 -> + actor3_event3 -> + actor3_bottom; + + // We connect each event src/dest. First we make sure they + // are vertically aligned. + {rank=same; actor1_event1 actor2_event1} + {rank=same; actor2_event2 actor3_event2} + {ranke=same; actor3_event3 actor1_event3} + + // Finally, we connect the dots. + edge [constraint=false, arrowhead=normal]; + + actor1_event1 -> actor2_event1 [xlabel="AddAccount(Acount)"]; + actor2_event2 -> actor3_event2 [xlabel="add"]; + actor3_event3 -> actor1_event3 [xlabel="return"]; +}