import java.util.ArrayList;
import java.util.Collection;
import javax.swing.JOptionPane;
public class Hotel {
static ArrayList<Hotel> ReservationList= new ArrayList<Hotel>();
static String input="";
public static void main(String[] args) {
int selection = 0;
int start = 0;
int foundAt = -1;
String searchReservation="";
start=JOptionPane.showConfirmDialog(null,"Do you wish to reserve a hotel room?", null, JOptionPane.YES_NO_OPTION);
if (start==JOptionPane.NO_OPTION)
JOptionPane.showMessageDialog(null, "Thank you for visiting!");
else
while(selection!=4){
selection = menu();
switch(selection) {
case 1: Reservation reservation = new Reservation();
reservation.addReservation();
ReservationList.add(null);
break;
case 2: if(ReservationList.isEmpty())
JOptionPane.showMessageDialog(null,
"database is empty! goback and add records.");
else
dispAllReservations();
break;
}
}
}//end main
public static int menu() {
int selection=0;
String Prompt= "-1-Add a reservation\n" +
"-2-Show a reservation\n" +
"-3-Quit program\n" +
"\tEnter selection 1-3: ";
input=JOptionPane.showInputDialog(Prompt);
selection = Integer.parseInt(input);
return selection;
}
public static void dispAllReservations()
{
for (int i = 0; i < ReservationList.size(); i++)
{
ReservationList.get(i).dispReport();
}//end for i
}//end dispAllBackflows
}
//=================================================
class Reservation{
String ReservationNo;
String firstName;
String lastName;
String roomType;
String Email;
String phoneNumber;
String numberOfPeople;
String zipCode;
String input="";
Reservation()
{
ReservationNo="";
firstName="";
lastName="";
roomType="";
Email="";
phoneNumber="";
numberOfPeople="";
zipCode="";
}
Reservation(String ReservationNo,String firstName, String roomType,String Email,
String phoneNumber,String numberOfPeople,String zipCode,String lastName)
{
this.ReservationNo=ReservationNo;
this.firstName=firstName;
this.lastName=lastName;
this.roomType=roomType;
this.Email=Email;
this.phoneNumber=phoneNumber;
this.numberOfPeople=numberOfPeople;
this.zipCode=zipCode;
}
void addReservation() {
input = JOptionPane.showInputDialog("Enter your first name:");
firstName=input;
input = JOptionPane.showInputDialog("Enter your last name:");
lastName=input;
input = JOptionPane.showInputDialog("Enter your room type:");
roomType=input;
input = JOptionPane.showInputDialog("Enter your email:");
Email=input;
input = JOptionPane.showInputDialog("Enter your phone number:");
phoneNumber=input;
input = JOptionPane.showInputDialog("How many people will be staying:");
numberOfPeople=input;
input = JOptionPane.showInputDialog("Enter your zip code:");
zipCode=input;
}
void dispReport() {
JOptionPane.showMessageDialog(null, "First Name" + firstName + "\n" +
"Last Name " + lastName + "\n" +
"Room Type " + roomType + "\n" +
"Email " + Email + "\n" +
"Phone " + phoneNumber + "\n" +
"Guest number" + numberOfPeople + "\n" +
"zipCode" + zipCode + "\n"
);
}
}