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

Solid Principle #7

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
66 changes: 60 additions & 6 deletions Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,11 @@ static void deallocate(int rn,int rtype)
}
}

public static holder getHotel_ob() {
return hotel_ob;
}

/*
static void order(int rn,int rtype)
{
int i,q;
Expand Down Expand Up @@ -471,7 +476,56 @@ static void order(int rn,int rtype)
{
System.out.println("Cannot be done");
}
}*/
}

interface Servicios{
abstract void darServicios(int rn,int rtype);
}

class ordenarComida implements Servicios{

public ordenarComida() {
}


@Override
public void darServicios(int rn,int rtype) {
holder hotel_ob = Hotel.getHotel_ob();
int i,q;
char wish;
try{
System.out.println("\n==========\n Menu: \n==========\n\n1.Sandwich\tRs.50\n2.Pasta\t\tRs.60\n3.Noodles\tRs.70\n4.Coke\t\tRs.30\n");
do
{
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;
case 2: hotel_ob.deluxe_doublerrom[rn].food.add(new Food(i,q));
break;
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;
}
System.out.println("Do you want to order anything else ? (y/n)");
wish=sc.next().charAt(0);
}while(wish=='y'||wish=='Y');
}
catch(NullPointerException e)
{
System.out.println("\nRoom not booked");
}
catch(Exception e)
{
System.out.println("Cannot be done");
}
}

}


Expand Down Expand Up @@ -500,7 +554,7 @@ public void run() {

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

ordenarComida order = new ordenarComida();
try
{
File f = new File("backup");
Expand Down Expand Up @@ -531,19 +585,19 @@ public static void main(String[] args){
ch2 = sc.nextInt();
Hotel.bookroom(ch2);
break;
case 4:
ase 4:
System.out.print("Room Number -");
ch2 = sc.nextInt();
if(ch2>60)
System.out.println("Room doesn't exist");
else if(ch2>40)
Hotel.order(ch2-41,4);
order.darServicios(ch2-41,4);
else if(ch2>30)
Hotel.order(ch2-31,3);
order.darServicios(ch2-31,3);
else if(ch2>10)
Hotel.order(ch2-11,2);
order.darServicios(ch2-11,2);
else if(ch2>0)
Hotel.order(ch2-1,1);
order.darServicios(ch2-1,1);
else
System.out.println("Room doesn't exist");
break;
Expand Down