57 lines
1.8 KiB
Java
57 lines
1.8 KiB
Java
package lodge.reservationsystem;
|
|
|
|
import java.time.ZonedDateTime;
|
|
import java.time.temporal.ChronoUnit;
|
|
|
|
public final class CabinReservation extends Reservation{
|
|
|
|
CabinReservation(){
|
|
super();
|
|
}
|
|
public CabinReservation(final Address physical_address) {
|
|
numberOfBeds = 1;
|
|
kitchen = KitchenEnum.Kitchenette;
|
|
this.physical_address = new Address();
|
|
this.physical_address.setStreet(physical_address.getStreet());
|
|
this.physical_address.setCity(physical_address.getCity());
|
|
this.physical_address.setState(physical_address.getState());
|
|
this.physical_address.setZip(physical_address.getZip());
|
|
}
|
|
|
|
public final String ReservationType() {
|
|
type='C';
|
|
return "CabinReservation";
|
|
}
|
|
|
|
public boolean checkValid() throws IllegalArgumentException {
|
|
boolean result = false;
|
|
if (physical_address == null) {
|
|
throw new IllegalArgumentException("not valid, physical_address");
|
|
}
|
|
if (mailing_address == null) {
|
|
throw new IllegalArgumentException("not valid, mailing_address");
|
|
}
|
|
result = true;
|
|
return result;
|
|
}
|
|
|
|
//calculate and return the reservation's price
|
|
// Cabin price plus additional fee of $20 for full kitchen and $5 for each additional bathroom
|
|
public float calculatePrice() {
|
|
ZonedDateTime enddt = reservation_end_date.truncatedTo(ChronoUnit.DAYS);
|
|
ZonedDateTime startdt = reservation_start_date.truncatedTo(ChronoUnit.DAYS);
|
|
long days = ChronoUnit.DAYS.between( startdt ,enddt);
|
|
days = ( days < 2 ) ? 1: days - 1;
|
|
price = (squareFeet > 900.0f) ? 120.0f + 15.0f : 120.0f;
|
|
if ( kitchen == KitchenEnum.FullKitchen ){
|
|
price = price + 20.0f ;
|
|
}
|
|
if( numberOfBathRooms > 1 ){
|
|
price = price + (numberOfBathRooms * 5.0f);
|
|
}
|
|
price = price * days;
|
|
return price;
|
|
}
|
|
|
|
}
|