updates cleanup.
This commit is contained in:
@@ -41,7 +41,8 @@ public final class TestReservations {
|
|||||||
// 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)
|
||||||
|
|
||||||
HotelReservation hotel = new HotelReservation(new Address("400 hotel ave", "Maryland City", "CA", "20723"));
|
HotelReservation hotel = new HotelReservation(
|
||||||
|
new Address("400 hotel ave", "Maryland City", "CA", "20723"));
|
||||||
hotel.setMailing_address(new Address("400 hotel ave", "Maryland City", "MD", "20723"));
|
hotel.setMailing_address(new Address("400 hotel ave", "Maryland City", "MD", "20723"));
|
||||||
hotel.setNumberOfBeds(2);
|
hotel.setNumberOfBeds(2);
|
||||||
hotel.setNumberOfFloors(1);
|
hotel.setNumberOfFloors(1);
|
||||||
@@ -67,7 +68,8 @@ public final class TestReservations {
|
|||||||
|
|
||||||
mgr.UpdateAccount(acct);
|
mgr.UpdateAccount(acct);
|
||||||
|
|
||||||
HouseReservation house = new HouseReservation(new Address("3000 Osage ave", "GreenBelt", "MD", "20740"));
|
HouseReservation house = new HouseReservation(
|
||||||
|
new Address("3000 Osage ave", "GreenBelt", "MD", "20740"));
|
||||||
house.setMailing_address(new Address("40012 College ave", "College Park", "MD", "20740"));
|
house.setMailing_address(new Address("40012 College ave", "College Park", "MD", "20740"));
|
||||||
house.setNumberOfBeds(4);
|
house.setNumberOfBeds(4);
|
||||||
house.setNumberOfFloors(3);
|
house.setNumberOfFloors(3);
|
||||||
@@ -80,17 +82,16 @@ public final class TestReservations {
|
|||||||
|
|
||||||
mgr.UpdateAccount(acct);
|
mgr.UpdateAccount(acct);
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mgr.addReservation(acct, cabin);
|
mgr.addReservation(acct, cabin);
|
||||||
mgr.UpdateAccount(mgr.retrieveAccount(acct.getAccount_number()));
|
mgr.UpdateAccount(mgr.retrieveAccount(acct.getAccount_number()));
|
||||||
} catch (DuplicateObjectException e) {
|
} catch (DuplicateObjectException e) {
|
||||||
System.out.println(e.getMessage());
|
System.out.println(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
Account account = mgr.retrieveLoadedAccounts().getFirst();
|
Account account = mgr.retrieveLoadedAccounts().getFirst();
|
||||||
Reservation rsrv = account.getReservation_list().getLast();
|
|
||||||
|
|
||||||
|
Reservation rsrv = account.findReservation(house.getReservation_number());
|
||||||
// 6. Complete reservation that is associated with an account
|
// 6. Complete reservation that is associated with an account
|
||||||
rsrv = mgr.retreiveReservation(rsrv.getReservation_number());
|
rsrv = mgr.retreiveReservation(rsrv.getReservation_number());
|
||||||
rsrv.Change(rsrv, ReservationStatusEnum.Completed);
|
rsrv.Change(rsrv, ReservationStatusEnum.Completed);
|
||||||
@@ -100,29 +101,28 @@ public final class TestReservations {
|
|||||||
rsrv = mgr.retreiveReservation(rsrv.getReservation_number());
|
rsrv = mgr.retreiveReservation(rsrv.getReservation_number());
|
||||||
rsrv.Change(rsrv, ReservationStatusEnum.Canceled);
|
rsrv.Change(rsrv, ReservationStatusEnum.Canceled);
|
||||||
mgr.UpdateAccount(mgr.retrieveAccount(acct.getAccount_number()));
|
mgr.UpdateAccount(mgr.retrieveAccount(acct.getAccount_number()));
|
||||||
/*
|
|
||||||
*
|
// 8. Change reservation values that can be changed (if reservation is
|
||||||
* if (rsrv != null) {
|
// cancelled, completed, or for past date, it is considered an error)
|
||||||
* // 8. Change reservation values that can be changed (if reservation is
|
rsrv.update(rsrv);
|
||||||
* // cancelled, completed, or for past date, it is considered an error)
|
|
||||||
* rsrv = Reservation.update(rsrv);
|
// 9. Request for price per night to be calculated and returned for a
|
||||||
*
|
// per night
|
||||||
* // 9. Request for price per night to be calculated and returned for a
|
// reservation
|
||||||
* specific
|
|
||||||
* // reservation
|
// 10. Request for total reservation price to be calculated and returned for
|
||||||
*
|
// specific reservation
|
||||||
* rsrv = Reservation.calculatePricePerNight(rsrv);
|
rsrv = account.findReservation(house.getReservation_number());
|
||||||
* // 10. Request for total reservation price to be calculated and returned for
|
rsrv.calculatePrice();
|
||||||
* a
|
|
||||||
* // specific reservation
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
System.out.println("Program Completed.");
|
System.out.println("Program Completed.");
|
||||||
}
|
}
|
||||||
public final static class getRepositoryConfig{
|
|
||||||
public final static String getPath(){
|
public final static class getRepositoryConfig {
|
||||||
String home = System.getenv("HOME")!=null? System.getenv("HOME"): System.getenv("HOMEDRIVE") + System.getenv("HOMEPATH");
|
public final static String getPath() {
|
||||||
return home.replace('\\', '/') + "/workspace/reservationsystem/src/resources";
|
String home = System.getenv("HOME") != null ? System.getenv("HOME")
|
||||||
|
: System.getenv("HOMEDRIVE") + System.getenv("HOMEPATH");
|
||||||
|
return home.replace('\\', '/') + "/workspace/reservationsystem/src/resources";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,19 +30,15 @@ public class Account {
|
|||||||
|
|
||||||
private final AccountReservationList reservation_list = new AccountReservationList();;
|
private final AccountReservationList reservation_list = new AccountReservationList();;
|
||||||
|
|
||||||
public final AccountReservationList getReservation_list() {
|
|
||||||
return reservation_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("{ \"Account\":{");
|
sb.append("{ \"Account\":{");
|
||||||
sb.append("\"account_number\": \"" + account_number + "\",");
|
sb.append("\"account_number\": \"").append(account_number).append("\",");
|
||||||
sb.append("\"phone_number\": \"" + phone_number + "\",");
|
sb.append("\"phone_number\": \"").append(phone_number).append("\",");
|
||||||
sb.append("\"mailing_address\": " + mailing_address + ",");
|
sb.append("\"mailing_address\": ").append(mailing_address).append(",");
|
||||||
sb.append("\"email_address\": " + email_address + ",");
|
sb.append("\"email_address\": ").append(email_address).append(",");
|
||||||
sb.append(this.reservation_list.toString());
|
sb.append(this.reservation_list.toString());
|
||||||
sb.append("}}");
|
sb.append("}}");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
@@ -149,7 +145,6 @@ public class Account {
|
|||||||
this.setEmail_address(acct.email_address);
|
this.setEmail_address(acct.email_address);
|
||||||
this.setPhone_number(acct.phone_number);
|
this.setPhone_number(acct.phone_number);
|
||||||
this.setMailing_address(acct.mailing_address);
|
this.setMailing_address(acct.mailing_address);
|
||||||
this.getReservation_list().update(acct.getReservation_list());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@ import java.util.ArrayList;
|
|||||||
public class AccountReservationList extends ArrayList<Reservation> {
|
public class AccountReservationList extends ArrayList<Reservation> {
|
||||||
|
|
||||||
private static String reservationSerial(Reservation reservation) {
|
private static String reservationSerial(Reservation reservation) {
|
||||||
return String.format("R%010d", Math.abs(java.util.Objects.hash(reservation.physical_address)));
|
return String.format("R%010d", Math.abs(java.util.Objects.hash(reservation.getPhysical_address())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -19,7 +19,7 @@ public class AccountReservationList extends ArrayList<Reservation> {
|
|||||||
try {
|
try {
|
||||||
result = reservation.checkValid();
|
result = reservation.checkValid();
|
||||||
} catch (ReservationException ex) {
|
} catch (ReservationException ex) {
|
||||||
return false;
|
result = false;
|
||||||
}
|
}
|
||||||
if(result){
|
if(result){
|
||||||
reservation.setReservation_number(AccountReservationList.reservationSerial(reservation));
|
reservation.setReservation_number(AccountReservationList.reservationSerial(reservation));
|
||||||
|
|||||||
@@ -7,29 +7,29 @@ public final class CabinReservation extends Reservation{
|
|||||||
|
|
||||||
CabinReservation(){
|
CabinReservation(){
|
||||||
super();
|
super();
|
||||||
|
setType('C');
|
||||||
}
|
}
|
||||||
public CabinReservation(final Address physical_address) {
|
public CabinReservation(final Address physical_address) {
|
||||||
numberOfBeds = 1;
|
setNumberOfBeds( 1);
|
||||||
kitchen = KitchenEnum.Kitchenette;
|
setKitchen( KitchenEnum.Kitchenette );
|
||||||
this.physical_address = new Address();
|
this.setPhysical_address(new Address());
|
||||||
this.physical_address.setStreet(physical_address.getStreet());
|
this.getPhysical_address().setStreet(physical_address.getStreet());
|
||||||
this.physical_address.setCity(physical_address.getCity());
|
this.getPhysical_address().setCity(physical_address.getCity());
|
||||||
this.physical_address.setState(physical_address.getState());
|
this.getPhysical_address().setState(physical_address.getState());
|
||||||
this.physical_address.setZip(physical_address.getZip());
|
this.getPhysical_address().setZip(physical_address.getZip());
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String ReservationType() {
|
public final String ReservationType() {
|
||||||
type='C';
|
|
||||||
return "CabinReservation";
|
return "CabinReservation";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkValid() throws IllegalArgumentException {
|
public boolean checkValid() throws IllegalArgumentException {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
if (physical_address == null) {
|
if (getPhysical_address() == null) {
|
||||||
throw new IllegalArgumentException("not valid, physical_address");
|
throw new IllegalArgumentException("not valid, physical_address");
|
||||||
}
|
}
|
||||||
if (mailing_address == null) {
|
if (getMailing_address() == null) {
|
||||||
throw new IllegalArgumentException("not valid, mailing_address");
|
throw new IllegalArgumentException("not valid, mailing_address");
|
||||||
}
|
}
|
||||||
result = true;
|
result = true;
|
||||||
@@ -40,19 +40,19 @@ public final class CabinReservation extends Reservation{
|
|||||||
// Cabin price plus additional fee of $20 for full kitchen and $5 for each additional bathroom
|
// Cabin price plus additional fee of $20 for full kitchen and $5 for each additional bathroom
|
||||||
@Override
|
@Override
|
||||||
public float calculatePrice() {
|
public float calculatePrice() {
|
||||||
ZonedDateTime enddt = reservation_end_date.truncatedTo(ChronoUnit.DAYS);
|
ZonedDateTime enddt = getReservation_end_date().truncatedTo(ChronoUnit.DAYS);
|
||||||
ZonedDateTime startdt = reservation_start_date.truncatedTo(ChronoUnit.DAYS);
|
ZonedDateTime startdt = getReservation_start_date().truncatedTo(ChronoUnit.DAYS);
|
||||||
long days = ChronoUnit.DAYS.between( startdt ,enddt);
|
long days = ChronoUnit.DAYS.between( startdt ,enddt);
|
||||||
days = ( days < 2 ) ? 1: days - 1;
|
days = ( days < 2 ) ? 1: days - 1;
|
||||||
price = (squareFeet > 900.0f) ? 120.0f + 15.0f : 120.0f;
|
float calcprice = (getSquareFeet() > 900.0f) ? 120.0f + 15.0f : 120.0f;
|
||||||
if ( kitchen == KitchenEnum.FullKitchen ){
|
if ( getKitchen() == KitchenEnum.FullKitchen ){
|
||||||
price = price + 20.0f ;
|
calcprice = calcprice + 20.0f;
|
||||||
}
|
}
|
||||||
if( numberOfBathRooms > 1 ){
|
if( getNumberOfBathRooms() > 1 ){
|
||||||
price = price + (numberOfBathRooms * 5.0f);
|
setPrice( getPrice() + (getNumberOfBathRooms() * 5.0f));
|
||||||
}
|
}
|
||||||
price = price * days;
|
calcprice = calcprice * days;
|
||||||
return price;
|
return calcprice;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,43 +7,44 @@ public final class HotelReservation extends Reservation {
|
|||||||
|
|
||||||
HotelReservation() {
|
HotelReservation() {
|
||||||
super();
|
super();
|
||||||
numberOfBeds = 2;
|
setType('H');
|
||||||
|
setNumberOfBeds( 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
public HotelReservation(final Address physical_address) {
|
public HotelReservation(final Address physical_address) {
|
||||||
numberOfBeds = 2;
|
setNumberOfBeds(2);
|
||||||
numberOfBedRooms = 1;
|
setNumberOfBedRooms(1);
|
||||||
numberOfBathRooms = 1;
|
setNumberOfBathRooms(1);
|
||||||
kitchen = KitchenEnum.None;
|
setNumberOfFloors(1);
|
||||||
this.physical_address = new Address();
|
setKitchen(KitchenEnum.Kitchenette );
|
||||||
this.physical_address.setStreet(physical_address.getStreet());
|
this.setPhysical_address(new Address());
|
||||||
this.physical_address.setCity(physical_address.getCity());
|
this.getPhysical_address().setStreet(physical_address.getStreet());
|
||||||
this.physical_address.setState(physical_address.getState());
|
this.getPhysical_address().setCity(physical_address.getCity());
|
||||||
this.physical_address.setZip(physical_address.getZip());
|
this.getPhysical_address().setState(physical_address.getState());
|
||||||
|
this.getPhysical_address().setZip(physical_address.getZip());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final String ReservationType() {
|
public final String ReservationType() {
|
||||||
type = 'H';
|
|
||||||
return "HotelReservation";
|
return "HotelReservation";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkValid() throws IllegalArgumentException {
|
public boolean checkValid() throws IllegalArgumentException {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
if (numberOfBathRooms != 1) {
|
if (getNumberOfBathRooms() != 1) {
|
||||||
throw new IllegalArgumentException("not valid, Baths");
|
throw new IllegalArgumentException("not valid, Baths");
|
||||||
}
|
}
|
||||||
if (numberOfBedRooms != 1) {
|
if (getNumberOfBedRooms() != 1) {
|
||||||
throw new IllegalArgumentException("not valid, BedRooms");
|
throw new IllegalArgumentException("not valid, BedRooms");
|
||||||
}
|
}
|
||||||
if (numberOfBeds != 2) {
|
if (getNumberOfBeds() != 2) {
|
||||||
throw new IllegalArgumentException("not valid, Beds");
|
throw new IllegalArgumentException("not valid, Beds");
|
||||||
}
|
}
|
||||||
if (physical_address == null) {
|
if (getPhysical_address() == null) {
|
||||||
throw new IllegalArgumentException("not valid, physical_address");
|
throw new IllegalArgumentException("not valid, physical_address");
|
||||||
}
|
}
|
||||||
if (mailing_address == null) {
|
if (getMailing_address() == null) {
|
||||||
throw new IllegalArgumentException("not valid, mailing_address");
|
throw new IllegalArgumentException("not valid, mailing_address");
|
||||||
}
|
}
|
||||||
result = true;
|
result = true;
|
||||||
@@ -52,17 +53,19 @@ public final class HotelReservation extends Reservation {
|
|||||||
|
|
||||||
// calculate and return the reservation's price
|
// calculate and return the reservation's price
|
||||||
// Hotel price plus additional flat fee of $50 plus $10 for kitchenette
|
// Hotel price plus additional flat fee of $50 plus $10 for kitchenette
|
||||||
|
@Override
|
||||||
public float calculatePrice() {
|
public float calculatePrice() {
|
||||||
ZonedDateTime enddt = reservation_end_date.truncatedTo(ChronoUnit.DAYS);
|
ZonedDateTime enddt = getReservation_end_date().truncatedTo(ChronoUnit.DAYS);
|
||||||
ZonedDateTime startdt = reservation_start_date.truncatedTo(ChronoUnit.DAYS);
|
ZonedDateTime startdt = getReservation_start_date().truncatedTo(ChronoUnit.DAYS);
|
||||||
long days = ChronoUnit.DAYS.between(startdt, enddt);
|
long days = ChronoUnit.DAYS.between( startdt ,enddt);
|
||||||
days = (days < 2) ? 1 : days - 1;
|
days = ( days < 2 ) ? 1: days - 1;
|
||||||
price = (squareFeet > 900.0f) ? 120.0f + 15.0f : 120.0f;
|
|
||||||
if (kitchen == KitchenEnum.FullKitchen) {
|
float calcprice = (getSquareFeet() > 900.0f) ? 120.0f + 15.0f : 120.0f;
|
||||||
price = price + 10.0f;
|
if (getKitchen() == KitchenEnum.FullKitchen) {
|
||||||
|
calcprice = calcprice + 10.0f;
|
||||||
}
|
}
|
||||||
price = price * days;
|
calcprice = calcprice * days;
|
||||||
price = price + 50.0f;
|
calcprice = calcprice + 50.0f;
|
||||||
return price;
|
return calcprice;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,32 +7,32 @@ public final class HouseReservation extends Reservation {
|
|||||||
|
|
||||||
HouseReservation(){
|
HouseReservation(){
|
||||||
super();
|
super();
|
||||||
|
this.setType( 'Z' );
|
||||||
}
|
}
|
||||||
|
|
||||||
public HouseReservation(final Address physical_address) {
|
public HouseReservation(final Address physical_address) {
|
||||||
numberOfBeds = 2;
|
setNumberOfBeds(2);
|
||||||
numberOfBedRooms = 1;
|
setNumberOfBedRooms(1);
|
||||||
numberOfBathRooms = 1;
|
setNumberOfBathRooms(1);
|
||||||
numberOfFloors = 1;
|
setNumberOfFloors(1);
|
||||||
kitchen = KitchenEnum.FullKitchen;
|
setKitchen(KitchenEnum.Kitchenette );
|
||||||
this.physical_address = new Address();
|
this.setPhysical_address(new Address());
|
||||||
this.physical_address.setStreet(physical_address.getStreet());
|
this.getPhysical_address().setStreet(physical_address.getStreet());
|
||||||
this.physical_address.setCity(physical_address.getCity());
|
this.getPhysical_address().setCity(physical_address.getCity());
|
||||||
this.physical_address.setState(physical_address.getState());
|
this.getPhysical_address().setState(physical_address.getState());
|
||||||
this.physical_address.setZip(physical_address.getZip());
|
this.getPhysical_address().setZip(physical_address.getZip());
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String ReservationType() {
|
public final String ReservationType() {
|
||||||
type = 'Z';
|
|
||||||
return "HouseReservation";
|
return "HouseReservation";
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkValid() throws IllegalArgumentException {
|
public boolean checkValid() throws IllegalArgumentException {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
if (physical_address == null) {
|
if (getPhysical_address() == null) {
|
||||||
throw new IllegalArgumentException("not valid, physical_address");
|
throw new IllegalArgumentException("not valid, physical_address");
|
||||||
}
|
}
|
||||||
if (mailing_address == null) {
|
if (getMailing_address() == null) {
|
||||||
throw new IllegalArgumentException("not valid, mailing_address");
|
throw new IllegalArgumentException("not valid, mailing_address");
|
||||||
}
|
}
|
||||||
result = true;
|
result = true;
|
||||||
@@ -40,19 +40,18 @@ public final class HouseReservation extends Reservation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public float getPricePerNight(){
|
public float getPricePerNight(){
|
||||||
price = (squareFeet > 900.0f) ? 120.0f + 15.0f : 120.0f;
|
return (getSquareFeet() > 900.0f) ? 120.0f + 15.0f : 120.0f;
|
||||||
return price;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate and return the reservation's price
|
// calculate and return the reservation's price
|
||||||
// Hotel price plus additional flat fee of $50 plus $10 for kitchenette
|
// Hotel price plus additional flat fee of $50 plus $10 for kitchenette
|
||||||
@Override
|
@Override
|
||||||
public float calculatePrice() {
|
public float calculatePrice() {
|
||||||
ZonedDateTime enddt = reservation_end_date.truncatedTo(ChronoUnit.DAYS);
|
ZonedDateTime enddt = getReservation_end_date().truncatedTo(ChronoUnit.DAYS);
|
||||||
ZonedDateTime startdt = reservation_start_date.truncatedTo(ChronoUnit.DAYS);
|
ZonedDateTime startdt = getReservation_start_date().truncatedTo(ChronoUnit.DAYS);
|
||||||
long days = ChronoUnit.DAYS.between( startdt, enddt);
|
long days = ChronoUnit.DAYS.between( startdt ,enddt);
|
||||||
days = ( days < 2 ) ? 1: days - 1;
|
days = ( days < 2 ) ? 1: days - 1;
|
||||||
price = getPricePerNight() * days;
|
float calcprice = getPricePerNight() * days;
|
||||||
return price;
|
return calcprice;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,26 +9,26 @@ import java.nio.file.Paths;
|
|||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
|
|
||||||
public abstract class Reservation {
|
public abstract class Reservation {
|
||||||
char type;
|
private char type;
|
||||||
String reservation_number = "-99";
|
private String reservation_number = "-99";
|
||||||
Address physical_address;
|
private Address physical_address;
|
||||||
Address mailing_address;
|
private Address mailing_address;
|
||||||
|
|
||||||
ZonedDateTime reservation_start_date;
|
private ZonedDateTime reservation_start_date;
|
||||||
ZonedDateTime reservation_end_date;
|
private ZonedDateTime reservation_end_date;
|
||||||
ReservationStatusEnum reservation_status;
|
private ReservationStatusEnum reservation_status;
|
||||||
|
|
||||||
KitchenEnum kitchen;
|
private KitchenEnum kitchen;
|
||||||
|
|
||||||
Integer numberOfBeds;
|
private Integer numberOfBeds;
|
||||||
Integer numberOfBedRooms;
|
private Integer numberOfBedRooms;
|
||||||
Integer numberOfBathRooms;
|
private Integer numberOfBathRooms;
|
||||||
Integer numberOfFloors;
|
private Integer numberOfFloors;
|
||||||
Integer squareFeet;
|
private Integer squareFeet;
|
||||||
|
|
||||||
Float price;
|
Float price;
|
||||||
|
|
||||||
Reservation() {
|
protected Reservation() {
|
||||||
numberOfBeds = 1;
|
numberOfBeds = 1;
|
||||||
numberOfBedRooms = 1;
|
numberOfBedRooms = 1;
|
||||||
numberOfBathRooms = 1;
|
numberOfBathRooms = 1;
|
||||||
@@ -40,16 +40,12 @@ public abstract class Reservation {
|
|||||||
physical_address = null;
|
physical_address = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getReservation_number() {
|
|
||||||
return reservation_number;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setReservation_number(String reservation_number) {
|
public void setReservation_number(String reservation_number) {
|
||||||
this.reservation_number = reservation_number;
|
this.reservation_number = reservation_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Address physical_address() {
|
public String getReservation_number() {
|
||||||
return physical_address;
|
return this.reservation_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPhysical_address(Address physical_address) {
|
public void setPhysical_address(Address physical_address) {
|
||||||
@@ -64,26 +60,14 @@ public abstract class Reservation {
|
|||||||
this.mailing_address = mailing_address;
|
this.mailing_address = mailing_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZonedDateTime reservation_start_date() {
|
|
||||||
return reservation_start_date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setReservation_start_date(ZonedDateTime reservation_start_date) {
|
public void setReservation_start_date(ZonedDateTime reservation_start_date) {
|
||||||
this.reservation_start_date = reservation_start_date;
|
this.reservation_start_date = reservation_start_date;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZonedDateTime reservation_end_date() {
|
|
||||||
return reservation_end_date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setReservation_end_date(ZonedDateTime reservation_end_date) {
|
public void setReservation_end_date(ZonedDateTime reservation_end_date) {
|
||||||
this.reservation_end_date = reservation_end_date;
|
this.reservation_end_date = reservation_end_date;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReservationStatusEnum reservation_status() {
|
|
||||||
return reservation_status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setReservation_status(ReservationStatusEnum reservation_status) {
|
public void setReservation_status(ReservationStatusEnum reservation_status) {
|
||||||
this.reservation_status = reservation_status;
|
this.reservation_status = reservation_status;
|
||||||
}
|
}
|
||||||
@@ -96,11 +80,6 @@ public abstract class Reservation {
|
|||||||
this.kitchen = kitchen;
|
this.kitchen = kitchen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Integer numberOfBeds() {
|
|
||||||
return numberOfBeds;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNumberOfBeds(Integer numberOfBeds) {
|
public void setNumberOfBeds(Integer numberOfBeds) {
|
||||||
this.numberOfBeds = numberOfBeds;
|
this.numberOfBeds = numberOfBeds;
|
||||||
}
|
}
|
||||||
@@ -113,38 +92,74 @@ public abstract class Reservation {
|
|||||||
this.numberOfBedRooms = numberOfBedRooms;
|
this.numberOfBedRooms = numberOfBedRooms;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer numberOfBathRooms() {
|
|
||||||
return numberOfBathRooms;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNumberOfBathRooms(Integer numberOfBathRooms) {
|
public void setNumberOfBathRooms(Integer numberOfBathRooms) {
|
||||||
this.numberOfBathRooms = numberOfBathRooms;
|
this.numberOfBathRooms = numberOfBathRooms;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer numberOfFloors() {
|
|
||||||
return numberOfFloors;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNumberOfFloors(Integer numberOfFloors) {
|
public void setNumberOfFloors(Integer numberOfFloors) {
|
||||||
this.numberOfFloors = numberOfFloors;
|
this.numberOfFloors = numberOfFloors;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer squareFeet() {
|
|
||||||
return squareFeet;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSquareFeet(Integer squareFeet) {
|
public void setSquareFeet(Integer squareFeet) {
|
||||||
this.squareFeet = squareFeet;
|
this.squareFeet = squareFeet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Float price() {
|
|
||||||
return price;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPrice(Float price) {
|
public void setPrice(Float price) {
|
||||||
this.price = price;
|
this.price = price;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public char getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setType(char type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Address getPhysical_address() {
|
||||||
|
return physical_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Address getMailing_address() {
|
||||||
|
return mailing_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ZonedDateTime getReservation_start_date() {
|
||||||
|
return reservation_start_date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ZonedDateTime getReservation_end_date() {
|
||||||
|
return reservation_end_date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReservationStatusEnum getReservation_status() {
|
||||||
|
return reservation_status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getNumberOfBeds() {
|
||||||
|
return numberOfBeds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getNumberOfBedRooms() {
|
||||||
|
return numberOfBedRooms;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getNumberOfBathRooms() {
|
||||||
|
return numberOfBathRooms;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getNumberOfFloors() {
|
||||||
|
return numberOfFloors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getSquareFeet() {
|
||||||
|
return squareFeet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Float getPrice() {
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
@@ -175,20 +190,20 @@ public abstract class Reservation {
|
|||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
sb.append(String.format("{ \"%s\":{", ReservationType()));
|
sb.append(String.format("{ \"%s\":{", ReservationType()));
|
||||||
sb.append("\"reservation_type\": \"" + ReservationType() + "\",");
|
sb.append("\"reservation_type\": \"").append(ReservationType()).append("\",");
|
||||||
sb.append("\"reservation_number\": \"" + reservation_number + "\",");
|
sb.append("\"reservation_number\": \"").append(reservation_number).append("\",");
|
||||||
sb.append("\"reservation_status\": \"" + reservation_status + "\",");
|
sb.append("\"reservation_status\": \"").append(reservation_status).append("\",");
|
||||||
sb.append("\"reservation_start_date\": \"" + reservation_start_date + "\",");
|
sb.append("\"reservation_start_date\": \"").append(reservation_start_date).append("\",");
|
||||||
sb.append("\"reservation_end_date\": \"" + reservation_end_date + "\",");
|
sb.append("\"reservation_end_date\": \"").append(reservation_end_date).append("\",");
|
||||||
sb.append("\"physical_address\": " + physical_address + ",");
|
sb.append("\"physical_address\": ").append(physical_address).append(",");
|
||||||
sb.append("\"mailing_address\": " + mailing_address + ",");
|
sb.append("\"mailing_address\": ").append(mailing_address).append(",");
|
||||||
sb.append("\"kitchen\": \"" + kitchen + "\",");
|
sb.append("\"kitchen\": \"").append(kitchen).append("\",");
|
||||||
sb.append("\"numberOfBeds\": \"" + numberOfBeds + "\",");
|
sb.append("\"numberOfBeds\": \"").append(numberOfBeds).append("\",");
|
||||||
sb.append("\"numberOfBedRooms\": \"" + numberOfBedRooms + "\",");
|
sb.append("\"numberOfBedRooms\": \"").append(numberOfBedRooms).append("\",");
|
||||||
sb.append("\"numberOfBathRooms\": \"" + numberOfBathRooms + "\",");
|
sb.append("\"numberOfBathRooms\": \"").append(numberOfBathRooms).append("\",");
|
||||||
sb.append("\"numberOfFloors\": \"" + numberOfFloors + "\",");
|
sb.append("\"numberOfFloors\": \"").append(numberOfFloors).append("\",");
|
||||||
sb.append("\"squareFeet\": \"" + squareFeet + "\",");
|
sb.append("\"squareFeet\": \"").append(squareFeet).append("\",");
|
||||||
sb.append("\"price\": \"" + price + "\"");
|
sb.append("\"price\": \"").append(price).append("\"");
|
||||||
sb.append("}}");
|
sb.append("}}");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
@@ -205,14 +220,14 @@ public abstract class Reservation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Change(Reservation reservation, ReservationStatusEnum newStatus) throws IllegalOperationException {
|
public void Change(Reservation reservation, ReservationStatusEnum newStatus) throws IllegalOperationException {
|
||||||
try {
|
try {
|
||||||
if (reservation.reservation_status == ReservationStatusEnum.Completed) {
|
if (reservation.reservation_status == ReservationStatusEnum.Completed) {
|
||||||
if (newStatus == ReservationStatusEnum.Canceled) {
|
if (newStatus == ReservationStatusEnum.Canceled) {
|
||||||
throw new IllegalOperationException ("Invalid Change, reservation has completed.");
|
throw new IllegalOperationException("Invalid Change, reservation has completed.");
|
||||||
}
|
}
|
||||||
if (ZonedDateTime.now().compareTo(this.reservation_start_date) > -1) {
|
if (ZonedDateTime.now().compareTo(this.reservation_start_date) > -1) {
|
||||||
throw new IllegalOperationException ("Invalid Change, reservation time started.");
|
throw new IllegalOperationException("Invalid Change, reservation time started.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,10 +240,6 @@ public abstract class Reservation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public float calculatePricePerNight() {
|
|
||||||
return 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract String ReservationType();
|
public abstract String ReservationType();
|
||||||
|
|
||||||
public abstract float calculatePrice();
|
public abstract float calculatePrice();
|
||||||
|
|||||||
Reference in New Issue
Block a user