-
Notifications
You must be signed in to change notification settings - Fork 0
/
Test.java
141 lines (125 loc) · 5.13 KB
/
Test.java
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package Assignment;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Book[] list = new Book[20];
int n = 0;
int choose = 0;
do {
menu();
System.out.print("Your choice: ");
choose = sc.nextInt();
switch (choose) {
case 1: {
MenuBooks t = new MenuBooks();
t.menuBook();
int CHOOSE = 0;
System.out.println("");
System.out.print("Your choice: ");
CHOOSE=sc.nextInt();
switch (CHOOSE) {
case 1:
int input = -1;
do {
t.insert(list, n);
n += 1;
System.out.println("Do you want to continue?");
System.out.println("1. Yes");
System.out.println("2. No");
input = sc.nextInt();
} while (input != 2);
t.menuBook();
break;
case 2:
int id;
System.out.print("Location you want to update: ");
id = sc.nextInt();
if (t.find2(list, n, id)) {
t.update(list, n, id);
} else {
System.out.println("Can't find book with ID " + id);
}
break;
case 3:
int ID;
System.out.print("Location you want to delete: ");
ID = sc.nextInt();
if (t.find2(list, n, ID)) {
t.delete(list, n, ID);
n -= 1;
} else {
System.out.println("Can't find book with ID " + ID);
}
break;
case 4:
t.display(list, n);
break;
case 5:
System.exit(0);
break;
default:
System.out.println("Sorry. Your choice does not exist.");
break;
}
}
while (choose != 5);
case 2: {
menuTool t1 = new menuTool();
t1.menuTool();
int choose1 = 0;
do {
System.out.println("Choose the function of the tool:");
choose1 = sc.nextInt();
switch (choose1) {
case 1: {
System.out.println("Enter author need to filt: ");
String name = sc.nextLine();
t1.findAu(list, n, name);
break;
}
case 2: {
System.out.println("Enter Language need to filt: ");
String lan = sc.nextLine();
t1.findLan(list, n, lan);
break;
}
case 3: {
System.out.println("Enter price need to filt: ");
Double pri = sc.nextDouble();
t1.findPri(list, n, pri);
break;
}
case 4: {
System.out.println("Sort by price: ");
t1.sort(list, n);
break;
}
case 5: {
menu();
break;
}
default:
System.out.println("Sorry. Your choice does not exist.");
break;
}
} while (choose1 != 5);
}
case 3:
System.exit(0);
break;
default:
System.out.println("Sorry. Your choice does not exist.");
}
System.out.println("Do you want to continue?");
menu();
choose = sc.nextInt();
} while (choose != 3);
}
public static void menu() {
System.out.println("==========Menu=========");
System.out.println("1. Books");
System.out.println("2. Tools");
System.out.println("3. Exit");
}
}