update
This commit is contained in:
@@ -6,8 +6,8 @@ package lodge.data;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import lodge.reservation.Reservation;
|
|
||||||
import lodge.reservation.IReservation;
|
import lodge.reservation.IReservation;
|
||||||
|
import lodge.reservation.Reservation;
|
||||||
|
|
||||||
class AccountReservationList extends ArrayList<IReservation> {
|
class AccountReservationList extends ArrayList<IReservation> {
|
||||||
|
|
||||||
@@ -16,21 +16,24 @@ class AccountReservationList extends ArrayList<IReservation> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean add(final IReservation reservation) throws RuntimeException{
|
public synchronized boolean add(final IReservation reservation) throws RuntimeException {
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
Reservation rsrv = this.find(reservation.getReservation_number());
|
Reservation rsrv = this.find(reservation.getReservation_number());
|
||||||
result = rsrv == null;
|
result = rsrv == null;
|
||||||
if( !result ){
|
if (!result) {
|
||||||
throw new DuplicateObjectException(String.format("Error No Dups, Reservation exists: %s.", rsrv.getReservation_number()));
|
throw new DuplicateObjectException(
|
||||||
|
String.format("Error No Dups, Reservation exists: %s.", rsrv.getReservation_number()));
|
||||||
}
|
}
|
||||||
result = ((IReservation)reservation).checkValid();
|
result = ((IReservation) reservation).checkValid();
|
||||||
|
|
||||||
if(result){
|
if (result) {
|
||||||
((Reservation)reservation).setReservation_number(AccountReservationList.reservationSerial((Reservation)reservation));
|
((Reservation) reservation)
|
||||||
((Reservation)reservation).setPrice(reservation.calculatePrice());
|
.setReservation_number(AccountReservationList.reservationSerial((Reservation) reservation));
|
||||||
|
((Reservation) reservation).setPrice(reservation.calculatePrice());
|
||||||
result = super.add(reservation);
|
result = super.add(reservation);
|
||||||
}else{
|
} else {
|
||||||
throw new IllegalArgumentException(String.format("error reservation invalid: %s", ((Reservation)reservation).getReservation_number()));
|
throw new IllegalArgumentException(String.format("error reservation invalid: %s",
|
||||||
|
((Reservation) reservation).getReservation_number()));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -56,9 +59,9 @@ class AccountReservationList extends ArrayList<IReservation> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Reservation find(String reservation_number) {
|
public Reservation find(String reservation_number) {
|
||||||
for(IReservation rsrv: this){
|
for (IReservation rsrv : this) {
|
||||||
if( rsrv.getReservation_number().compareTo(reservation_number) == 0 ){
|
if (rsrv.getReservation_number().compareTo(reservation_number) == 0) {
|
||||||
return (Reservation)rsrv;
|
return (Reservation) rsrv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -67,8 +70,8 @@ class AccountReservationList extends ArrayList<IReservation> {
|
|||||||
public void update(AccountReservationList incoming_reservation_list) {
|
public void update(AccountReservationList incoming_reservation_list) {
|
||||||
for (IReservation rsrv : incoming_reservation_list) {
|
for (IReservation rsrv : incoming_reservation_list) {
|
||||||
Reservation onListRsrv = find(rsrv.getReservation_number());
|
Reservation onListRsrv = find(rsrv.getReservation_number());
|
||||||
if( onListRsrv != null ){
|
if (onListRsrv != null) {
|
||||||
onListRsrv.update((Reservation)rsrv);
|
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 {
|
digraph G {
|
||||||
fontname = "Bitstream Vera Sans"
|
fontname="Bitstream Vera Sans"
|
||||||
fontsize = 8
|
fontsize=8
|
||||||
|
|
||||||
node [
|
node [
|
||||||
fontname = "Bitstream Vera Sans"
|
fontname="Bitstream Vera Sans"
|
||||||
fontsize = 8
|
fontsize=8
|
||||||
shape = "record"
|
shape=record,
|
||||||
]
|
]
|
||||||
|
|
||||||
edge [
|
edge [
|
||||||
fontname = "Bitstream Vera Sans"
|
fontname="Bitstream Vera Sans"
|
||||||
fontsize = 8
|
fontsize=8
|
||||||
]
|
]
|
||||||
|
|
||||||
rankdir = BT
|
|
||||||
|
|
||||||
// Interfaces
|
// Interfaces
|
||||||
IReservation [
|
IReservation [
|
||||||
label = "{<<interface>>\nIReservation|+ ReservationType()\l+ checkValid()\l+ calculatePrice()\l+ getReservation_number()\l+ getAccountNumber()\l+ getPhysical_address()\l}"
|
label="{<<Interface>>\nIReservation|+ ReservationType(): String\l+ getReservation_number(): String\l+ getAccountNumber(): String\l+ getPhysical_address(): Address\l+ calculatePrice(): float\l+ checkValid(): boolean\l}"
|
||||||
style=filled, fillcolor=lightblue
|
]
|
||||||
];
|
|
||||||
|
|
||||||
// Abstract Classes
|
// Abstract Classes
|
||||||
Reservation [
|
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}"
|
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}"
|
||||||
style=filled, fillcolor=lightgrey
|
]
|
||||||
];
|
|
||||||
|
|
||||||
// Concrete Classes
|
// Concrete Classes
|
||||||
HotelReservation [
|
HotelReservation [
|
||||||
label = "{HotelReservation|+ calculatePrice()\l+ checkValid()\l+ ReservationType()\l}"
|
label="{HotelReservation|+ ReservationType(): String\l+ checkValid(): boolean\l+ calculatePrice(): float\l}"
|
||||||
];
|
]
|
||||||
|
|
||||||
HouseReservation [
|
HouseReservation [
|
||||||
label = "{HouseReservation|+ calculatePrice()\l+ checkValid()\l+ ReservationType()\l}"
|
label="{HouseReservation|+ ReservationType(): String\l+ checkValid(): boolean\l+ calculatePrice(): float\l}"
|
||||||
];
|
]
|
||||||
|
|
||||||
CabinReservation [
|
CabinReservation [
|
||||||
label = "{CabinReservation|+ calculatePrice()\l+ checkValid()\l+ ReservationType()\l}"
|
label="{CabinReservation|+ ReservationType(): String\l+ checkValid(): boolean\l+ calculatePrice(): float\l}"
|
||||||
];
|
]
|
||||||
|
|
||||||
Account [
|
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 [
|
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 [
|
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 [
|
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 [
|
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 [
|
TestReservations [
|
||||||
label = "{TestReservations|+ main(String[])\l}"
|
label="{TestReservations|+ main(String[]): void\l}"
|
||||||
];
|
]
|
||||||
|
|
||||||
// Data/Value Objects
|
// Enumerations
|
||||||
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
|
|
||||||
];
|
|
||||||
ReservationStatusEnum [
|
ReservationStatusEnum [
|
||||||
label = "{<<enum>>\nReservationStatusEnum|Draft\l|Completed\l|Canceled\l}"
|
label="{<<Enumeration>>\nReservationStatusEnum|Draft\lCanceled\lCompleted\l}"
|
||||||
shape=box, style=filled, fillcolor=lightyellow
|
]
|
||||||
];
|
|
||||||
|
KitchenTypeEnum [
|
||||||
|
label="{<<Enumeration>>\nKitchenTypeEnum|None\lKitchenette\lFullKitchen\l}"
|
||||||
|
]
|
||||||
|
|
||||||
// Relationships
|
// Relationships
|
||||||
|
edge [arrowhead=empty, arrowtail=none]
|
||||||
// Inheritance
|
|
||||||
edge [arrowhead=empty, style=solid];
|
|
||||||
HotelReservation -> Reservation;
|
HotelReservation -> Reservation;
|
||||||
HouseReservation -> Reservation;
|
HouseReservation -> Reservation;
|
||||||
CabinReservation -> 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, arrowtail=odiamond]
|
||||||
edge [arrowhead=empty, style=dashed];
|
AccomodationManager -> AccountList [label="1"];
|
||||||
Reservation -> IReservation;
|
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=odiamond, arrowtail=diamond]
|
||||||
edge [arrowhead=diamond, style=solid];
|
AccountList -> Account [arrowtail=odiamond,label="0..*"];
|
||||||
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];
|
|
||||||
AccountReservationList -> IReservation [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 -> 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