SHOW:
|
|
- or go back to the newest paste.
1 | class Movie { | |
2 | private String name; | |
3 | ||
4 | public Movie(String name){ | |
5 | this.name = name; | |
6 | } | |
7 | ||
8 | public String getName() { | |
9 | return name; | |
10 | } | |
11 | ||
12 | public String plot(){ | |
13 | return " No plot here"; | |
14 | } | |
15 | public String character(){ | |
16 | return "Main character"; | |
17 | } | |
18 | } | |
19 | ||
20 | class Jaws extends Movie { | |
21 | ||
22 | public Jaws(){ | |
23 | super("Jaws"); | |
24 | } | |
25 | ||
26 | public String plot(){ | |
27 | return "A shark eats lots of people"; | |
28 | } | |
29 | ||
30 | @Override | |
31 | public String character() { | |
32 | return "Jaws"; | |
33 | } | |
34 | } | |
35 | ||
36 | class MazeRunner extends Movie { | |
37 | public MazeRunner( ) { | |
38 | super("Maze Runner"); | |
39 | } | |
40 | ||
41 | @Override | |
42 | public String plot() { | |
43 | return "Kids try and escape a maze"; | |
44 | } | |
45 | ||
46 | @Override | |
47 | public String character() { | |
48 | return "Maze"; | |
49 | } | |
50 | } | |
51 | ||
52 | class StarWars extends Movie { | |
53 | public StarWars() { | |
54 | super("Star Wars"); | |
55 | } | |
56 | ||
57 | @Override | |
58 | public String plot() { | |
59 | return "Imperial forces try to take over the universe"; | |
60 | } | |
61 | ||
62 | @Override | |
63 | public String character() { | |
64 | return "Star"; | |
65 | } | |
66 | } | |
67 | ||
68 | class Forgettable extends Movie { | |
69 | public Forgettable(){ | |
70 | super ("Forgettable"); | |
71 | } | |
72 | // No plot method | |
73 | // No character here; | |
74 | } | |
75 | ||
76 | class IndependenceDay extends Movie { | |
77 | ||
78 | public IndependenceDay() { | |
79 | super("Independence Day"); | |
80 | } | |
81 | ||
82 | @Override | |
83 | public String plot() { | |
84 | return ("Aliens attempted to take over planet earth"); | |
85 | } | |
86 | } | |
87 | ||
88 | ||
89 | public class Main { | |
90 | ||
91 | public static void main(String[] args) { | |
92 | ||
93 | for ( int x = 1 ; x < 9 ; x++){ | |
94 | // int y = 3 * x; | |
95 | System.out.println(" 3 * " + x + " = " ); | |
96 | } | |
97 | ||
98 | for (int i = 1 ; i < 11 ; i ++){ | |
99 | Movie movie = randomMovie(); | |
100 | System.out.println("Movie # " + i + " : " + movie.getName() + " \n " + "Plot: + " + movie.plot() + "\n" + movie.character() + "\n"); | |
101 | } | |
102 | } | |
103 | ||
104 | public static Movie randomMovie(){ | |
105 | int randomNumber = (int) (Math.random()*5) + 1; | |
106 | System.out.println("Random movie generated was: " + randomNumber); | |
107 | switch (randomNumber) { | |
108 | case 1: | |
109 | return new Jaws(); | |
110 | ||
111 | case 2: | |
112 | return new IndependenceDay(); | |
113 | ||
114 | case 3: | |
115 | return new MazeRunner(); | |
116 | ||
117 | case 4: | |
118 | return new StarWars(); | |
119 | ||
120 | case 5: | |
121 | return new Forgettable(); | |
122 | } | |
123 | return null; | |
124 | } | |
125 | } |