forked from cuongquangnam/CZ2002-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MovieListingController.java
115 lines (87 loc) · 2.47 KB
/
MovieListingController.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
package com.controllers;
import com.models.*;
import java.util.ArrayList;
import java.util.Scanner;
public class MovieListingController {
static ArrayList <Movie> movieList = new ArrayList <Movie>();
static Scanner sc = new Scanner(System.in);
public static Movie search(ArrayList<Movie> movieList, String movieTitle)
{
for(Movie m : movieList)
{
if(m.getMovieTitle().equalsIgnoreCase(movieTitle))
return m;
}
return null;
}
public static void addMovie(Movie m)
{
movieList.add(m);
System.out.println(movieList);
}
public static void updateMovieTitle(String omovieTitle,String nmovieTitle)
{
Movie m = search(movieList, omovieTitle);
movieList.remove(m);
m.setMovieTitle(nmovieTitle);
movieList.add(m);
System.out.println(movieList);
}
public static void updateShowingStatus(String omovieTitle, int nshowingStatus)
{
Movie m = search(movieList, omovieTitle);
movieList.remove(m);
m.setShowingStatus(nshowingStatus);
movieList.add(m);
System.out.println(movieList);
}
public static void updateSypnosis(String omovieTitle, String nsypnosis)
{
Movie m = search(movieList, omovieTitle);
movieList.remove(m);
m.setSypnosis(nsypnosis);
movieList.add(m);
System.out.println(movieList);
}
public static void updateDirector(String omovieTitle, String ndirector)
{
Movie m = search(movieList, omovieTitle);
movieList.remove(m);
m.setDirector(ndirector);
movieList.add(m);
System.out.println(movieList);
}
public static void updateCast(String omovieTitle, ArrayList <String> ncast)
{
Movie m = search(movieList, omovieTitle);
movieList.remove(m);
m.setCast(ncast);
movieList.add(m);
System.out.println(movieList);
}
public static void updateIsBlockbuster(String omovieTitle, boolean nisBlockbuster)
{
Movie m = search(movieList, omovieTitle);
movieList.remove(m);
m.setBlockBuster(nisBlockbuster);
movieList.add(m);
System.out.println(movieList);
}
public static void deleteMovie(String movieTitle)
{
Movie m = search(movieList, movieTitle);
movieList.remove(m);
System.out.println(movieList);
}
public static void createMovie(String movieTitle, int showingStatus, String sypnosis, String director, ArrayList <String> cast, double basePrice)
{
Movie m = new Movie();
m.setMovieTitle(movieTitle);
m.setBasePrice(basePrice);
m.setCast(cast);
m.setDirector(director);
m.setShowingStatus(showingStatus);
m.setSypnosis(sypnosis);
addMovie(m);
}
}