Ponrasu
package hotel_management.com;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
class UserProfile {
private String userID;
private String fullName;
private String email;
private String mobileNumber;
private String password;
private String role; // Admin or User
public UserProfile(String userID, String fullName, String email, String mobileNumber, String password, String role) {
this.userID = userID;
this.fullName = fullName;
this.email = email;
this.mobileNumber = mobileNumber;
this.password = password;
this.role = role;
}
// Getters and Setters
public String getUserID() { return userID; }
public void setUserID(String userID) { this.userID = userID; }
public String getFullName() { return fullName; }
public void setFullName(String fullName) { this.fullName = fullName; }
public String getEmail() { return email; }
public void setEmail(String email) { this.email = email; }
public String getMobileNumber() { return mobileNumber; }
public void setMobileNumber(String mobileNumber) { this.mobileNumber = mobileNumber; }
public String getPassword() { return password; }
public void setPassword(String password) { this.password = password; }
public String getRole() { return role; }
public void setRole(String role) { this.role = role; }
@Override
public String toString() {
return "UserProfile [UserID=" + userID + ", FullName=" + fullName + ", Email=" + email + ", MobileNumber=" + mobileNumber + ", Role=" + role + "]";
}
}
class Reservation {
private int reservationId;
private String checkInDate;
private String checkOutDate;
private String roomPreference;
private String guestName;
private long contactNumber;
public Reservation(int reservationId, String checkInDate, String checkOutDate, String roomPreference, String guestName, long contactNumber) {
this.reservationId = reservationId;
this.checkInDate = checkInDate;
this.checkOutDate = checkOutDate;
this.roomPreference = roomPreference;
this.guestName = guestName;
this.contactNumber = contactNumber;
}
@Override
public String toString() {
return "Reservation [ReservationId=" + reservationId + ", CheckIn=" + checkInDate + ", CheckOut=" + checkOutDate +
", RoomPreference=" + roomPreference + ", Guest=" + guestName + ", Contact=" + contactNumber + "]";
}
public int getReservationId() {
return reservationId;
}
}
class BookingHistory {
private String userName;
private int reservationId;
public BookingHistory(String userName, int reservationId) {
this.userName = userName;
this.reservationId = reservationId;
}
@Override
public String toString() {
return "BookingHistory [User=" + userName + ", ReservationID=" + reservationId + "]";
}
public int getReservationId() {
return reservationId;
}
}
class Complaint {
private String userName;
private long contactNumber;
private int roomNumber;
private String typeOfComplaint;
private int feedbackRating;
public Complaint(String userName, long contactNumber, int roomNumber, String typeOfComplaint, int feedbackRating) {
this.userName = userName;
this.contactNumber = contactNumber;
this.roomNumber = roomNumber;
this.typeOfComplaint = typeOfComplaint;
this.feedbackRating = feedbackRating;
}
@Override
public String toString() {
return "Complaint [User=" + userName + ", Contact=" + contactNumber + ", Room=" + roomNumber +
", ComplaintType=" + typeOfComplaint + ", Rating=" + feedbackRating + "]";
}
public int getRoomNumber() {
return roomNumber;
}
}
class BookingHotel {
private int bookingID;
private String roomTypeSelection;
private String bookingDetails;
private double price;
// Constructor
public BookingHotel(int bookingID, String roomTypeSelection, String bookingDetails, double price) {
this.bookingID = bookingID;
this.roomTypeSelection = roomTypeSelection;
this.bookingDetails = bookingDetails;
this.price = price;
}
// Getters and Setters
public int getBookingID() { return bookingID; }
public void setRoomTypeSelection(String roomTypeSelection) { this.roomTypeSelection = roomTypeSelection; }
public String getRoomTypeSelection() { return roomTypeSelection; }
public String getBookingDetails() { return bookingDetails; }
public double getPrice() { return price; }
@Override
public String toString() {
return "BookingHotel [BookingID=" + bookingID + ", RoomTypeSelection=" + roomTypeSelection +
", BookingDetails=" + bookingDetails + ", Price=" + price + "]";
}
}
public class Main {
static List<UserProfile> userProfiles = new ArrayList<>();
static List<Reservation> reservations = new ArrayList<>();
static List<BookingHistory> bookingHistories = new ArrayList<>();
static List<Complaint> complaints = new ArrayList<>();
static List<BookingHotel> bookings = new ArrayList<>();
static int bookingCounter = 1; // Auto-incremented booking ID
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
boolean exit = false;
while (!exit) {
System.out.println("----- Hotel Management System -----");
System.out.println("1. Register User");
System.out.println("2. Login");
System.out.println("3. Exit");
System.out.print("Choose an option: ");
int option = sc.nextInt();
switch (option) {
case 1:
registerUser(sc); // Register a user
break;
case 2:
login(sc); // Login for Admin or User
break;
case 3:
exit = true;
break;
default:
System.out.println("Invalid option. Please try again.");
break;
}
}
}
public static void registerUser(Scanner sc) {
System.out.println("---- Register User ----");
System.out.print("Enter User ID: ");
String userID = sc.next();
System.out.print("Enter Full Name: ");
String fullName = sc.next();
System.out.print("Enter Email: ");
String email = sc.next();
System.out.print("Enter Mobile Number: ");
String mobileNumber = sc.next();
System.out.print("Enter Password: ");
String password = sc.next();
System.out.print("Enter Role (admin/user): ");
String role = sc.next();
UserProfile userProfile = new UserProfile(userID, fullName, email, mobileNumber, password, role);
userProfiles.add(userProfile);
System.out.println("User registered successfully!");
}
public static void login(Scanner sc) {
System.out.println("---- Login ----");
System.out.print("Enter User ID: ");
String userID = sc.next();
System.out.print("Enter Password: ");
String password = sc.next();
for (UserProfile userProfile : userProfiles) {
if (userProfile.getUserID().equals(userID) && userProfile.getPassword().equals(password)) {
System.out.println("Login successful!");
if (userProfile.getRole().equalsIgnoreCase("admin")) {
adminPage(sc); // Admin page
} else {
userPage(sc); // User page
}
return;
}
}
System.out.println("Invalid UserID or Password.");
}
public static void adminPage(Scanner sc) {
boolean exit = false;
while (!exit) {
System.out.println("----- Admin Page -----");
System.out.println("1. Booking Hotel Services");
System.out.println("2. View Booking History");
System.out.println("3. View Booking History by ID");
System.out.println("4. View Room Status");
System.out.println("5. View Check-out Billing Invoice");
System.out.println("6. View Complaints");
System.out.println("7. Logout");
System.out.print("Choose an option: ");
int option = sc.nextInt();
switch (option) {
case 1:
bookHotelServices(sc); // Book hotel services
break;
case 2:
viewBookingHistoryAdmin(); // View booking history for admin
break;
case 3:
viewBookingHistoryByID(sc); // View booking history by ID
break;
case 4:
viewRoomStatus(); // View room status
break;
case 5:
viewCheckOutBillingInvoice(); // View check-out billing invoice
break;
case 6:
viewComplaints(); // View complaints
break;
case 7:
exit = true;
break;
default:
System.out.println("Invalid option. Please try again.");
break;
}
}
}
public static void userPage(Scanner sc) {
boolean exit = false;
while (!exit) {
System.out.println("----- User Page -----");
System.out.println("1. Make Reservation");
System.out.println("2. View Booking History");
System.out.println("3. View Room Status");
System.out.println("4. Check-out Billing");
System.out.println("5. Make Complaint");
System.out.println("6. Contact");
System.out.println("7. Pay Bill"); // Add this option for bill payment
System.out.println("8. Logout");
System.out.print("Choose an option: ");
int option = sc.nextInt();
switch (option) {
case 1:
makeReservation(sc); // Make reservation
break;
case 2:
viewBookingHistory(); // View booking history
break;
case 3:
viewRoomStatus(); // View room status
break;
case 4:
checkOutBilling(); // Check-out billing
break;
case 5:
makeComplaint(sc); // Make complaint
break;
case 6:
contact(); // Contact information
break;
case 7:
payBill(sc); // Call the bill payment method
break;
case 8:
exit = true;
break;
default:
System.out.println("Invalid option. Please try again.");
break;
}
}
}
// User Story 4: Make reservation
public static void makeReservation(Scanner sc) {
System.out.println("---- Make Reservation ----");
System.out.print("Enter Reservation ID: ");
int reservationId = sc.nextInt();
System.out.print("Enter Check-In Date (YYYY-MM-DD): ");
String checkInDate = sc.next();
System.out.print("Enter Check-Out Date (YYYY-MM-DD): ");
String checkOutDate = sc.next();
System.out.print("Enter Room Preference (Single/Double): ");
String roomPreference = sc.next();
System.out.print("Enter Guest Name: ");
String guestName = sc.next();
System.out.print("Enter Contact Number: ");
long contactNumber = sc.nextLong();
Reservation reservation = new Reservation(reservationId, checkInDate, checkOutDate, roomPreference, guestName, contactNumber);
reservations.add(reservation);
BookingHistory bookingHistory = new BookingHistory(guestName, reservationId);
bookingHistories.add(bookingHistory);
System.out.println("Reservation Successful!");
}
// User Story 5: View booking history
public static void viewBookingHistory() {
System.out.println("---- Booking History ----");
for (BookingHistory history : bookingHistories) {
System.out.println(history);
}
}
// User Story 6: Make complaint
public static void makeComplaint(Scanner sc) {
System.out.println("---- Make Complaint ----");
System.out.print("Enter Your Name: ");
String userName = sc.next();
System.out.print("Enter Contact Number: ");
long contactNumber = sc.nextLong();
System.out.print("Enter Room Number: ");
int roomNumber = sc.nextInt();
System.out.print("Enter Type of Complaint (Poor housekeeping, Noisy guests, etc.): ");
String typeOfComplaint = sc.next();
System.out.print("Enter Feedback Rating (1-5): ");
int feedbackRating = sc.nextInt();
Complaint complaint = new Complaint(userName, contactNumber, roomNumber, typeOfComplaint, feedbackRating);
complaints.add(complaint);
System.out.println("Complaint submitted successfully!");
}
// User Story 7: Contact
public static void contact() {
System.out.println("---- Contact Us ----");
System.out.println("For any inquiries, please contact us at:");
System.out.println("Email: [email protected]");
System.out.println("Phone: +123456789");
}
// User Story 8: View room status
public static void viewRoomStatus() {
System.out.println("---- Room Status ----");
// Sample room status
System.out.println("Room 101: Available");
System.out.println("Room 102: Occupied");
System.out.println("Room 103: Available");
System.out.println("Room 104: Under Maintenance");
}
// User Story 9: Check-out billing
public static void checkOutBilling() {
System.out.println("---- Check-out Billing ----");
// Sample billing details
System.out.println("Reservation ID: 1");
System.out.println("Room Type: Single");
System.out.println("Check-in Date: 2024-09-01");
System.out.println("Check-out Date: 2024-09-07");
System.out.println("Total Amount: $700");
}
// User Story 10: Bill Payment
public static void payBill(Scanner sc) {
System.out.println("---- Bill Payment ----");
// Display the service amount
double serviceAmount = 500.0; // This could be dynamically set based on services booked
System.out.println("Service Amount: $" + serviceAmount);
// Choose payment option (assuming only card payment for now)
System.out.println("Select Payment Method: ");
System.out.println("1. Debit Card");
System.out.println("2. Credit Card");
int paymentOption = sc.nextInt();
if (paymentOption == 1 || paymentOption == 2) {
// Get card details
sc.nextLine(); // Consume newline
System.out.print("Enter Card Holder Name: ");
String cardHolderName = sc.nextLine();
System.out.print("Enter Card Number: ");
String cardNumber = sc.nextLine();
System.out.print("Enter CVV: ");
String cvv = sc.nextLine();
System.out.print("Enter Expiry Date (MM/YY): ");
String expiryDate = sc.nextLine();
// Simulate payment processing
System.out.println("Processing payment...");
// Payment successful
System.out.println("Payment Successful!");
// Display invoice
System.out.println("---- Payment Invoice ----");
System.out.println("Card Holder Name: " + cardHolderName);
System.out.println("Service Amount: $" + serviceAmount);
System.out.println("Payment Method: " + (paymentOption == 1 ? "Debit Card" : "Credit Card"));
System.out.println("Card Number: **** **** **** " + cardNumber.substring(cardNumber.length() - 4));
System.out.println("Transaction Status: Successful");
System.out.println("------");
} else {
System.out.println("Invalid Payment Option.");
}
}
// User Story 11: Book hotel services (Admin)
// - User Story 11: Add new Booking -
public static void addBooking(Scanner sc) {
System.out.println("---- Add New Booking ----");
// Auto-generate Booking ID
int bookingID = bookingCounter++;
// Input Room Type Selection
System.out.print("Enter Room Type (Single/Double): ");
String roomTypeSelection = sc.next();
// Input Booking Details
System.out.print("Enter Booking Details: ");
sc.nextLine(); // Consume newline
String bookingDetails = sc.nextLine();
// Input Price
System.out.print("Enter Price: ");
double price = sc.nextDouble();
// Create a new booking and add it to the list
BookingHotel booking = new BookingHotel(bookingID, roomTypeSelection, bookingDetails, price);
bookings.add(booking);
// Display success message
System.out.println("Successfully registered Booking: " + bookingID);
}
// - User Story 11: Update Booking -
public static void updateBooking(Scanner sc) {
System.out.println("---- Update Booking ----");
// Input Booking ID to update
System.out.print("Enter Booking ID to update: ");
int bookingID = sc.nextInt();
// Find the booking
for (BookingHotel booking : bookings) {
if (booking.getBookingID() == bookingID) {
// Input new Room Type
System.out.print("Enter new Room Type (Single/Double): ");
String newRoomType = sc.next();
// Update Room Type
booking.setRoomTypeSelection(newRoomType);
System.out.println("Booking details are updated for Booking ID: " + bookingID);
return;
}
}
// If booking not found
System.out.println("Booking ID not found.");
}
// - User Story 11: Delete Booking -
public static void deleteBooking(Scanner sc) {
System.out.println("---- Delete Booking ----");
// Input Booking ID to delete
System.out.print("Enter Booking ID to delete: ");
int bookingID = sc.nextInt();
// Find and remove the booking
for (int i = 0; i < bookings.size(); i++) {
if (bookings.get(i).getBookingID() == bookingID) {
bookings.remove(i);
System.out.println("Booking details are deleted for Booking ID: " + bookingID);
return;
}
}
// If booking not found
System.out.println("Booking ID not found.");
}
// - Admin Menu Option 1: Booking Hotel Services -
public static void bookHotelServices(Scanner sc) {
boolean exit = false;
while (!exit) {
System.out.println("----- Booking Services Menu -----");
System.out.println("1. Add New Booking");
System.out.println("2. Update Booking");
System.out.println("3. Delete Booking");
System.out.println("4. Back to Admin Page");
System.out.print("Choose an option: ");
int option = sc.nextInt();
switch (option) {
case 1:
addBooking(sc); // Call method to add booking
break;
case 2:
updateBooking(sc); // Call method to update booking
break;
case 3:
deleteBooking(sc); // Call method to delete booking
break;
case 4:
exit = true; // Exit to admin page
break;
default:
System.out.println("Invalid option. Please try again.");
break;
}
}
}
// User Story 13: View booking history (Admin)
public static void viewBookingHistoryAdmin() {
System.out.println("---- Booking History ----");
for (BookingHistory history : bookingHistories) {
System.out.println(history);
}
}
// User Story 14: View booking history by ID (Admin)
public static void viewBookingHistoryByID(Scanner sc) {
System.out.println("---- View Booking History by ID ----");
System.out.print("Enter Reservation ID: ");
int reservationId = sc.nextInt();
for (BookingHistory history : bookingHistories) {
if (history.getReservationId() == reservationId) {
System.out.println(history);
return;
}
}
System.out.println("No booking history found for the given ID.");
}
// User Story 15: View check-out billing invoice (Admin)
public static void viewCheckOutBillingInvoice() {
System.out.println("---- Check-out Billing Invoice ----");
System.out.println("Reservation ID: 1");
System.out.println("Room Type: Single");
System.out.println("Check-in Date: 2024-09-01");
System.out.println("Check-out Date: 2024-09-07");
System.out.println("Total Amount: $700");
System.out.println("Thank you for staying with us!");
}
// User Story 12: View complaints (Admin)
public static void viewComplaints() {
System.out.println("---- All Complaints ----");
for (Complaint complaint : complaints) {
System.out.println(complaint);
}
}
}