-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenuClass.js
More file actions
76 lines (63 loc) · 1.85 KB
/
MenuClass.js
File metadata and controls
76 lines (63 loc) · 1.85 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
class Order {
constructor(name,position){
this.name=[];
this.position=position;
}
describe(){
return `The order are ${this.name}`
}
viewOrder (){
let orderItems ='';
for (let i=0; i<this.name.length; i++) {
orderItems +=i + ')' + this.name[i] + '\n';
}
alert (orderItems);
}
createOrder (){
let position = prompt("How Many item do you need to add to your order")
for (let i=0;i<position;i++){
let names= prompt("Enter order")
this.name.push(names)
}
}
deleteOrder (){
let x = prompt("which item number you need to remove")
this.name.splice(x,1)
}
}
class Menu extends Order {
constructor(name,position){
super(name,position)
}
start() {
let selection = this.showMainMenuOptions();
while (selection !=0){
switch (selection){
case '1':
this.createOrder();
break;
case '2':
this.viewOrder();
break;
case '3':
this.deleteOrder();
break;
default :
selection=0;
}
selection = this.showMainMenuOptions();
}
alert ('GoodBye ')
}
showMainMenuOptions()
{
return prompt(`
0) exit
1) create new Order
2) view Order
3) delete item on order
`);
}
}
let menu= new Menu()
menu.start();