-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu.java
More file actions
113 lines (88 loc) · 2.55 KB
/
Copy pathmenu.java
File metadata and controls
113 lines (88 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package amrita;
import java.util.Scanner;
import java.util.Vector;
public class menu
{
Scanner inp=new Scanner(System.in);
private static Vector<food> foodList;
private static int menuCount;
public void addFood()
{
System.out.println("Enter the name of food Item :");
String tempName=inp.nextLine();
System.out.println("Enter the type of food :");
String tempType=inp.nextLine();
System.out.println("Enter the cost per serve :");
double tempCost=inp.nextDouble();
System.out.println("Enter the category of the food :");
String tempCategory=inp.nextLine();
System.out.println("Enter the number of days it will be served :");
int n=inp.nextInt();
while(!(n>=1 && n<=7))
{
System.out.println("The no of days can only be a positive number from 1 to 7 please check your input!!!:");
n=inp.nextInt();
}
if(n>=1 && n<=7)
{
int[] day=new int[7];
for(int i=0;i<n;i++)
{
System.out.println("Enter the corresponding to the week day it will be served :");
day[i]=inp.nextInt();
}
food foodItem=new food(tempName,tempCategory,day,tempType,tempCost);
foodList.addElement(foodItem);
++menuCount;
}
}
public void displayCount()
{
System.out.println("There are "+menuCount+" food Items present in the menu :");
}
public void displayMenu()
{
for(int i=0;i<menuCount;i++)
{
System.out.println((i+1)+") "+foodList.elementAt(i));
}
}
public void displayFoodItem(String name)
{
for(int i=0;i<menuCount;i++)
{
if(foodList.elementAt(i).getName().compareTo(name)==0)
{
System.out.println("Details of the food Item :");
System.out.println("Name : "+foodList.elementAt(i).getName());
System.out.println("Category : "+foodList.elementAt(i).getCategory());
System.out.println("Day : "+foodList.elementAt(i).getDay());
System.out.println("Type : "+foodList.elementAt(i).getType());
System.out.println("Cost per serve : "+foodList.elementAt(i).getCostPerServe());
}
}
}
public static int search(String foodItem)
{int flag=-1;
for(int i=0;i<menuCount;i++)
{
if(foodList.elementAt(i).getName().compareTo(foodItem)==0)
{
flag=i;
}
}
return flag;
}
public static Vector<food> getFoodList() {
return foodList;
}
public static void setFoodList(Vector<food> foodList) {
menu.foodList = foodList;
}
public static int getMenuCount() {
return menuCount;
}
public static void setMenuCount(int menuCount) {
menu.menuCount = menuCount;
}
}