Hotel MGMT System
Hotel MGMT System
Leader:
Members:
Leonin, Reynald
Requirements:
• Classes and Objects: Implement classes for Room, Guest, Booking, and Hotel.
cancelReservation().
Features:
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
setRoomNumber(roomNumber);
setPrice(price);
setRoomType(roomType);
setAvailable(true);
return roomNumber;
this.roomNumber = roomNumber;
return price;
this.price = price;
return roomType;
this.roomType = roomType;
return isAvailable;
this.isAvailable = isAvailable;
//once a room is booked, it checks if the check-in and check-out dates does not conflict to existing
booking dates
return false; //it means that one or both of the dates overlap with the existing ones
return true;
//this method adds the booking dates to a list of booking dates for the room
//this methods takes the check in and check out date from the given booking and removes it from the
bookedDates list
bookedDates.removeIf(dates ->
}
//ROOM SUBCLASS – SINGLE ROOM
setAvailable(isAvailable());;
}
//ROOM SUBCLASS – DOUBLE ROOM
}
//ROOM SUBCLASS – EXTENDED ROOM
}
//GUEST CLASS
import java.util.List;
import java.util.ArrayList;
setName(name);
setContactInfo(contactInfo);
return name;
this.name = name;
return contactInfo;
this.contactInfo = contactInfo;
}
//add booking to the guest's booking history
bookingHistory.add(booking);
if(bookingHistory.isEmpty()){
else{
System.out.println(booking);
}
//BOOKING CLASS
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
setGuest(guest);
setRoom(room);
setCheckInDate(checkInDate);
setCheckOutDate(checkOutDate);
return guest;
this.guest = guest;
return room;
return checkInDate;
this.checkInDate = LocalDate.parse(checkInDate);
return checkOutDate;
this.checkOutDate = LocalDate.parse(checkOutDate);
if(checkOutDate.compareTo(checkInDate)==0){
}else{
return checkOutDate.compareTo(checkInDate);
try {
LocalDate.parse(dateStr, formatter);
return true;
} catch (DateTimeParseException e) {
return false;
return "Booking{" +
'}';
}
//RESERVABLE INTERFACE
import java.time.LocalDate;
}
//HOTEL CLASS
import java.util.ArrayList;
import java.util.List;
import java.time.LocalDate;
public Hotel(){
rooms.add(room);
if (room.getRoomType().equalsIgnoreCase(roomType) &&
room.isAvailableForDates(LocalDate.parse(checkInDate), LocalDate.parse(checkOutDate))) {
}
return null; // No room available
//method for getting a certain booking depending on the guest name and their room number
return booking;
return null;
//method overloading getBooking, with different parameter to get the booking using the guest's name
and contact info
if(booking.getGuest().getName().equals(guestName) &&
booking.getGuest().getContactInfo().equals(guestEmail)){
return booking;
return null;
bookings.remove(booking);
}
//implemented from the reservable interface
//create a booking based on guest, room type, check-in and check-out dates
public void makeReservation(Guest guest, String roomType, String checkInDate, String checkOutDate){
if(room != null){ //proceeds with the booking if the room object is not null
room.addBookingDates(LocalDate.parse(checkInDate),LocalDate.parse(checkOutDate)); //parses
the dates and adds them to the booked dates
}else{
System.out.println("No available " + roomType + " for the selected dates"); // prints if there are no
available room type based on the guest's preference
if(toCancel != null){
toCancel.getRoom().removeBookingDates(toCancel);
toCancel.getRoom().setAvailable(true); // sets the as room available
System.out.println("Reseration on room " + roomNumber + " has been canceled by guest " +
guestName);
}else{
System.out.println("No booking found for guest " + guestName + " under Room "+ roomNumber);
//displays the billing information based on the guest name and room number
if(settleBooking !=null){
System.out.println(" ");
}else{
System.out.println("No booking under "+ guestName + " and Room number" + roomNumber);
}
//MAIN CLASS
import java.util.Scanner;
hotel.addRoom(new ExtendedRoom(103,300.0));
String choice;
while(running){
System.out.println("5. Exit");
sc.nextLine();
switch(selected){
case 1:
System.out.println();
System.out.println("Booking A Room");
if(roomType.equals("Single Room")||roomType.equals("Double
Room")||roomType.equals("Extended Room")){
if(Booking.isValidDate(checkInDate)&&Booking.isValidDate(checkOutDate)&&
checkOutDate.compareTo(checkInDate)>=0){
}else{
System.out.println("Invalid date/s");
break;
}else{
break;
System.out.println();
choice = sc.nextLine();
if(choice.equals("Y")){
break;
}else{
running = false;
break;
case 2:
System.out.println();
System.out.println("Canceling A Reservation");
System.out.print("Enter the room number you wish to cancel reservations on: ");
sc.nextLine();
hotel.cancelReservation(cancelName, roomNumber);
System.out.println();
choice = sc.nextLine();
if(choice.equals("Y")){
break;
}else{
running = false;
break;
case 3:
System.out.println();
System.out.println("Settling Bills");
hotel.showBillingInfo(settleName, settleRoomNumber);
sc.nextLine();
if(amountPaid>=hotel.getBooking(settleName, settleRoomNumber).getTotalAmount()){
hotel.getBooking(settleName, settleRoomNumber).getRoom().setAvailable(true);
hotel.removeBooking(hotel.getBooking(settleName, settleRoomNumber));
}else{
System.out.println("Insufficient funds");
System.out.println();
choice = sc.nextLine();
if(choice.equals("Y")){
break;
}else{
running = false;
break;
case 4:
System.out.println();
hotel.getBooking(historyName, historyEmail).getGuest().viewBookingHistory();
System.out.println();
choice = sc.nextLine();
if(choice.equals("Y")){
break;
}else{
running = false;
break;
case 5:
running = false;