Question

In: Computer Science

Hotel California Hotel California is a small modern-style hotel located not too far from the Central...

Hotel California
Hotel California is a small modern-style hotel located not too far from the Central Bangkok District. Your job is to write a simple piece of software to manage the room occupancy. The hotel has two buildings; each building has four floors; and each floor has a different number of rooms. Building A has five rooms on each floor. Building B has four rooms on each floor. Each room is graded with Standard, Deluxe, and Suite, and the rates per night are $100, $250, and $600 respectively. In both buildings, the rooms on the first and the second floors are Standard; the rooms on the third floor are Deluxe; and the rooms on the fourth floor are Suite.
Write a program that allows the hotel front desk to reserve a room for its customers. When a customer reserves a room, he needs to provide his name (first name and last name), his phone number and the room grade. The system must check for the availability of that room grade. If the preferred room grade is available, the reservation number will be generated and the room number will be assigned to that reservation. If there are no rooms of that grade available, a proper message must be shown.
Note that the hotel policy allows only 1 room with 1-night stay per booking. If the customer wants to book more than one rooms, he needs to make more reservations. The hotel allows the room to be booked only one day in advance. Hence, the system will only have the booking for tomorrow's check-in.

The front desk should also be able to record the payment for a reservation during the customer's check-out process (given a reservation number, the customer's name or the customer's phone number). If the customer has more than one reservations made on that day, the list of reservations must be shown so the front desk can apply the payment to such a reservation. In order to keep track of the hotel's income, the staff should be able to print the sales reports for each building (grouped by the room grades).
Design and implement the system for Hotel California using Java. Make use of queues, stacks and/or linked lists if necessary. Also add comments explaining the logic behind your code.

Solutions

Expert Solution

import java.util.ArrayList;
import java.util.Scanner;


class Room{

String firstname,lastname,roomgrade;
int phoneNumber;
public Room(String firstName,String lastName, int phone, String roomGrade ){
this.firstname = firstName;
this.lastname = lastName;
this.phoneNumber = phone;
this.roomgrade = roomGrade;
}

void printDetails(){
System.out.println("Name :" +this.firstname +" " + this.lastname);
System.out.println("Phone: " + this.phoneNumber);
System.out.println("Room Grade :" + this.roomgrade);
System.out.println("Payment : " + this.payment());
}

int payment(){
if (this.roomgrade == "Suite")
return 600;
else if (this.roomgrade.equals("Delux"))
return 250;
else
return 100;
}
}

public class Main {
public static void main() {
ArrayList<Room> customersA = new ArrayList<Room>();
ArrayList<Room> customersB = new ArrayList<Room>();
int enex = 0;
Scanner sc = new Scanner(System.in);
while (true) {
System.out.println("Enter 1 for entry 0 for exit of customer! :");
enex = sc.nextInt();
if (enex == 1)
entry(customersA, customersB);
if (enex == 0) {
System.out.println("Enter First Name: ");
String firstname = sc.next();
System.out.println("Enter Last Name: ");
String lastname = sc.next();
System.out.println("ENter Phone number: ");
int phone = sc.nextInt();
exit(firstname, lastname, phone, customersA, customersB);
}
}

}

public static void exit(String firstName, String lastName, int phone, ArrayList<Room> customersA, ArrayList<Room> customersB) {

int Asize = customersA.size();
int Bsize = customersB.size();

for (int i = 0; i < Math.max(Asize, Bsize); i++) {
if (i < Asize)
if (customersA.get(i).firstname.equals(firstName)) {
if (customersA.get(i).lastname.equals(lastName)) {
if (customersA.get(i).phoneNumber == phone) {
customersA.get(i).printDetails();
customersA.remove(customersA.get(i));
}
}
}
if (i < Bsize)
if (customersB.get(i).firstname.equals(firstName)) {
if (customersB.get(i).lastname.equals((lastName))) {
if (customersB.get(i).phoneNumber == phone) {
customersB.get(i).printDetails();
customersB.remove(customersB.get(i));
}
}

}
}

}

public static void entry(ArrayList<Room> customersA, ArrayList<Room> customersB) {

int totalCustomers = 0;
int occupiedStandardA = 0;
int occupiedStandardB = 0;

int occupiedDeluxA = 0;
int occupiedDeluxB = 0;

int occupiedSuiteA = 0;
int occupiedSuiteB = 0;

String firstName = "";
String lastName = "";

int phone = 0;

String roomGrade = "";

Scanner sc = new Scanner(System.in);

char exit = ' ';

while (exit != 'Y' || exit != 'y') {
System.out.println("Enter first Name: ");
firstName = sc.next();

System.out.println("Enter Last Name: ");
lastName = sc.next();

System.out.println("Enter Phone Number: ");
phone = sc.nextInt();

System.out.println("Enter Room Grade(Standard, Delux, Suite): ");
roomGrade = sc.next();

System.out.println("Exit [Y/N]");
exit = sc.next().strip().charAt(0);

if (roomGrade.equals("Standard")) {
if (occupiedStandardA < 10) {
Room customer = new Room(firstName, lastName, phone, roomGrade);
occupiedStandardA += 1;
totalCustomers += 1;
customersA.add(customer);
} else if (occupiedStandardB < 8) {
Room customer = new Room(firstName, lastName, phone, roomGrade);
occupiedStandardB += 1;
totalCustomers += 1;
customersB.add(customer);
} else
System.out.println("No Standard Rooms Available!!");
} else if (roomGrade.equals("Dulex")) {
if (occupiedDeluxA < 5) {
Room customer = new Room(firstName, lastName, phone, roomGrade);
occupiedDeluxA += 1;
totalCustomers += 1;
customersA.add(customer);
} else if (occupiedDeluxB < 4) {
Room customer = new Room(firstName, lastName, phone, roomGrade);
occupiedDeluxB += 1;
totalCustomers += 1;
customersB.add(customer);
} else
System.out.println("No Delux Rooms Available!!");
} else if (roomGrade.equals("Suite")) {
if (occupiedSuiteA < 5) {
Room customer = new Room(firstName, lastName, phone, roomGrade);
occupiedSuiteA += 1;
totalCustomers += 1;
customersA.add(customer);
} else if (occupiedSuiteB < 4) {
Room customer = new Room(firstName, lastName, phone, roomGrade);
occupiedSuiteB += 1;
totalCustomers += 1;
customersB.add(customer);
} else
System.out.println("No Suite Available!!");
} else
System.out.println("No Rooms Available!!");
}
}
}


Related Solutions

Hotel California is a small modern-style hotel located not too far from the Central Bangkok District....
Hotel California is a small modern-style hotel located not too far from the Central Bangkok District. Your job is to write a simple piece of software to manage the room occupancy. The hotel has two buildings; each building has four floors; and each floor has a different number of rooms. Building A has five rooms on each floor. Building B has four rooms on each floor. Each room is graded with Standard, Deluxe, and Suite, and the rates per night...
The Hill of Tara is located in south-central Meath not far from Dublin, Ireland. Tara is...
The Hill of Tara is located in south-central Meath not far from Dublin, Ireland. Tara is of great cultural and archaeological importance, since it is by legend the seat of the ancient high kings of Ireland. Magnetic surveying is one technique used by archaeologists to determine anomalies arising from variation in magnetic susceptibility. Unusual changes in magnetic susceptibility might (or might not) indicate an important archaeological discovery. Let x be a random variable that represents a magnetic susceptibility (MS) reading...
The Modern Motel Industry" outline a very small marketing plan for the hotel segment you researched....
The Modern Motel Industry" outline a very small marketing plan for the hotel segment you researched. Please be as creative as you like. Analyze modern ownership and management patterns, and create a list of best practices for those wishing to either invest in or make a career in the hotel industry. "Group Bookings" Considering the same hotel you used evaluate and discuss the pros and cons of taking group bookings. Please give specific examples relevant to the chain you selected....
Marketing assignment The Inn at Prescott Ranch is a small, boutique hotel located in Prescott, Arizona....
Marketing assignment The Inn at Prescott Ranch is a small, boutique hotel located in Prescott, Arizona. It opened in 1998. The Inn has identified the main competition as the Prescott Resort, owned and operated by the Yavapai Nation, and the Hassayampa Inn, a historic hotel in downtown Prescott, adjacent to Whiskey Row. The Inn has 65 rooms on two floors—each with a private balcony. The nightly room rates are the highest in Prescott. The Inn offers a full array of...
To keep their action local, paracrine signal molecules must be prevented from straying too far from...
To keep their action local, paracrine signal molecules must be prevented from straying too far from their points of origin. Suggest different ways by which this could be accomplished. Explain your answer
When an object is located very far away from a convex mirror, the image of the...
When an object is located very far away from a convex mirror, the image of the object is 12.0 cm behind the mirror. Using a ray diagram drawn to scale, determine where the image is located when the object is placed 6.0 cm in front of the mirror. Note that the mirror must be drawn to scale also. In your drawing, assume that the height of the object is 3.0 cm. cm  ---Select--- in front of behind the mirror As an...
Life has been found on a newly discovered planet not too far from our solar system!...
Life has been found on a newly discovered planet not too far from our solar system! The planet is named Nairb. A mission was sent to Nairb to learn more about these new life forms and the following data was obtained. The life forms on Nairb have a similar appearance to those of earth. These new life forms are also composed of many very similar molecular building blocks to life forms on earth, for example: amino acids and lipids are...
You predict that nature reserves located far from large cities (with populations >100,000) have a higher...
You predict that nature reserves located far from large cities (with populations >100,000) have a higher proportion of plant species that are native to their region than reserves that are close to large cities. You collect the following data on 7 nature reserves: Conduct an appropriate analysis to test the prediction.
Developing an Equation from Average CostsParadise Pub is a high-end dog hotel located in New York....
Developing an Equation from Average CostsParadise Pub is a high-end dog hotel located in New York. Assume that in March, when dog-days occupancy was at an annual low of 500 days, the average cost per dog-day was $26. In July, when dog-days were at a capacity level of 4,500, the average cost per dog-day was $10.(a) Develop an equation for monthly operating costs. (Let X = dog-days per month)Total cost = $Answer + $Answer * X(b) Determine the average cost...
A seafood restaurant often receives complaints from it’s patrons that the lobster is too small. The...
A seafood restaurant often receives complaints from it’s patrons that the lobster is too small. The menu lists the weight of a lobster as 462g. The next time the restaurant receives a batch of 60 lobsters it weighs them and finds the average is 451g with a standard deviation of 31g. Do you think the restaurant sells lobsters that are smaller than advertised? Perform a hypothesis test at α = 0.01
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT