fixups
This commit is contained in:
@@ -54,7 +54,7 @@ public final class TestReservations {
|
||||
hotel.setNumberOfBedRooms(1);
|
||||
hotel.setSquareFeet(450);
|
||||
hotel.setReservation_start_date(ZonedDateTime.of(2025, 07, 05, 10, 0, 0, 0, ZoneId.of("UTC")));
|
||||
hotel.setReservation_end_date(ZonedDateTime.of(2025, 11, 30, 22, 0, 0, 0, ZoneId.of("UTC")));
|
||||
hotel.setReservation_end_date(ZonedDateTime.of(2025, 07, 07, 22, 0, 0, 0, ZoneId.of("UTC")));
|
||||
mgr.addReservation(acct, hotel);
|
||||
|
||||
mgr.UpdateAccount(acct);
|
||||
@@ -89,8 +89,8 @@ public final class TestReservations {
|
||||
house.setNumberOfFloors(3);
|
||||
house.setNumberOfBedRooms(3);
|
||||
house.setSquareFeet(1400);
|
||||
house.setReservation_start_date(ZonedDateTime.of(2025, 9, 5, 10, 0, 0, 0, ZoneId.of("UTC")));
|
||||
house.setReservation_end_date(ZonedDateTime.of(2025, 11, 30, 22, 0, 0, 0, ZoneId.of("UTC")));
|
||||
house.setReservation_start_date(ZonedDateTime.of(2025, 11, 5, 10, 0, 0, 0, ZoneId.of("UTC")));
|
||||
house.setReservation_end_date(ZonedDateTime.of(2025, 11, 15, 22, 0, 0, 0, ZoneId.of("UTC")));
|
||||
mgr.addReservation(acct, house);
|
||||
|
||||
mgr.UpdateAccount(acct);
|
||||
|
||||
@@ -70,7 +70,7 @@ public final class AccomodationManager {
|
||||
return acct;
|
||||
}
|
||||
|
||||
public boolean addReservation(final Account account, final Reservation reservation) throws ReservationException {
|
||||
public boolean addReservation(final Account account, final Reservation reservation){
|
||||
boolean result = account.add(reservation);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
package lodge.reservationsystem;
|
||||
|
||||
class AccountException extends Exception {
|
||||
public AccountException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public AccountException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,7 +9,7 @@ public class AccountReservationList extends ArrayList<Reservation> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(final Reservation reservation) {
|
||||
public boolean add(final Reservation reservation) throws RuntimeException{
|
||||
boolean result = true;
|
||||
Reservation rsrv = this.find(reservation.getReservation_number());
|
||||
if( rsrv != null ){
|
||||
@@ -18,11 +18,12 @@ public class AccountReservationList extends ArrayList<Reservation> {
|
||||
}
|
||||
try {
|
||||
result = reservation.checkValid();
|
||||
} catch (ReservationException ex) {
|
||||
} catch (RuntimeException ex) {
|
||||
result = false;
|
||||
}
|
||||
if(result){
|
||||
reservation.setReservation_number(AccountReservationList.reservationSerial(reservation));
|
||||
reservation.setPrice(reservation.calculatePrice());
|
||||
result = super.add(reservation);
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -36,6 +36,10 @@ public final class CabinReservation extends Reservation {
|
||||
return result;
|
||||
}
|
||||
|
||||
public float getPricePerNight() {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
//calculate and return the reservation's price
|
||||
// Cabin price plus additional fee of $20 for full kitchen and $5 for each additional bathroom
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package lodge.reservationsystem;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
@@ -51,6 +52,10 @@ public final class HotelReservation extends Reservation {
|
||||
return result;
|
||||
}
|
||||
|
||||
public float getPricePerNight() {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
// calculate and return the reservation's price
|
||||
// Hotel price plus additional flat fee of $50 plus $10 for kitchenette
|
||||
@Override
|
||||
@@ -58,7 +63,11 @@ public final class HotelReservation 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;
|
||||
|
||||
ZonedDateTime checkOutTime = enddt.with(LocalTime.of(12, 0));
|
||||
if(getReservation_end_date().isBefore(checkOutTime)){
|
||||
days = days-1;
|
||||
}
|
||||
|
||||
float calcprice = (getSquareFeet() > 900.0f) ? 120.0f + 15.0f : 120.0f;
|
||||
if (getKitchen() == KitchenEnum.FullKitchen) {
|
||||
|
||||
@@ -39,12 +39,12 @@ public final class HouseReservation extends Reservation {
|
||||
return result;
|
||||
}
|
||||
|
||||
// House price plus additional flat fee for additional space per day
|
||||
public float getPricePerNight() {
|
||||
return (getSquareFeet() > 900.0f) ? 120.0f + 15.0f : 120.0f;
|
||||
}
|
||||
|
||||
// calculate and return the reservation's price
|
||||
// Hotel price plus additional flat fee of $50 plus $10 for kitchenette
|
||||
@Override
|
||||
public float calculatePrice() {
|
||||
ZonedDateTime enddt = getReservation_end_date().truncatedTo(ChronoUnit.DAYS);
|
||||
|
||||
@@ -256,6 +256,7 @@ public abstract class Reservation{
|
||||
}
|
||||
|
||||
public abstract String ReservationType();
|
||||
public abstract float getPricePerNight();
|
||||
public abstract float calculatePrice();
|
||||
public abstract boolean checkValid() throws ReservationException;
|
||||
public abstract boolean checkValid();
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
package lodge.reservationsystem;
|
||||
|
||||
class ReservationException extends Exception {
|
||||
public ReservationException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ReservationException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1 +1,33 @@
|
||||
{ "HotelReservation":{"reservation_type": "HotelReservation","reservation_number": "R0123077641","reservation_status": "Draft","reservation_start_date": "2025-07-05T10:00Z[UTC]","reservation_end_date": "2025-11-30T22:00Z[UTC]","account_number": "A1450981765","physical_address": { "Address":{"street": "400 hotel ave","city": "Maryland City","state": "CA","zip": "20723"}},"mailing_address": { "Address":{"street": "400 hotel ave","city": "Maryland City","state": "MD","zip": "20723"}},"kitchen": "Kitchenette","numberOfBeds": "2","numberOfBedRooms": "1","numberOfBathRooms": "1","numberOfFloors": "1","squareFeet": "450","price": "120.0"}}
|
||||
{
|
||||
"HotelReservation": {
|
||||
"reservation_type": "HotelReservation",
|
||||
"reservation_number": "R0123077641",
|
||||
"reservation_status": "Draft",
|
||||
"reservation_start_date": "2025-07-05T10:00Z[UTC]",
|
||||
"reservation_end_date": "2025-07-07T22:00Z[UTC]",
|
||||
"account_number": "A1450981765",
|
||||
"physical_address": {
|
||||
"Address": {
|
||||
"street": "400 hotel ave",
|
||||
"city": "Maryland City",
|
||||
"state": "CA",
|
||||
"zip": "20723"
|
||||
}
|
||||
},
|
||||
"mailing_address": {
|
||||
"Address": {
|
||||
"street": "400 hotel ave",
|
||||
"city": "Maryland City",
|
||||
"state": "MD",
|
||||
"zip": "20723"
|
||||
}
|
||||
},
|
||||
"kitchen": "Kitchenette",
|
||||
"numberOfBeds": "2",
|
||||
"numberOfBedRooms": "1",
|
||||
"numberOfBathRooms": "1",
|
||||
"numberOfFloors": "1",
|
||||
"squareFeet": "450",
|
||||
"price": "290.0"
|
||||
}
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
{ "HouseReservation":{"reservation_type": "HouseReservation","reservation_number": "R0499811708","reservation_status": "Completed","reservation_start_date": "2025-09-05T10:00Z[UTC]","reservation_end_date": "2025-11-30T22:00Z[UTC]","account_number": "A1450981765","physical_address": { "Address":{"street": "3000 Osage ave","city": "GreenBelt","state": "MD","zip": "20740"}},"mailing_address": { "Address":{"street": "40012 College ave","city": "College Park","state": "MD","zip": "20740"}},"kitchen": "Kitchenette","numberOfBeds": "4","numberOfBedRooms": "3","numberOfBathRooms": "1","numberOfFloors": "3","squareFeet": "1400","price": "11475.0"}}
|
||||
{ "HouseReservation":{"reservation_type": "HouseReservation","reservation_number": "R0499811708","reservation_status": "Completed","reservation_start_date": "2025-11-05T10:00Z[UTC]","reservation_end_date": "2025-11-15T22:00Z[UTC]","account_number": "A1450981765","physical_address": { "Address":{"street": "3000 Osage ave","city": "GreenBelt","state": "MD","zip": "20740"}},"mailing_address": { "Address":{"street": "40012 College ave","city": "College Park","state": "MD","zip": "20740"}},"kitchen": "Kitchenette","numberOfBeds": "4","numberOfBedRooms": "3","numberOfBathRooms": "1","numberOfFloors": "3","squareFeet": "1400","price": "1215.0"}}
|
||||
@@ -1 +1 @@
|
||||
{ "CabinReservation":{"reservation_type": "CabinReservation","reservation_number": "R0535276622","reservation_status": "Draft","reservation_start_date": "2025-09-05T10:00Z[UTC]","reservation_end_date": "2025-11-30T22:00Z[UTC]","account_number": "A1450981765","physical_address": { "Address":{"street": "40 cabin ave","city": "Carnelian","state": "CA","zip": "96140"}},"mailing_address": { "Address":{"street": "40 cabin ave","city": "Carnelian Bay","state": "CA","zip": "96140"}},"kitchen": "Kitchenette","numberOfBeds": "4","numberOfBedRooms": "3","numberOfBathRooms": "1","numberOfFloors": "2","squareFeet": "806","price": "120.0"}}
|
||||
{ "CabinReservation":{"reservation_type": "CabinReservation","reservation_number": "R0535276622","reservation_status": "Draft","reservation_start_date": "2025-09-05T10:00Z[UTC]","reservation_end_date": "2025-11-30T22:00Z[UTC]","account_number": "A1450981765","physical_address": { "Address":{"street": "40 cabin ave","city": "Carnelian","state": "CA","zip": "96140"}},"mailing_address": { "Address":{"street": "40 cabin ave","city": "Carnelian Bay","state": "CA","zip": "96140"}},"kitchen": "Kitchenette","numberOfBeds": "4","numberOfBedRooms": "3","numberOfBathRooms": "1","numberOfFloors": "2","squareFeet": "806","price": "10200.0"}}
|
||||
@@ -1 +1 @@
|
||||
{ "CabinReservation":{"reservation_type": "CabinReservation","reservation_number": "R2042828431","reservation_status": "Draft","reservation_start_date": "2025-09-05T10:00Z[UTC]","reservation_end_date": "2025-11-30T22:00Z[UTC]","account_number": "A2074212339","physical_address": { "Address":{"street": "30 cabin ave","city": "Carnelian","state": "CA","zip": "96140"}},"mailing_address": { "Address":{"street": "30 cabin ave","city": "Carnelian Bay","state": "CA","zip": "96140"}},"kitchen": "Kitchenette","numberOfBeds": "4","numberOfBedRooms": "3","numberOfBathRooms": "1","numberOfFloors": "2","squareFeet": "806","price": "120.0"}}
|
||||
{ "CabinReservation":{"reservation_type": "CabinReservation","reservation_number": "R2042828431","reservation_status": "Draft","reservation_start_date": "2025-09-05T10:00Z[UTC]","reservation_end_date": "2025-11-30T22:00Z[UTC]","account_number": "A2074212339","physical_address": { "Address":{"street": "30 cabin ave","city": "Carnelian","state": "CA","zip": "96140"}},"mailing_address": { "Address":{"street": "30 cabin ave","city": "Carnelian Bay","state": "CA","zip": "96140"}},"kitchen": "Kitchenette","numberOfBeds": "4","numberOfBedRooms": "3","numberOfBathRooms": "1","numberOfFloors": "2","squareFeet": "806","price": "10200.0"}}
|
||||
Reference in New Issue
Block a user