-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathApp.java
More file actions
94 lines (75 loc) · 3.32 KB
/
Copy pathApp.java
File metadata and controls
94 lines (75 loc) · 3.32 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
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import controller.MovieController;
import model.Movie;
import repository.MovieRepository;
public class App {
public static void main(String[] args) throws Exception {
MovieRepository movieRepository = new MovieRepository();
MovieController movieController = new MovieController();
Scanner sc = new Scanner(System.in);
movieRepository.getData();
List<Movie> listMovies = movieRepository.listMovies;
System.out.println("\n-------------------------------------------------------------\n");
while(true){
menu();
int choose = sc.nextInt();
sc.nextLine();
switch (choose) {
case 1:
// Sắp xếp phim dựa theo tên
System.out.println("DANH SÁCH SAU KHI SẮP XẾP: ");
Collections.sort(listMovies, new Comparator<Movie>() {
@Override
public int compare(Movie o1, Movie o2) {
return o1.getTitle().compareTo(o2.getTitle());
}
});
printList(listMovies);
break;
case 2:
System.out.println("Nhập tên phim bạn muốn tìm kiếm: ");
String name = sc.nextLine();
System.out.println("DANH SACH PHIM CÓ TÊN LÀ " + name + " : ");
movieController.searchMovieByName(listMovies, name);
break;
case 3:
System.out.println("Nhập tên phim bạn muốn tìm kiếm: ");
String genres = sc.nextLine();
System.out.println("DANH SACH PHIM CÓ THỂ LOẠI LÀ " + genres + " : ");
movieController.searchMovieByCategory(listMovies, genres);
break;
case 4:
System.out.println("Nhập tên phim bạn muốn tìm kiếm: ");
String language = sc.nextLine();
System.out.println("DANH SACH PHIM CÓ NGÔN NGỮ LÀ " + language + " : ");
movieController.searchMovieByLanguage(listMovies, language);
break;
case 5:
movieController.countMovieByCategory(listMovies);
break;
case 0:
System.exit(1);
break;
default:
break;
}
}
}
public static void printList(List<Movie> list) {
for (Movie movie : list) {
System.out.println(movie);
}
}
public static void menu() {
System.out.println("Lựa chọn: ");
System.out.println("1 : Sắp xếp các phim dựa theo tên");
System.out.println("2 : Tìm kiếm phim theo tên");
System.out.println("3 : Tìm kiếm phim theo thể loại");
System.out.println("4 : Tìm kiếm phim theo ngôn ngữ");
System.out.println("5 : Liệt kê thể loại phim và số phim dựa theo thể loại");
System.out.println("6 : Thoát chương trình");
}
}