Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Movie {
- private String name;
- public Movie(String name){
- this.name = name;
- }
- public String getName() {
- return name;
- }
- public String plot(){
- return " No plot here";
- }
- public String character(){
- return "Main character";
- }
- }
- class Jaws extends Movie {
- public Jaws(){
- super("Jaws");
- }
- public String plot(){
- return "A shark eats lots of people";
- }
- @Override
- public String character() {
- return "Jaws";
- }
- }
- class MazeRunner extends Movie {
- public MazeRunner( ) {
- super("Maze Runner");
- }
- @Override
- public String plot() {
- return "Kids try and escape a maze";
- }
- @Override
- public String character() {
- return "Maze";
- }
- }
- class StarWars extends Movie {
- public StarWars() {
- super("Star Wars");
- }
- @Override
- public String plot() {
- return "Imperial forces try to take over the universe";
- }
- @Override
- public String character() {
- return "Star";
- }
- }
- class Forgettable extends Movie {
- public Forgettable(){
- super ("Forgettable");
- }
- // No plot method
- // No character here;
- }
- class IndependenceDay extends Movie {
- public IndependenceDay() {
- super("Independence Day");
- }
- @Override
- public String plot() {
- return ("Aliens attempted to take over planet earth");
- }
- }
- public class Main {
- public static void main(String[] args) {
- for ( int x = 1 ; x < 9 ; x++){
- // int y = 3 * x;
- System.out.println(" 3 * " + x + " = " );
- }
- for (int i = 1 ; i < 11 ; i ++){
- Movie movie = randomMovie();
- System.out.println("Movie # " + i + " : " + movie.getName() + " \n " + "Plot: + " + movie.plot() + "\n" + movie.character() + "\n");
- }
- }
- public static Movie randomMovie(){
- int randomNumber = (int) (Math.random()*5) + 1;
- System.out.println("Random movie generated was: " + randomNumber);
- switch (randomNumber) {
- case 1:
- return new Jaws();
- case 2:
- return new IndependenceDay();
- case 3:
- return new MazeRunner();
- case 4:
- return new StarWars();
- case 5:
- return new Forgettable();
- }
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement