update
This commit is contained in:
@@ -6,8 +6,8 @@ package lodge.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import lodge.reservation.Reservation;
|
||||
import lodge.reservation.IReservation;
|
||||
import lodge.reservation.Reservation;
|
||||
|
||||
class AccountReservationList extends ArrayList<IReservation> {
|
||||
|
||||
@@ -16,21 +16,24 @@ class AccountReservationList extends ArrayList<IReservation> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean add(final IReservation reservation) throws RuntimeException{
|
||||
public synchronized boolean add(final IReservation reservation) throws RuntimeException {
|
||||
boolean result = true;
|
||||
Reservation rsrv = this.find(reservation.getReservation_number());
|
||||
result = rsrv == null;
|
||||
if( !result ){
|
||||
throw new DuplicateObjectException(String.format("Error No Dups, Reservation exists: %s.", rsrv.getReservation_number()));
|
||||
if (!result) {
|
||||
throw new DuplicateObjectException(
|
||||
String.format("Error No Dups, Reservation exists: %s.", rsrv.getReservation_number()));
|
||||
}
|
||||
result = ((IReservation)reservation).checkValid();
|
||||
result = ((IReservation) reservation).checkValid();
|
||||
|
||||
if(result){
|
||||
((Reservation)reservation).setReservation_number(AccountReservationList.reservationSerial((Reservation)reservation));
|
||||
((Reservation)reservation).setPrice(reservation.calculatePrice());
|
||||
if (result) {
|
||||
((Reservation) reservation)
|
||||
.setReservation_number(AccountReservationList.reservationSerial((Reservation) reservation));
|
||||
((Reservation) reservation).setPrice(reservation.calculatePrice());
|
||||
result = super.add(reservation);
|
||||
}else{
|
||||
throw new IllegalArgumentException(String.format("error reservation invalid: %s", ((Reservation)reservation).getReservation_number()));
|
||||
} else {
|
||||
throw new IllegalArgumentException(String.format("error reservation invalid: %s",
|
||||
((Reservation) reservation).getReservation_number()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -56,9 +59,9 @@ class AccountReservationList extends ArrayList<IReservation> {
|
||||
}
|
||||
|
||||
public Reservation find(String reservation_number) {
|
||||
for(IReservation rsrv: this){
|
||||
if( rsrv.getReservation_number().compareTo(reservation_number) == 0 ){
|
||||
return (Reservation)rsrv;
|
||||
for (IReservation rsrv : this) {
|
||||
if (rsrv.getReservation_number().compareTo(reservation_number) == 0) {
|
||||
return (Reservation) rsrv;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -67,8 +70,8 @@ class AccountReservationList extends ArrayList<IReservation> {
|
||||
public void update(AccountReservationList incoming_reservation_list) {
|
||||
for (IReservation rsrv : incoming_reservation_list) {
|
||||
Reservation onListRsrv = find(rsrv.getReservation_number());
|
||||
if( onListRsrv != null ){
|
||||
onListRsrv.update((Reservation)rsrv);
|
||||
if (onListRsrv != null) {
|
||||
onListRsrv.update((Reservation) rsrv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,41 +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"
|
||||
}
|
||||
},
|
||||
{
|
||||
"CabinReservation": {
|
||||
"reservation_number": "R0535276622"
|
||||
}
|
||||
},
|
||||
{
|
||||
"HouseReservation": {
|
||||
"reservation_number": "R0499811708"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
{ "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"}},{"CabinReservation":{"reservation_number":"R0535276622"}},{"HouseReservation":{"reservation_number":"R0499811708"}}]}}
|
||||
@@ -1,41 +1 @@
|
||||
{
|
||||
"Account": {
|
||||
"account_number": "A2074212339",
|
||||
"phone_number": "301-356-3890",
|
||||
"mailing_address": {
|
||||
"Address": {
|
||||
"street": "30 Amstadam ave",
|
||||
"city": "New York",
|
||||
"state": "NY",
|
||||
"zip": "12010"
|
||||
}
|
||||
},
|
||||
"email_address": {
|
||||
"EmailAddress": {
|
||||
"email": "newbee952@aol.com"
|
||||
}
|
||||
},
|
||||
"reservations": [
|
||||
{
|
||||
"HotelReservation": {
|
||||
"reservation_number": "R0123087344"
|
||||
}
|
||||
},
|
||||
{
|
||||
"CabinReservation": {
|
||||
"reservation_number": "R2042828431"
|
||||
}
|
||||
},
|
||||
{
|
||||
"HotelReservation": {
|
||||
"reservation_number": "R0123087344"
|
||||
}
|
||||
},
|
||||
{
|
||||
"CabinReservation": {
|
||||
"reservation_number": "R2042828431"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
{ "Account":{"account_number": "A2074212339","phone_number": "301-356-3890","mailing_address": { "Address":{"street": "30 Amstadam ave","city": "New York","state": "NY","zip": "12010"}},"email_address": { "EmailAddress":{"email": "newbee952@aol.com"}},"reservations":[{"HotelReservation":{"reservation_number":"R0123087344"}},{"CabinReservation":{"reservation_number":"R2042828431"}},{"HotelReservation":{"reservation_number":"R0123087344"}},{"CabinReservation":{"reservation_number":"R2042828431"}}]}}
|
||||
@@ -1,129 +1,100 @@
|
||||
digraph G {
|
||||
fontname = "Bitstream Vera Sans"
|
||||
fontsize = 8
|
||||
|
||||
fontname="Bitstream Vera Sans"
|
||||
fontsize=8
|
||||
node [
|
||||
fontname = "Bitstream Vera Sans"
|
||||
fontsize = 8
|
||||
shape = "record"
|
||||
fontname="Bitstream Vera Sans"
|
||||
fontsize=8
|
||||
shape=record,
|
||||
]
|
||||
|
||||
edge [
|
||||
fontname = "Bitstream Vera Sans"
|
||||
fontsize = 8
|
||||
fontname="Bitstream Vera Sans"
|
||||
fontsize=8
|
||||
]
|
||||
|
||||
rankdir = BT
|
||||
|
||||
// Interfaces
|
||||
IReservation [
|
||||
label = "{<<interface>>\nIReservation|+ ReservationType()\l+ checkValid()\l+ calculatePrice()\l+ getReservation_number()\l+ getAccountNumber()\l+ getPhysical_address()\l}"
|
||||
style=filled, fillcolor=lightblue
|
||||
];
|
||||
label="{<<Interface>>\nIReservation|+ ReservationType(): String\l+ getReservation_number(): String\l+ getAccountNumber(): String\l+ getPhysical_address(): Address\l+ calculatePrice(): float\l+ checkValid(): boolean\l}"
|
||||
]
|
||||
|
||||
// Abstract Classes
|
||||
Reservation [
|
||||
label = "{<<abstract>>\nReservation|- type: char\l- reservation_number: String\l- physical_address: Address\l- mailing_address: Address\l- reservation_start_date: ZonedDateTime\l- reservation_end_date: ZonedDateTime\l- reservation_status: ReservationStatusEnum\l- kitchen: KitchenTypeEnum\l- numberOfBeds: Integer\l- ...\l- price: Float\l- accountNumber: String\l|+ getReservation_number()\l+ setReservation_number()\l+ ...\l+ Write()\l+ Change()\l+ update()\l# ReservationType()\l}"
|
||||
style=filled, fillcolor=lightgrey
|
||||
];
|
||||
label="{Abstract\nReservation|- type: char\l- reservation_number: String\l- physical_address: Address\l- mailing_address: Address\l- reservation_start_date: ZonedDateTime\l- reservation_end_date: ZonedDateTime\l- reservation_status: ReservationStatusEnum\l- kitchen: KitchenTypeEnum\l- numberOfBeds: Integer\l- price: Float\l# accountNumber: String\l|+ setReservation_number(String): void\l+ getReservation_number(): String\l+ setAccountNumber(String): void\l+ getAccountNumber(): String\l+ Write(Reservation): void\l+ Change(Reservation, ReservationStatusEnum): void\l+ update(Reservation): void\l+ calculatePrice(): float\l+ ReservationType(): String\l}"
|
||||
]
|
||||
|
||||
// Concrete Classes
|
||||
HotelReservation [
|
||||
label = "{HotelReservation|+ calculatePrice()\l+ checkValid()\l+ ReservationType()\l}"
|
||||
];
|
||||
label="{HotelReservation|+ ReservationType(): String\l+ checkValid(): boolean\l+ calculatePrice(): float\l}"
|
||||
]
|
||||
|
||||
HouseReservation [
|
||||
label = "{HouseReservation|+ calculatePrice()\l+ checkValid()\l+ ReservationType()\l}"
|
||||
];
|
||||
label="{HouseReservation|+ ReservationType(): String\l+ checkValid(): boolean\l+ calculatePrice(): float\l}"
|
||||
]
|
||||
|
||||
CabinReservation [
|
||||
label = "{CabinReservation|+ calculatePrice()\l+ checkValid()\l+ ReservationType()\l}"
|
||||
];
|
||||
label="{CabinReservation|+ ReservationType(): String\l+ checkValid(): boolean\l+ calculatePrice(): float\l}"
|
||||
]
|
||||
|
||||
Account [
|
||||
label = "{Account|- account_number: String\l- phone_number: String\l- mailing_address: Address\l- email_address: EmailAddress\l- reservations: AccountReservationList\l|+ add(Reservation)\l+ Write(Account)\l+ findReservation(String)\l+ ...\l}"
|
||||
];
|
||||
label="{Account|- account_number: String\l- phone_number: String\l- mailing_address: Address\l- email_address: EmailAddress\l- reservations: AccountReservationList\l|+ add(Reservation): boolean\l+ Write(Account): void\l+ findReservation(String): Reservation\l+ getAllReservations(): ListIterator<IReservation>\l}"
|
||||
]
|
||||
|
||||
AccountList [
|
||||
label = "{AccountList|+ add(Account)\l+ save(Account)\l+ find(String)\l+ getListOfReservations()\l}"
|
||||
];
|
||||
label="{AccountList|+ add(Account): boolean\l+ save(Account): void\l+ find(String): Account\l+ getListOfReservations(): List<IReservation>\l}"
|
||||
]
|
||||
|
||||
AccountReservationList [
|
||||
label = "{AccountReservationList|+ add(IReservation)\l+ find(String)\l+ update(...)\l}"
|
||||
];
|
||||
label="{AccountReservationList|+ add(IReservation): boolean\l+ find(String): Reservation\l+ update(AccountReservationList): void\l}"
|
||||
]
|
||||
|
||||
AccomodationManager [
|
||||
label = "{AccomodationManager|- accounts: AccountList\l|+ loadAll()\l+ retrieveAccount(String)\l+ AddAccount(Account)\l+ addReservation(Account, Reservation)\l+ findReservation(String)\l}"
|
||||
];
|
||||
label="{AccomodationManager|- accounts: AccountList\l|+ loadAll(): void\l+ retrieveAccount(String): Account\l+ AddAccount(Account): void\l+ UpdateAccount(Account): void\l+ addReservation(Account, Reservation): boolean\l+ findReservation(String): Reservation\l}"
|
||||
]
|
||||
|
||||
DataRepository [
|
||||
label = "{<<static>>\nDataRepository|- instance: DataRepository\l- directoryPath: String\l|+ getInstance()\l+ setDataStoreRoot(String)\l+ getPath()\l+ Reservation(String)\l+ WalkFileSystemTree(...)\l+ LoadAccount(Path)\l}"
|
||||
];
|
||||
label="{<<Singleton>>\nDataRepository|- directoryPath: String\l|+ setDataStoreRoot(String): void\l+ getPath(): String\l+ Reservation(String): Reservation\l+ LoadAccount(Path): Account\l- loadReservation(...): void\l}"
|
||||
]
|
||||
|
||||
Address [
|
||||
label="{Address|- street: String\l- city: String\l- state: String\l- zip: String\l}"
|
||||
]
|
||||
|
||||
EmailAddress [
|
||||
label="{EmailAddress|- email_address: String\l}"
|
||||
]
|
||||
|
||||
TestReservations [
|
||||
label = "{TestReservations|+ main(String[])\l}"
|
||||
];
|
||||
label="{TestReservations|+ main(String[]): void\l}"
|
||||
]
|
||||
|
||||
// Data/Value Objects
|
||||
Address [
|
||||
label = "{Address|- street: String\l- city: String\l- state: String\l- zip: String\l}"
|
||||
shape=box, style=filled, fillcolor=beige
|
||||
];
|
||||
EmailAddress [
|
||||
label = "{EmailAddress|- email: String\l}"
|
||||
shape=box, style=filled, fillcolor=beige
|
||||
];
|
||||
|
||||
// Enums
|
||||
KitchenTypeEnum [
|
||||
label = "{<<enum>>\nKitchenTypeEnum|None\l|Kitchenette\l|FullKitchen\l}"
|
||||
shape=box, style=filled, fillcolor=lightyellow
|
||||
];
|
||||
// Enumerations
|
||||
ReservationStatusEnum [
|
||||
label = "{<<enum>>\nReservationStatusEnum|Draft\l|Completed\l|Canceled\l}"
|
||||
shape=box, style=filled, fillcolor=lightyellow
|
||||
];
|
||||
label="{<<Enumeration>>\nReservationStatusEnum|Draft\lCanceled\lCompleted\l}"
|
||||
]
|
||||
|
||||
KitchenTypeEnum [
|
||||
label="{<<Enumeration>>\nKitchenTypeEnum|None\lKitchenette\lFullKitchen\l}"
|
||||
]
|
||||
|
||||
// Relationships
|
||||
|
||||
// Inheritance
|
||||
edge [arrowhead=empty, style=solid];
|
||||
edge [arrowhead=empty, arrowtail=none]
|
||||
HotelReservation -> Reservation;
|
||||
HouseReservation -> Reservation;
|
||||
CabinReservation -> Reservation;
|
||||
AccountList -> "java.util.ArrayList<Account>" [style=dashed, label="extends"];
|
||||
AccountReservationList -> "java.util.ArrayList<IReservation>" [style=dashed, label="extends"];
|
||||
|
||||
// Implementation
|
||||
edge [arrowhead=empty, style=dashed];
|
||||
Reservation -> IReservation;
|
||||
edge [arrowhead=empty, arrowtail=odiamond]
|
||||
AccomodationManager -> AccountList [label="1"];
|
||||
Account -> Address [label="1..2"];
|
||||
Account -> EmailAddress [label="1"];
|
||||
Account -> AccountReservationList [label="1"];
|
||||
Reservation -> Address [label="2"];
|
||||
Reservation -> ReservationStatusEnum [label="1"];
|
||||
Reservation -> KitchenTypeEnum [label="1"];
|
||||
|
||||
// Composition
|
||||
edge [arrowhead=diamond, style=solid];
|
||||
AccomodationManager -> AccountList [label="1..1 accounts"];
|
||||
Account -> AccountReservationList [label="1..1 reservations"];
|
||||
Account -> Address [label="1..1 mailing_address"];
|
||||
Account -> EmailAddress [label="1..1 email_address"];
|
||||
|
||||
// Aggregation
|
||||
edge [arrowhead=odiamond, style=solid];
|
||||
edge [arrowhead=odiamond, arrowtail=diamond]
|
||||
AccountList -> Account [arrowtail=odiamond,label="0..*"];
|
||||
AccountReservationList -> IReservation [label="0..*"];
|
||||
AccountList -> Account [label="0..*"];
|
||||
Reservation -> Address [label="0..2\n(physical, mailing)"];
|
||||
|
||||
// Dependency
|
||||
edge [arrowhead=vee, style=dashed];
|
||||
edge [arrowhead=vee, style=dashed]
|
||||
Reservation -> IReservation [arrowtail=empty, style=dashed, dir=back, arrowhead=none];
|
||||
AccomodationManager -> DataRepository [label="uses"];
|
||||
AccomodationManager -> Account;
|
||||
TestReservations -> AccomodationManager [label="uses"];
|
||||
TestReservations -> HotelReservation [label="creates"];
|
||||
TestReservations -> HouseReservation [label="creates"];
|
||||
TestReservations -> CabinReservation [label="creates"];
|
||||
DataRepository -> AccomodationManager [label="uses"];
|
||||
DataRepository -> Account [label="creates"];
|
||||
DataRepository -> HotelReservation [label="creates"];
|
||||
DataRepository -> HouseReservation [label="creates"];
|
||||
DataRepository -> CabinReservation [label="creates"];
|
||||
Account -> DataRepository [label="uses"];
|
||||
Reservation -> DataRepository [label="uses"];
|
||||
Reservation -> KitchenTypeEnum [label="uses"];
|
||||
Reservation -> ReservationStatusEnum [label="uses"];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user