Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add guest model #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 70 additions & 72 deletions Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,25 @@
import java.util.ArrayList;
import java.util.Scanner;


class Guest implements Serializable
{
String name;
String contact;
String gender;

public Guest(String name, String contact, String gender) {
this.name = name;
this.contact = contact;
this.gender = gender;
}
}
class Food implements Serializable
{
int itemno;
int quantity;
int quantity;
float price;

Food(int itemno,int quantity)
{
this.itemno=itemno;
Expand All @@ -32,42 +45,27 @@ class Food implements Serializable
}
class Singleroom implements Serializable
{
String name;
String contact;
String gender;
Guest guest;
ArrayList<Food> food =new ArrayList<>();


Singleroom()
{
this.name="";
this.guest = new Guest("", "", "");
}
Singleroom(String name,String contact,String gender)
{
this.name=name;
this.contact=contact;
this.gender=gender;
this.guest = new Guest(name, contact, gender);
}
}
class Doubleroom extends Singleroom implements Serializable
{
String name2;
String contact2;
String gender2;

Doubleroom()
{
this.name="";
this.name2="";
}
{
Guest guest2;

Doubleroom(String name,String contact,String gender,String name2,String contact2,String gender2)
{
this.name=name;
this.contact=contact;
this.gender=gender;
this.name2=name2;
this.contact2=contact2;
this.gender2=gender2;
this.guest = new Guest(name, contact, gender);
this.guest2 = new Guest(name2, contact2, gender2);
}
}
class NotAvailable extends Exception
Expand All @@ -94,7 +92,7 @@ class Hotel
static void CustDetails(int i,int rn)
{
String name, contact, gender;
String name2 = null, contact2 = null;
String name2 = null, contact2 = null;
String gender2="";
System.out.print("\nEnter customer name: ");
name = sc.next();
Expand All @@ -110,8 +108,8 @@ static void CustDetails(int i,int rn)
contact2=sc.next();
System.out.print("Enter gender: ");
gender2 = sc.next();
}
}

switch (i) {
case 1:hotel_ob.luxury_doublerrom[rn]=new Doubleroom(name,contact,gender,name2,contact2,gender2);
break;
Expand All @@ -125,7 +123,7 @@ static void CustDetails(int i,int rn)
break;
}
}

static void bookroom(int i)
{
int j;
Expand Down Expand Up @@ -226,7 +224,7 @@ static void bookroom(int i)
}
System.out.println("Room Booked");
}

static void features(int i)
{
switch (i) {
Expand All @@ -243,7 +241,7 @@ static void features(int i)
break;
}
}

static void availability(int i)
{
int j,count=0;
Expand Down Expand Up @@ -282,15 +280,15 @@ static void availability(int i)
}
System.out.println("Number of rooms available : "+count);
}

static void bill(int rn,int rtype)
{
double amount=0;
String list[]={"Sandwich","Pasta","Noodles","Coke"};
System.out.println("\n*******");
System.out.println(" Bill:-");
System.out.println("*******");

switch(rtype)
{
case 1:
Expand All @@ -307,7 +305,7 @@ static void bill(int rn,int rtype)
String format = "%-10s%-10s%-10s%n";
System.out.printf(format,list[obb.itemno-1],obb.quantity,obb.price );
}

break;
case 2:amount+=3000;
System.out.println("Room Charge - "+3000);
Expand Down Expand Up @@ -353,17 +351,17 @@ static void bill(int rn,int rtype)
}
System.out.println("\nTotal Amount- "+amount);
}

static void deallocate(int rn,int rtype)
{
int j;
char w;
switch (rtype) {
case 1:
case 1:
if(hotel_ob.luxury_doublerrom[rn]!=null)
System.out.println("Room used by "+hotel_ob.luxury_doublerrom[rn].name);
else
{
System.out.println("Room used by "+hotel_ob.luxury_doublerrom[rn].guest.name);
else
{
System.out.println("Empty Already");
return;
}
Expand All @@ -375,13 +373,13 @@ static void deallocate(int rn,int rtype)
hotel_ob.luxury_doublerrom[rn]=null;
System.out.println("Deallocated succesfully");
}

break;
case 2:
if(hotel_ob.deluxe_doublerrom[rn]!=null)
System.out.println("Room used by "+hotel_ob.deluxe_doublerrom[rn].name);
else
{
System.out.println("Room used by "+hotel_ob.deluxe_doublerrom[rn].guest.name);
else
{
System.out.println("Empty Already");
return;
}
Expand All @@ -393,13 +391,13 @@ static void deallocate(int rn,int rtype)
hotel_ob.deluxe_doublerrom[rn]=null;
System.out.println("Deallocated succesfully");
}

break;
case 3:
if(hotel_ob.luxury_singleerrom[rn]!=null)
System.out.println("Room used by "+hotel_ob.luxury_singleerrom[rn].name);
else
{
System.out.println("Room used by "+hotel_ob.luxury_singleerrom[rn].guest.name);
else
{
System.out.println("Empty Already");
return;
}
Expand All @@ -411,13 +409,13 @@ static void deallocate(int rn,int rtype)
hotel_ob.luxury_singleerrom[rn]=null;
System.out.println("Deallocated succesfully");
}

break;
case 4:
if(hotel_ob.deluxe_singleerrom[rn]!=null)
System.out.println("Room used by "+hotel_ob.deluxe_singleerrom[rn].name);
else
{
System.out.println("Room used by "+hotel_ob.deluxe_singleerrom[rn].guest.name);
else
{
System.out.println("Empty Already");
return;
}
Expand All @@ -435,7 +433,7 @@ static void deallocate(int rn,int rtype)
break;
}
}

static void order(int rn,int rtype)
{
int i,q;
Expand All @@ -447,7 +445,7 @@ static void order(int rn,int rtype)
i = sc.nextInt();
System.out.print("Quantity- ");
q=sc.nextInt();

switch(rtype){
case 1: hotel_ob.luxury_doublerrom[rn].food.add(new Food(i,q));
break;
Expand All @@ -456,11 +454,11 @@ static void order(int rn,int rtype)
case 3: hotel_ob.luxury_singleerrom[rn].food.add(new Food(i,q));
break;
case 4: hotel_ob.deluxe_singleerrom[rn].food.add(new Food(i,q));
break;
break;
}
System.out.println("Do you want to order anything else ? (y/n)");
wish=sc.next().charAt(0);
}while(wish=='y'||wish=='Y');
wish=sc.next().charAt(0);
}while(wish=='y'||wish=='Y');
}
catch(NullPointerException e)
{
Expand Down Expand Up @@ -491,17 +489,17 @@ public void run() {
catch(Exception e)
{
System.out.println("Error in writing "+e);
}
}

}

}

public class Main {
public static void main(String[] args){

try
{
{
File f = new File("backup");
if(f.exists())
{
Expand All @@ -528,7 +526,7 @@ public static void main(String[] args){
break;
case 3:System.out.println("\nChoose room type :\n1.Luxury Double Room \n2.Deluxe Double Room \n3.Luxury Single Room\n4.Deluxe Single Room\n");
ch2 = sc.nextInt();
Hotel.bookroom(ch2);
Hotel.bookroom(ch2);
break;
case 4:
System.out.print("Room Number -");
Expand All @@ -546,7 +544,7 @@ else if(ch2>0)
else
System.out.println("Room doesn't exist");
break;
case 5:
case 5:
System.out.print("Room Number -");
ch2 = sc.nextInt();
if(ch2>60)
Expand All @@ -563,23 +561,23 @@ else if(ch2>0)
System.out.println("Room doesn't exist");
break;
case 6:break x;

}

System.out.println("\nContinue : (y/n)");
wish=sc.next().charAt(0);
wish=sc.next().charAt(0);
if(!(wish=='y'||wish=='Y'||wish=='n'||wish=='N'))
{
System.out.println("Invalid Option");
System.out.println("\nContinue : (y/n)");
wish=sc.next().charAt(0);
wish=sc.next().charAt(0);
}
}while(wish=='y'||wish=='Y');

}while(wish=='y'||wish=='Y');

Thread t=new Thread(new write(Hotel.hotel_ob));
t.start();
}
}
catch(Exception e)
{
System.out.println("Not a valid input");
Expand Down