diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..fb565a5 --- /dev/null +++ b/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..1873dff --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + Resturant + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..7341ab1 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/bin/Customer.class b/bin/Customer.class new file mode 100644 index 0000000..8ebacd5 Binary files /dev/null and b/bin/Customer.class differ diff --git a/bin/Food.class b/bin/Food.class new file mode 100644 index 0000000..9762c47 Binary files /dev/null and b/bin/Food.class differ diff --git a/bin/Menu.class b/bin/Menu.class new file mode 100644 index 0000000..bdbed5f Binary files /dev/null and b/bin/Menu.class differ diff --git a/bin/Waiter.class b/bin/Waiter.class new file mode 100644 index 0000000..be7358a Binary files /dev/null and b/bin/Waiter.class differ diff --git a/bin/restaurant.class b/bin/restaurant.class new file mode 100644 index 0000000..7f4cf88 Binary files /dev/null and b/bin/restaurant.class differ diff --git a/bin/resturant_main$1.class b/bin/resturant_main$1.class new file mode 100644 index 0000000..ae2d73e Binary files /dev/null and b/bin/resturant_main$1.class differ diff --git a/bin/resturant_main$2.class b/bin/resturant_main$2.class new file mode 100644 index 0000000..818705a Binary files /dev/null and b/bin/resturant_main$2.class differ diff --git a/bin/resturant_main$3.class b/bin/resturant_main$3.class new file mode 100644 index 0000000..efcb957 Binary files /dev/null and b/bin/resturant_main$3.class differ diff --git a/bin/resturant_main$4.class b/bin/resturant_main$4.class new file mode 100644 index 0000000..63b9c42 Binary files /dev/null and b/bin/resturant_main$4.class differ diff --git a/bin/resturant_main$5.class b/bin/resturant_main$5.class new file mode 100644 index 0000000..56103ae Binary files /dev/null and b/bin/resturant_main$5.class differ diff --git a/bin/resturant_main$6.class b/bin/resturant_main$6.class new file mode 100644 index 0000000..7dfc8b3 Binary files /dev/null and b/bin/resturant_main$6.class differ diff --git a/bin/resturant_main$7.class b/bin/resturant_main$7.class new file mode 100644 index 0000000..cf935d5 Binary files /dev/null and b/bin/resturant_main$7.class differ diff --git a/bin/resturant_main.class b/bin/resturant_main.class new file mode 100644 index 0000000..c780fd9 Binary files /dev/null and b/bin/resturant_main.class differ diff --git a/hs_err_pid7220.log b/hs_err_pid7220.log new file mode 100644 index 0000000..c54e67a --- /dev/null +++ b/hs_err_pid7220.log @@ -0,0 +1,149 @@ +# +# There is insufficient memory for the Java Runtime Environment to continue. +# Native memory allocation (malloc) failed to allocate 1048576 bytes for E in C:\jdk7u2_64p\jdk7u15\hotspot\src\share\vm\utilities/taskqueue.hpp +# Possible reasons: +# The system is out of physical RAM or swap space +# In 32 bit mode, the process size limit was hit +# Possible solutions: +# Reduce memory load on the system +# Increase physical memory or swap space +# Check if swap backing store is full +# Use 64 bit Java on a 64 bit OS +# Decrease Java heap size (-Xmx/-Xms) +# Decrease number of Java threads +# Decrease Java thread stack sizes (-Xss) +# Set larger code cache with -XX:ReservedCodeCacheSize= +# This output file may be truncated or incomplete. +# +# Out of Memory Error (memory/allocation.inline.hpp:58), pid=7220, tid=14676 +# +# JRE version: 7.0_15-b03 +# Java VM: Java HotSpot(TM) 64-Bit Server VM (23.7-b01 mixed mode windows-amd64 compressed oops) +# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows +# + +--------------- T H R E A D --------------- + +Current thread (0x00000000022be000): JavaThread "Unknown thread" [_thread_in_vm, id=14676, stack(0x00000000020d0000,0x00000000021d0000)] + +Stack: [0x00000000020d0000,0x00000000021d0000] + +--------------- P R O C E S S --------------- + +Java Threads: ( => current thread ) + +Other Threads: + +=>0x00000000022be000 (exited) JavaThread "Unknown thread" [_thread_in_vm, id=14676, stack(0x00000000020d0000,0x00000000021d0000)] + +VM state:not at safepoint (normal execution) + +VM Mutex/Monitor currently owned by a thread: None + +Heap + PSYoungGen total 18560K, used 318K [0x00000000eb400000, 0x00000000ec8b0000, 0x0000000100000000) + eden space 15936K, 2% used [0x00000000eb400000,0x00000000eb44fb50,0x00000000ec390000) + from space 2624K, 0% used [0x00000000ec620000,0x00000000ec620000,0x00000000ec8b0000) + to space 2624K, 0% used [0x00000000ec390000,0x00000000ec390000,0x00000000ec620000) + ParOldGen total 42496K, used 0K [0x00000000c1c00000, 0x00000000c4580000, 0x00000000eb400000) + object space 42496K, 0% used [0x00000000c1c00000,0x00000000c1c00000,0x00000000c4580000) + PSPermGen total 21248K, used 686K [0x00000000bca00000, 0x00000000bdec0000, 0x00000000c1c00000) + object space 21248K, 3% used [0x00000000bca00000,0x00000000bcaab8b8,0x00000000bdec0000) + +Card table byte_map: [0x00000000053c0000,0x00000000055e0000] byte_map_base: 0x0000000004ddb000 + +Polling page: 0x0000000000960000 + +Code Cache [0x00000000023c0000, 0x0000000002630000, 0x00000000053c0000) + total_blobs=39 nmethods=0 adapters=20 free_code_cache=48889Kb largest_free_block=50062912 + +Compilation events (0 events): +No events + +GC Heap History (0 events): +No events + +Deoptimization events (0 events): +No events + +Internal exceptions (0 events): +No events + +Events (10 events): +Event: 0.017 loading class 0x00000000022d0b90 +Event: 0.017 loading class 0x00000000022d0b90 done +Event: 0.017 loading class 0x00000000022d06e0 +Event: 0.017 loading class 0x00000000022d06e0 done +Event: 0.017 loading class 0x00000000022d06b0 +Event: 0.017 loading class 0x00000000022d06b0 done +Event: 0.017 loading class 0x000000000230b180 +Event: 0.017 loading class 0x000000000230b180 done +Event: 0.017 loading class 0x000000000230a340 +Event: 0.018 loading class 0x000000000230a340 done + + +Dynamic libraries: +0x00007ff7dffe0000 - 0x00007ff7e0013000 C:\Program Files\Java\jre7\bin\javaw.exe +0x00007fff66a40000 - 0x00007fff66bec000 C:\Windows\SYSTEM32\ntdll.dll +0x00007fff66100000 - 0x00007fff6623a000 C:\Windows\system32\KERNEL32.DLL +0x00007fff63dd0000 - 0x00007fff63ee0000 C:\Windows\system32\KERNELBASE.dll +0x00007fff625a0000 - 0x00007fff6262e000 C:\Windows\system32\apphelp.dll +0x00007fff5f0c0000 - 0x00007fff5f113000 C:\Windows\AppPatch\AppPatch64\AcGenral.DLL +0x00007fff66470000 - 0x00007fff66517000 C:\Windows\system32\msvcrt.dll +0x00007fff63a80000 - 0x00007fff63aab000 C:\Windows\SYSTEM32\SspiCli.dll +0x00007fff663e0000 - 0x00007fff66431000 C:\Windows\system32\SHLWAPI.dll +0x00007fff65cb0000 - 0x00007fff65e21000 C:\Windows\system32\USER32.dll +0x00007fff65b10000 - 0x00007fff65ca4000 C:\Windows\system32\ole32.dll +0x00007fff643f0000 - 0x00007fff65908000 C:\Windows\system32\SHELL32.dll +0x00007fff632a0000 - 0x00007fff632bf000 C:\Windows\SYSTEM32\USERENV.dll +0x00007fff64340000 - 0x00007fff643e5000 C:\Windows\system32\ADVAPI32.dll +0x00007fff59fc0000 - 0x00007fff59fdb000 C:\Windows\SYSTEM32\MPR.dll +0x00007fff668e0000 - 0x00007fff66a21000 C:\Windows\system32\RPCRT4.dll +0x00007fff64160000 - 0x00007fff641b9000 C:\Windows\SYSTEM32\sechost.dll +0x00007fff66520000 - 0x00007fff666f6000 C:\Windows\SYSTEM32\combase.dll +0x00007fff65910000 - 0x00007fff65a60000 C:\Windows\system32\GDI32.dll +0x00007fff63c50000 - 0x00007fff63c64000 C:\Windows\SYSTEM32\profapi.dll +0x00007fff62500000 - 0x00007fff6259f000 C:\Windows\SYSTEM32\SHCORE.dll +0x00007fff65f90000 - 0x00007fff65fc4000 C:\Windows\system32\IMM32.DLL +0x00007fff641c0000 - 0x00007fff64312000 C:\Windows\system32\MSCTF.dll +0x00007fff61500000 - 0x00007fff6177a000 C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.9600.17810_none_6240b9c7ecbd0bda\COMCTL32.dll +0x0000000069370000 - 0x0000000069441000 C:\Program Files\Java\jre7\bin\msvcr100.dll +0x0000000068c50000 - 0x000000006936f000 C:\Program Files\Java\jre7\bin\server\jvm.dll +0x00007fff5cf10000 - 0x00007fff5cf19000 C:\Windows\SYSTEM32\WSOCK32.dll +0x00007fff61a70000 - 0x00007fff61a8f000 C:\Windows\SYSTEM32\WINMM.dll +0x00007fff64320000 - 0x00007fff64327000 C:\Windows\system32\PSAPI.DLL +0x00007fff660a0000 - 0x00007fff660f8000 C:\Windows\system32\WS2_32.dll +0x00007fff61460000 - 0x00007fff6148a000 C:\Windows\SYSTEM32\WINMMBASE.dll +0x00007fff66a30000 - 0x00007fff66a39000 C:\Windows\system32\NSI.dll +0x00007fff64110000 - 0x00007fff6415a000 C:\Windows\SYSTEM32\cfgmgr32.dll +0x00007fff62aa0000 - 0x00007fff62ac6000 C:\Windows\SYSTEM32\DEVOBJ.dll +0x0000000068c40000 - 0x0000000068c4f000 C:\Program Files\Java\jre7\bin\verify.dll +0x0000000068c10000 - 0x0000000068c38000 C:\Program Files\Java\jre7\bin\java.dll +0x0000000068bf0000 - 0x0000000068c05000 C:\Program Files\Java\jre7\bin\zip.dll + +VM Arguments: +jvm_args: -Dfile.encoding=Cp1256 +java_command: resturant_main +Launcher Type: SUN_STANDARD + +Environment Variables: +PATH=C:/Program Files/Java/jre1.8.0_66/bin/server;C:/Program Files/Java/jre1.8.0_66/bin;C:/Program Files/Java/jre1.8.0_66/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Perl64\site\bin;C:\Perl64\bin;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;D:\Dwimperl\perl\bin;D:\Dwimperl\perl\site\bin;D:\Dwimperl\c\bin;C:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\;C:\Program Files (x86)\Skype\Phone\;D:\Barname\eclipse-java-mars-R-win32-x86_64\eclipse; +USERNAME=EHSAN-PC +OS=Windows_NT +PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 69 Stepping 1, GenuineIntel + + + +--------------- S Y S T E M --------------- + +OS: Windows 8 , 64 bit Build 9200 + +CPU:total 4 (2 cores per cpu, 2 threads per core) family 6 model 69 stepping 1, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, avx, avx2, ht, tsc, tscinvbit + +Memory: 4k page, physical 4074564k(921516k free), swap 16657476k(5676k free) + +vm_info: Java HotSpot(TM) 64-Bit Server VM (23.7-b01) for windows-amd64 JRE (1.7.0_15-b03), built on Feb 15 2013 13:43:57 by "java_re" with unknown MS VC++:1600 + +time: Tue Jan 19 02:34:44 2016 +elapsed time: 0 seconds + diff --git a/src/Customer.class b/src/Customer.class new file mode 100644 index 0000000..8579558 Binary files /dev/null and b/src/Customer.class differ diff --git a/src/Customer.java b/src/Customer.java new file mode 100644 index 0000000..7ce68cf --- /dev/null +++ b/src/Customer.java @@ -0,0 +1,83 @@ + +public class Customer +{ + private int cost=0; + private int id; + private String nationality; + private String foodType; + private String menuType; + private int money; + private int vote; + private Menu menu; + public Customer(int id, String nationality, String foodType, String menuType, int money, int vote) + { + this.id=id; + this.nationality=nationality; + this.foodType=foodType; + this.menuType=menuType; + this.money=money; + this.vote=vote; + } + public void setVote(int vote) + { + this.vote=vote; + } + public void setMenu(Menu menu) + { + this.menu=menu; + } + public String getNationality() + { + return nationality; + } + public String getFoodType() + { + return foodType; + } + public String getMenuType() + { + return menuType; + } + public int getId() + { + return id; + } + public int getMoney() + { + return money; + } + public int getVote() + { + return vote; + } + public Menu getMenu() + { + return menu; + } + public boolean sad() + { + if(menu==null) + { + return true; + } + else + { + return false; + } + } + public int leaving() + { + setVote(vote); + money=money-cost; + return cost; + } + public void Cost(int cost) + { + this.cost=this.cost+cost; + } + public int getCost() + { + return cost; + } + +} diff --git a/src/Food.class b/src/Food.class new file mode 100644 index 0000000..9e8f7d0 Binary files /dev/null and b/src/Food.class differ diff --git a/src/Food.java b/src/Food.java new file mode 100644 index 0000000..20fb2ac --- /dev/null +++ b/src/Food.java @@ -0,0 +1,72 @@ + +public class Food +{ + private int cost; + private int number=10; + private int id; + private int quality; + private int internationalQuality; + private String nationality; + private String foodType; + public Food(int id, int quality, int internationalQuality, String nationality, String foodType, int cost) + { + this.id=id; + this.quality=quality; + this.internationalQuality=internationalQuality; + this.nationality=nationality; + this.foodType=foodType; + this.cost=cost; + } + public void setNumber(int number) + { + this.number=this.number-number; + } + public void setQuality(int quality) + { + this.quality=quality; + } + public void setInternatinalQuality(int internationalQuality) + { + this.internationalQuality=internationalQuality; + } + public String getNationality() + { + return nationality; + } + public int getId() + { + return id; + } + public int getQuality() + { + return quality; + } + public int getInternationalQuality() + { + return internationalQuality; + } + public int getNumber() + { + return number; + } + public String getFoodType() + { + return foodType; + } + public int getCost() + { + return cost; + } + public boolean isFinished() + { + if(number==0) + { + return true; + } + else + { + return false; + } + } + +} diff --git a/src/Menu.class b/src/Menu.class new file mode 100644 index 0000000..47e8a17 Binary files /dev/null and b/src/Menu.class differ diff --git a/src/Menu.java b/src/Menu.java new file mode 100644 index 0000000..c3d78f9 --- /dev/null +++ b/src/Menu.java @@ -0,0 +1,89 @@ + +public class Menu +{ + private Food[] restaurantFoods = new Food[20]; + private Food[] restaurantFoods1 = new Food[5]; + private Customer myCustomers; + public Menu(Food[] restaurantFoods,Customer myCustomers) + { + if(myCustomers.getMenuType().equals("China")) + { + if(myCustomers.getFoodType().equals("non-Vegetarian")) + { + System.arraycopy(restaurantFoods, 0, this.restaurantFoods, 0, 20); + } + else + { + System.arraycopy(restaurantFoods, 15, restaurantFoods1, 0, 5); + } + } + else if(myCustomers.getMenuType().equals("Italian")) + { + + if(myCustomers.getFoodType().equals("non-Vegetarian")) + { + System.arraycopy(restaurantFoods, 20, this.restaurantFoods, 0, 20); + } + else + { + System.arraycopy(restaurantFoods, 35, restaurantFoods1, 0, 5); + } + } + else if(myCustomers.getMenuType().equals("French")) + { + + if(myCustomers.getFoodType().equals("non-Vegetarian")) + { + System.arraycopy(restaurantFoods, 40, this.restaurantFoods, 0, 20); + } + else + { + System.arraycopy(restaurantFoods, 55, restaurantFoods1, 0, 5); + } + } + else if(myCustomers.getMenuType().equals("Indian")) + { + if(myCustomers.getFoodType().equals("non-Vegetarian")) + { + System.arraycopy(restaurantFoods, 60, this.restaurantFoods, 0, 20); + } + else + { + System.arraycopy(restaurantFoods, 75, restaurantFoods1, 0, 5); + } + } + else if(myCustomers.getMenuType().equals("Iranian")) + { + if(myCustomers.getFoodType().equals("non-Vegetarian")) + { + System.arraycopy(restaurantFoods, 80, this.restaurantFoods, 0, 20); + } + else + { + System.arraycopy(restaurantFoods, 95, restaurantFoods1, 0, 5); + } + } + + this.myCustomers=myCustomers; + } + public void setMyCustomer(Customer myCustomer) + { + this.myCustomers=myCustomer; + } + public Food[] getMenuFoods() + { + if(myCustomers.getFoodType().equals("non-Vegetarian")) + { + return restaurantFoods; + } + else + { + return restaurantFoods1; + } + + } + public Customer getMyCustomer() + { + return myCustomers; + } +} diff --git a/src/Waiter.class b/src/Waiter.class new file mode 100644 index 0000000..a38b5f7 Binary files /dev/null and b/src/Waiter.class differ diff --git a/src/Waiter.java b/src/Waiter.java new file mode 100644 index 0000000..2f49ee4 --- /dev/null +++ b/src/Waiter.java @@ -0,0 +1,56 @@ + +public class Waiter +{ + private int id; + private int counter=0; + private int salary=0; + private int customers=0; + private String nationality; + public Waiter(int id, String nationality) + { + this.id=id; + this.nationality=nationality; + } + public void incrementCustomers() + { + customers++; + } + public void setSalary(int salary) + { + + if(salary==3) + { + this.salary=this.salary+salary; + } + else + { + this.salary=this.salary+salary; + counter++; + } + + } + public int getId() + { + return id; + } + public void setCounter(int counter) + { + this.counter=counter; + } + public int getCounter() + { + return counter; + } + public String getNationality() + { + return nationality; + } + public int getSalary() + { + return salary; + } + public int getCustomers() + { + return customers; + } +} diff --git a/src/restaurant.class b/src/restaurant.class new file mode 100644 index 0000000..a0befb7 Binary files /dev/null and b/src/restaurant.class differ diff --git a/src/restaurant.java b/src/restaurant.java new file mode 100644 index 0000000..ee1d3f9 --- /dev/null +++ b/src/restaurant.java @@ -0,0 +1,103 @@ +import java.util.ArrayList; + +public class restaurant +{ + private int id=-1,j=0; + private String name; + private int capacity; + private int fund=10000; + private Food[] foods = new Food[100]; + private Customer[] customers; + private ArrayList waiters = new ArrayList(); + public restaurant(String name, int capacity) + { + this.name=name; + this.capacity=capacity; + customers = new Customer[capacity]; + cooking("China"); + cooking("Italian"); + cooking("French"); + cooking("Indian"); + cooking("Iranian"); + } + public restaurant(String name) + { + this.name=name; + capacity=50; + } + public void setCapacity(int capacity) + { + this.capacity=capacity; + } + public void cooking(String nationality) + { + for(int i=j;i<=j+19;i++) + { + if(j+0<=i && i getWaiters() + { + return waiters; + } + public int getId() + { + return id; + } +} diff --git a/src/resturant_main$1.class b/src/resturant_main$1.class new file mode 100644 index 0000000..b96c37a Binary files /dev/null and b/src/resturant_main$1.class differ diff --git a/src/resturant_main$2.class b/src/resturant_main$2.class new file mode 100644 index 0000000..649c086 Binary files /dev/null and b/src/resturant_main$2.class differ diff --git a/src/resturant_main$3.class b/src/resturant_main$3.class new file mode 100644 index 0000000..2fa14df Binary files /dev/null and b/src/resturant_main$3.class differ diff --git a/src/resturant_main$4.class b/src/resturant_main$4.class new file mode 100644 index 0000000..ba80762 Binary files /dev/null and b/src/resturant_main$4.class differ diff --git a/src/resturant_main$5.class b/src/resturant_main$5.class new file mode 100644 index 0000000..014cc3e Binary files /dev/null and b/src/resturant_main$5.class differ diff --git a/src/resturant_main$6.class b/src/resturant_main$6.class new file mode 100644 index 0000000..a188044 Binary files /dev/null and b/src/resturant_main$6.class differ diff --git a/src/resturant_main$7.class b/src/resturant_main$7.class new file mode 100644 index 0000000..829ecbb Binary files /dev/null and b/src/resturant_main$7.class differ diff --git a/src/resturant_main.class b/src/resturant_main.class new file mode 100644 index 0000000..f57bd69 Binary files /dev/null and b/src/resturant_main.class differ diff --git a/src/resturant_main.java b/src/resturant_main.java new file mode 100644 index 0000000..0e2fbd5 --- /dev/null +++ b/src/resturant_main.java @@ -0,0 +1,549 @@ +import javax.swing.*; +import javax.swing.event.AncestorEvent; +import javax.swing.event.AncestorListener; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.plaf.basic.BasicListUI.ListSelectionHandler; +import javax.swing.text.NavigationFilter; + +import java.awt.*; +import java.awt.event.*; +import java.beans.PropertyChangeListener; +import java.io.Writer; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.Vector; + +public class resturant_main extends JFrame{ + + static JFrame frame = new JFrame(); + static JPanel panel1 = new JPanel(); + static JPanel panel2 = new JPanel(); + static JPanel panel3 = new JPanel(); + static JPanel panel4 = new JPanel(); + static JPanel panel5 = new JPanel(); + //static JPanel panel6 = new JPanel(); + static Vector nationality =new Vector(); + static Vector foodtype =new Vector(); + static Vector menutype =new Vector(); + static Vector waiterslist = new Vector(); + static Vector customerslist = new Vector(); + static restaurant Restaurant; + static String str; + static int price; + public static void main(String[] args) + { + /*Restaurant=new restaurant("amin", 500); + Restaurant.CustomerEntry("English", "veg", "ch", 1000, 2); + Restaurant.WaiterEntry(4, "English"); + System.out.println(Restaurant.getWaiters().get(0).getNationality()); + System.out.println(Restaurant.getCustomers()[0].getNationality());*/ + /////////////////////////////////// + nationality.add("China"); + nationality.add("Italian"); + nationality.add("French"); + nationality.add("Indian"); + nationality.add("Iranian"); + nationality.add("English"); + nationality.add("Other"); + /////////////////////////////////// + foodtype.add("Vegetarian"); + foodtype.add("non-Vegetarian"); + /////////////////////////////////// + menutype.add("China"); + menutype.add("Italian"); + menutype.add("French"); + menutype.add("Indian"); + menutype.add("Iranian"); + menutype.add("English"); + ////////////restaurant//////////// + JLabel restaurantlabel = new JLabel("Restaurant"); + restaurantlabel.setBounds(80, 0, 100, 30); + restaurantlabel.setFont(new Font("Dialog",Font.BOLD+Font.ITALIC, 18)); + + JLabel restaurantnamelabel = new JLabel("Name"); + restaurantnamelabel.setBounds(10, 50, 60, 30); + + JLabel restaurantcapacitylabel = new JLabel("Capacity"); + restaurantcapacitylabel.setBounds(10, 90, 60, 30); + + final JTextField restaurantnametextfeild = new JTextField(); + restaurantnametextfeild.setBounds(75, 50, 105, 30); + + final JTextField restaurantcapacitytextfeild = new JTextField(); + restaurantcapacitytextfeild.setBounds(75, 90, 105, 30); + + JLabel restaurantfundlabel = new JLabel("Fund"); + restaurantfundlabel.setBounds(10, 130, 60, 30); + + final JTextField restauranttextfeild = new JTextField(); + restauranttextfeild.setBounds(75, 130, 105, 30); + restauranttextfeild.setEditable(false); + restauranttextfeild.setFont(new Font("Dialog",Font.BOLD, 15)); + + final JButton restaurantcreatbutton = new JButton("Creat"); + restaurantcreatbutton.setBounds(195, 130, 70, 30); + //restaurantcreatbutton.setFont(new Font("Dialog",Font.CENTER_BASELINE,14)); + ////////////////////////////////// + ////////////waiter//////////// + JLabel waiterlabel = new JLabel("Waiter"); + waiterlabel.setBounds(100, 170, 100, 30); + waiterlabel.setFont(new Font("Dialog",Font.BOLD+Font.ITALIC, 18)); + + JLabel waiteridlabel = new JLabel("ID"); + waiteridlabel.setBounds(10, 210, 60, 30); + + JLabel waiternationalitylabel = new JLabel("Nationality"); + waiternationalitylabel.setBounds(10, 250, 60, 30); + + final JTextField waiteridtextfeild = new JTextField(); + waiteridtextfeild.setBounds(75, 210, 105, 30); + + final JComboBox waiternationalitycombobox = new JComboBox<>(nationality); + waiternationalitycombobox.setBounds(75, 250, 105, 30); + + JButton waiteraddbutton = new JButton("Add"); + waiteraddbutton.setBounds(195, 250, 70, 30); + ////////////////////////////////// + ////////////customer////////////// + JLabel customerlabel = new JLabel("Customer"); + customerlabel.setBounds(100, 0, 100, 30); + customerlabel.setFont(new Font("Dialog",Font.BOLD+Font.ITALIC, 18)); + + JLabel customernationalitylabel = new JLabel("Nationality"); + customernationalitylabel.setBounds(10, 60, 60, 30); + + JLabel customerfoodTypelabel = new JLabel("FoodType"); + customerfoodTypelabel.setBounds(10, 100, 60, 30); + + JLabel customermenuTypelabel = new JLabel("MenuType"); + customermenuTypelabel.setBounds(10, 140, 60, 30); + + JLabel customermoneylabel = new JLabel("Money"); + customermoneylabel.setBounds(10, 180, 60, 30); + + JLabel customervotelabel = new JLabel("Vote(1-10)"); + customervotelabel.setBounds(10, 220, 60, 30); + + final JComboBox customernationalitycombobox = new JComboBox<>(nationality); + customernationalitycombobox.setBounds(80, 60, 150, 30); + + final JComboBox customerfoodTypecombobox = new JComboBox<>(foodtype); + customerfoodTypecombobox.setBounds(80, 100, 150, 30); + + final JComboBox customermenuTypecombobox = new JComboBox<>(menutype); + customermenuTypecombobox.setBounds(80, 140, 150, 30); + + final JTextField customermoneytextfeild = new JTextField(); + customermoneytextfeild.setBounds(80, 180, 150, 30); + + final JTextField customervotetextfeild = new JTextField(); + customervotetextfeild.setBounds(80, 220, 150, 30); + + JButton customeraddbutton = new JButton("Add"); + customeraddbutton.setBounds(250, 230, 70, 50); + ////////////////////////////////// + ///////////Waiters List/////////// + JLabel waiterlistlabel = new JLabel("Waiters List:"); + waiterlistlabel.setBounds(10, 0, 150, 30); + waiterlistlabel.setFont(new Font("Dialog",Font.BOLD+Font.ITALIC, 18)); + + final JList waiterslistscrollpane = new JList(); + waiterslistscrollpane.setSelectedIndex(ListSelectionModel.SINGLE_SELECTION); + JScrollPane waitersscrollpane = new JScrollPane(waiterslistscrollpane); + waitersscrollpane.setBounds(10, 30, 150, 150); + /////////Customers List////////// + JLabel customerlistlabel = new JLabel("Customers List:"); + customerlistlabel.setBounds(200, 0, 150, 30); + customerlistlabel.setFont(new Font("Dialog",Font.BOLD+Font.ITALIC, 18)); + + final JList customerslistscrollpane = new JList(); + customerslistscrollpane.setSelectedIndex(ListSelectionModel.SINGLE_SELECTION); + JScrollPane customersscrollpane = new JScrollPane(customerslistscrollpane); + customersscrollpane.setBounds(200, 30, 350, 250); + + + /*JButton customerselectbutton = new JButton("Select"); + customerselectbutton.setBounds(460, 150, 80, 30);*/ + ////////////////////////////////// + ///////////////Menu/////////////// + JLabel menulistlabel = new JLabel("Menu :"); + menulistlabel.setBounds(10, 0, 150, 30); + menulistlabel.setFont(new Font("Dialog",Font.BOLD+Font.ITALIC, 18)); + + final JList menulistscrollpane = new JList(); + menulistscrollpane.setSelectedIndex(ListSelectionModel.SINGLE_SELECTION); + JScrollPane menuscrollpane = new JScrollPane(menulistscrollpane); + menuscrollpane.setBounds(10, 30, 270, 250); + ////////////////////////////////// + JLabel pricelabel = new JLabel("Price "); + pricelabel.setBounds(10, 210, 80, 30); + + final JTextField pricetextfeild = new JTextField(); + pricetextfeild.setBounds(50, 210, 90, 30); + + JButton eatbutton = new JButton("Eat"); + eatbutton.setBounds(50, 250, 90, 30); + ////////////////////////////////// + ////////////////////////////////// + JLabel salarywaiterlabel = new JLabel("Salary Waiter $"); + salarywaiterlabel.setBounds(10, 10, 150, 30); + + final JTextField salarywaitertextfeild = new JTextField(); + salarywaitertextfeild.setBounds(110, 10, 150, 30); + + JButton salarywaiterbutton = new JButton("Salary Waiter"); + salarywaiterbutton.setBounds(110, 50, 150, 50); + ////////////////////////////////// + ////////////////////////////////// + + JButton payoffbutton = new JButton("Pay off"); + payoffbutton.setBounds(80, 170, 150, 70); + payoffbutton.setFont(new Font("Dialog",Font.BOLD+Font.ITALIC, 18)); + ////////////////////////////////// + //////////////panel1////////////// + panel1.setBackground(Color.BLUE); + panel1.setBounds(0, 0, 270, 300); + panel1.setLayout(null); + panel1.add(restaurantlabel); + panel1.add(restaurantnamelabel); + panel1.add(restaurantcapacitylabel); + panel1.add(restaurantfundlabel); + panel1.add(restaurantnametextfeild); + panel1.add(restaurantcapacitytextfeild); + panel1.add(restaurantcreatbutton); + panel1.add(restauranttextfeild); + panel1.add(waiterlabel); + panel1.add(waiteridlabel); + panel1.add(waiternationalitylabel); + panel1.add(waiteridtextfeild); + panel1.add(waiternationalitycombobox); + panel1.add(waiteraddbutton); + //////////////panel2////////////// + panel2.setBackground(Color.orange); + panel2.setBounds(270, 0, 330, 300); + panel2.setLayout(null); + panel2.add(customerlabel); + panel2.add(customernationalitylabel); + panel2.add(customerfoodTypelabel); + panel2.add(customermenuTypelabel); + panel2.add(customermoneylabel); + panel2.add(customervotelabel); + panel2.add(customernationalitycombobox); + panel2.add(customerfoodTypecombobox); + panel2.add(customermenuTypecombobox); + panel2.add(customermoneytextfeild); + panel2.add(customervotetextfeild); + panel2.add(customeraddbutton); + //////////////panel3////////////// + panel3.setBackground(Color.red); + panel3.setBounds(600, 0, 300, 300); + panel3.setLayout(null); + panel3.add(menulistlabel); + panel3.add(menuscrollpane); + panel3.add(menulistlabel); + panel3.add(menuscrollpane); + //////////////panel4////////////// + panel4.setBackground(Color.green); + panel4.setBounds(0, 300, 600, 300); + panel4.setLayout(null); + panel4.add(waiterlistlabel); + panel4.add(waitersscrollpane); + panel4.add(customerlistlabel); + panel4.add(customersscrollpane); + //panel4.add(customerselectbutton); + panel4.add(eatbutton); + panel4.add(pricelabel); + panel4.add(pricetextfeild); + //////////////panel5////////////// + panel5.setBackground(Color.PINK); + panel5.setBounds(600, 300, 300, 300); + panel5.setLayout(null); + panel5.add(salarywaiterbutton); + panel5.add(salarywaitertextfeild); + panel5.add(salarywaiterlabel); + panel5.add(payoffbutton); + //////////////panel6////////////// +/* panel6.setBackground(Color.orange); + panel6.setBounds(600, 300, 300, 300); + panel6.setLayout(null);*/ + ////////////////////////////////// + + + + //////////////frame/////////////// + frame.setTitle("Restaurant"); + frame.setBounds(250, 30, 916, 639); + frame.setLayout(null); + + frame.add(panel1); + frame.add(panel2); + frame.add(panel3); + frame.add(panel4); + frame.add(panel5); + //frame.add(panel6); + frame.setVisible(true); + ////////////////////////////////// + ////////////////////////////////////////Restaurant///////////////////////////////////////////////// + restaurantcreatbutton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) + { + try + { + Restaurant = new restaurant(restaurantnametextfeild.getText(), + Integer.parseInt(restaurantcapacitytextfeild.getText())); + restauranttextfeild.setText(""+Restaurant.getFund()); + JOptionPane.showMessageDialog(null,"Restaurant created", "Wellcome",JOptionPane.INFORMATION_MESSAGE); + restaurantcreatbutton.setEnabled(false); + restaurantcapacitytextfeild.setEnabled(false); + restaurantnametextfeild.setEnabled(false); + } + catch(Exception e) + { + JOptionPane.showMessageDialog(null,"Please enter correct input", "ERROR",JOptionPane.ERROR_MESSAGE); + } + } + }); + /////////////////////////////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////Waiters///////////////////////////////////////////////////// + waiteraddbutton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) + { + try + { + if(Integer.parseInt(waiteridtextfeild.getText())>0) + { + if(!searchid(Restaurant.getWaiters(), Integer.parseInt(waiteridtextfeild.getText()))) + { + Restaurant.WaiterEntry(Integer.parseInt(waiteridtextfeild.getText()), + waiternationalitycombobox.getSelectedItem().toString()); + waiterslist.add("ID:"+waiteridtextfeild.getText()+ + " Nationality:"+waiternationalitycombobox.getSelectedItem().toString()); + //JOptionPane.showMessageDialog(null, "Waiter Added", "ADD",JOptionPane.INFORMATION_MESSAGE); + waiterslistscrollpane.setListData(waiterslist); + } + else + { + JOptionPane.showMessageDialog(null,"This ID exist", "ERROR",JOptionPane.ERROR_MESSAGE); + } + } + else + { + JOptionPane.showMessageDialog(null,"Please enter correct input", "ERROR",JOptionPane.ERROR_MESSAGE); + } + } + catch(Exception e) + { + if(Restaurant==null) + { + JOptionPane.showMessageDialog(null,"Restaurant not created", "ERROR",JOptionPane.ERROR_MESSAGE); + } + else + { + JOptionPane.showMessageDialog(null,"Please enter correct input", "ERROR",JOptionPane.ERROR_MESSAGE); + } + } + } + }); + + /////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////Customers//////////////////////////////////////////////// + customeraddbutton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) + { + try + { + if(Integer.parseInt(customermoneytextfeild.getText())>0 + && 1<=Integer.parseInt(customervotetextfeild.getText()) + && Integer.parseInt(customervotetextfeild.getText())<=10) + { + Restaurant.getWaiters().get(waiterslistscrollpane.getSelectedIndex()).setSalary(3); + Restaurant.CustomerEntry(customernationalitycombobox.getSelectedItem().toString() + , customerfoodTypecombobox.getSelectedItem().toString() + , customermenuTypecombobox.getSelectedItem().toString() + , Integer.parseInt(customermoneytextfeild.getText()) + , Integer.parseInt(customervotetextfeild.getText())); + customerslist.add("Nationality: "+customernationalitycombobox.getSelectedItem().toString() + + " FoodType: "+customerfoodTypecombobox.getSelectedItem().toString() + + " MenuType: "+customermenuTypecombobox.getSelectedItem().toString() + + " Money: "+customermoneytextfeild.getText() + + " Vote: "+customervotetextfeild.getText()); + + customerslistscrollpane.setListData(customerslist); + + } + else + { + JOptionPane.showMessageDialog(null,"Please enter correct input", "ERROR",JOptionPane.ERROR_MESSAGE); + } + + } + catch(Exception e) + { + if(Restaurant==null) + { + JOptionPane.showMessageDialog(null,"Restaurant not created", "ERROR",JOptionPane.ERROR_MESSAGE); + } + else + { + JOptionPane.showMessageDialog(null,"Please enter correct input", "ERROR",JOptionPane.ERROR_MESSAGE); + } + } + + } + }); + customerslistscrollpane.addListSelectionListener(new ListSelectionListener() { + + @Override + public void valueChanged(ListSelectionEvent arg0) { + try + { + menulistscrollpane.setListData(menu(customerslistscrollpane.getSelectedIndex())); + } + catch (Exception e) + { + } + } + }); + +/* customerselectbutton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) + { + try + { + menulistscrollpane.setListData(menu(customerslistscrollpane.getSelectedIndex())); + } + catch (Exception e) + { + JOptionPane.showMessageDialog(null,"ERROR", "ERROR",JOptionPane.ERROR_MESSAGE); + } + + } + });*/ + /////////////////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////eat//////////////////////////////////////////////////// + eatbutton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) + { + try + { + int i=Integer.parseInt(menulistscrollpane.getSelectedValue().substring(0, menulistscrollpane.getSelectedValue().indexOf(")")))-1; + if(!Restaurant.getFoods()[i].isFinished()) + { + //pricetextfeild.setText(""+Restaurant.getFoods()[i].getCost()); + if((Restaurant.getFoods()[i].getCost() + +Restaurant.getCustomers()[customerslistscrollpane.getSelectedIndex()].getCost()) + <=Restaurant.getCustomers()[customerslistscrollpane.getSelectedIndex()].getMoney()) + { + if(Restaurant.getWaiters().get(waiterslistscrollpane.getSelectedIndex()).getCounter()==9) + { + Restaurant.getWaiters().get(waiterslistscrollpane.getSelectedIndex()).setSalary(10); + Restaurant.getWaiters().get(waiterslistscrollpane.getSelectedIndex()).setCounter(0); + Restaurant.setFund(-10); + restauranttextfeild.setText(""+Restaurant.getFund()); + } + else + { + Restaurant.getWaiters().get(waiterslistscrollpane.getSelectedIndex()).setSalary(0); + } + + Restaurant.getCustomers()[customerslistscrollpane.getSelectedIndex()].Cost(Restaurant.getFoods()[i].getCost()); + Restaurant.getFoods()[i].setNumber(1); + pricetextfeild.setText(""+Restaurant.getCustomers()[customerslistscrollpane.getSelectedIndex()].getCost()); + menulistscrollpane.setListData(menu(customerslistscrollpane.getSelectedIndex())); + } + else + { + JOptionPane.showMessageDialog(null,"Your money is low", "ERROR",JOptionPane.ERROR_MESSAGE); + } + } + } + catch (Exception e) + { + JOptionPane.showMessageDialog(null,"ERROR", "ERROR",JOptionPane.ERROR_MESSAGE); + } + } + }); + /////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////SalaryWAiter///////////////////////////////////////////////// + salarywaiterbutton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) + { + salarywaitertextfeild.setText(""+Restaurant.getWaiters().get(waiterslistscrollpane.getSelectedIndex()).getSalary()); + + } + }); + /////////////////////////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////pay off/////////////////////////////////////////////////// + payoffbutton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) + { + try{ + Restaurant.settlement(Restaurant.getCustomers()[customerslistscrollpane.getSelectedIndex()]); + restauranttextfeild.setText(""+Restaurant.getFund()); + customerslist.remove(customerslistscrollpane.getSelectedIndex()); + customerslist.add(customerslistscrollpane.getSelectedIndex(),"Nationality: "+Restaurant.getCustomers()[customerslistscrollpane.getSelectedIndex()].getNationality() + + " FoodType: "+Restaurant.getCustomers()[customerslistscrollpane.getSelectedIndex()].getFoodType() + + " MenuType: "+Restaurant.getCustomers()[customerslistscrollpane.getSelectedIndex()].getMenuType() + + " Money: "+Restaurant.getCustomers()[customerslistscrollpane.getSelectedIndex()].getMoney() + + " Vote: "+Restaurant.getCustomers()[customerslistscrollpane.getSelectedIndex()].getVote()); + + customerslistscrollpane.setListData(customerslist); + } + catch (Exception e) + { + JOptionPane.showMessageDialog(null,"ERROR", "ERROR",JOptionPane.ERROR_MESSAGE); + } + } + }); + /////////////////////////////////////////////////////////////////////////////////////////////////// + + } + public static String[] menu(int index) + { + String[] foods = new String[20]; + for(int i=0;i<=(Restaurant.getCustomers()[index].getMenu().getMenuFoods().length)-1;i++) + { + foods[i]=Restaurant.getCustomers()[index].getMenu().getMenuFoods()[i].getId()+1+") " + +Restaurant.getCustomers()[index].getMenu().getMenuFoods()[i].getNationality() + +" FoodType :"+Restaurant.getCustomers()[index].getMenu().getMenuFoods()[i].getFoodType() + +" Quality :"+Restaurant.getCustomers()[index].getMenu().getMenuFoods()[i].getQuality() + +" IQuality :"+Restaurant.getCustomers()[index].getMenu().getMenuFoods()[i].getInternationalQuality() + +" Number :"+Restaurant.getCustomers()[index].getMenu().getMenuFoods()[i].getNumber() + +" COst :"+Restaurant.getCustomers()[index].getMenu().getMenuFoods()[i].getCost(); + + } + + return foods; + } + public static boolean searchid(ArrayList waiters,int id) + { + boolean flag=false; + for (Waiter waiter : waiters) + { + if(waiter.getId()==id) + { + flag=true; + break; + } + } + + return flag; + } + + +}