Question

In: Computer Science

Based on Movie package example, you will create a package about your favorite TV series and...

Based on Movie package example, you will create a package about your favorite TV series and provide the plot()

Readme.txt: Explain how you apply polymorphism in your program

package Movie;

public class MovieTester {
public static void main(String[] args) {

for(int i = 1; i < 11; i++){
Movie movie = randomMovie();
System.out.println("Movie # " + i + ": " + movie.getTitle() + ", Genre: " + movie.getGenre() + '\n'
+"Plot: " + movie.plot());
}

}

public static Movie randomMovie(){
int randomNumber = (int)(Math.random() * 5) + 1; //1 and 5

System.out.println("Random number is going to be generated and it is " + randomNumber);

switch(randomNumber){
case 1: return new Borat();
case 2: return new Inception();
case 3: return new JohnWick();
case 4: return new Parasite();
case 5: return new Shrek();
}

return null;
}
}

class Movie{

private String title;
private String genre;
private String rating;
private int year;
private int length; //minute

public Movie(String title, String genre, String rating, int year, int length) {
this.title = title;
this.genre = genre;
this.rating = rating;
this.year = year;
this.length = length;
}

public String getTitle() {
return title;
}

public String getGenre() {
return genre;
}

public String getRating() {
return rating;
}

public int getYear() {
return year;
}

public int getLength() {
return length;
}

public String plot(){
return "No plot yet provided";
}
}

//Shrek, JohnWick, Inception, Borat, Parasite

class Shrek extends Movie{

public Shrek(){
super("Shrek","Animation","R",1991,120);
}
@Override
public String plot(){
return "To save Fiona.";
}


}

class JohnWick extends Movie{


public JohnWick(){
super("John Wick","Action","R",2000,120);
}

@Override
public String plot(){
return "To revenge";
}

}

class Inception extends Movie{

public Inception(){
super("Inception", "Thriller", "PG",1996, 150);
}

@Override
public String plot(){
return "To chasing.";
}

}

class Borat extends Movie{

public Borat(){
super("Borat", "Comedy", "R", 2020,120);
}

@Override
public String plot(){
return "Trying to find Pamela Anderson.";
}


}

class Parasite extends Movie{

public Parasite(){
super("Parasite", "Horror", "R", 2019, 120);
}

@Override
public String plot(){
return "About three family";
}

}

Solutions

Expert Solution

If you have any problem with the code feel free to comment. Add more tv series class accordingly.

TvSeries

package tvSeries;

public class TVSeries {
        //instance variables
        private String title;
        private String genre;
        private String rating;
        private int year;
        private int numEpisodes;
        
        //constructor
        public TVSeries(String title, String genre, String rating, int year, int numEpisodes) {
                this.title = title;
                this.genre = genre;
                this.rating = rating;
                this.year = year;
                this.numEpisodes = numEpisodes;
        }

        //all getter methods
        public String getTitle() {
                return title;
        }

        public String getGenre() {
                return genre;
        }

        public String getRating() {
                return rating;
        }

        public int getYear() {
                return year;
        }

        public int getNumEpisodes() {
                return numEpisodes;
        }
        
        //plot method
        public String plot() {
                return "no plot yet";
        }

        //toString method
        @Override
        public String toString() {
                return "Title=" + title + "\nGenre=" + genre + "\nRating=" + rating + "\nYear=" + year + "\nNumber of Episodes="
                                + numEpisodes;
        }
        
}

BigBangTheory

package tvSeries;

public class BigBangTheory extends TVSeries {
        //initializing the TvSeries constructor
        public BigBangTheory() {
                super("The Big Bang Theory", "Comedy", "8.3", 2007, 279);
        }
        
        //giving the plot
        @Override
        public String plot() {
                return "Nerds learning to interact with girls";
        }
}

BreakingBad

package tvSeries;

public class BreakingBad extends TVSeries {

        public BreakingBad() {
                super("Breaking Bad", "Crime", "9.6", 2008, 62);
        }
        
        @Override
        public String plot() {
                return "A chemistry teacher becomes a drug lord";
        }

}

TvSeriesTester

package tvSeries;

public class TVSeriesTester {
        public static void main(String[] args) {
                //using polymorphism 
                TVSeries bbt = new BigBangTheory();
                TVSeries bb = new BreakingBad();
                
                //showing result
                System.out.println(bbt);
                System.out.println("Plot= "+bbt.plot());
                System.out.println("\n"+bb);
                System.out.println("Plot= "+bb.plot());
        }
}

Output


Related Solutions

Hello, please tell me about your favorite movie! select ANY movie of your choice and analyze...
Hello, please tell me about your favorite movie! select ANY movie of your choice and analyze the movie from the perspective of developmental psychology. You will discuss the themes, plot, characters, and conflict in the movie. You will tie these elements of the movie to theories, topics, and information covered in this course. The paper should demonstrate your broad and comprehensive understanding of the field of Developmental Psychology.
1. Writing a recommendation of 2 pages for a movie or a TV series that is...
1. Writing a recommendation of 2 pages for a movie or a TV series that is related to strategic management. Guidelines for the expectations of the article -The movie/TV series recommendation should include the film/ TV series title, leading actors, the director, the storyline, and how does the movie/ series related to strategic management. -You can pick any movie/TV series that are related topics in the lectures or in the textbooks, for example, game theory, corporate merger & acquisition, and...
Experience Paper Topics III. Analyze your favorite TV or movie character according to different personality theories....
Experience Paper Topics III. Analyze your favorite TV or movie character according to different personality theories. In a paragraph or two describe the plot. Describe the character’s personality according to one or more personality theories. Be sure to include phrases or behaviors used by the character to back up your observations Requirements Be thorough when describing a concept.Tell me what you know about the topic. You should be able to recognize how the principles we talk about apply to your...
In this assignment you will create a web page about your favorite sports to play or...
In this assignment you will create a web page about your favorite sports to play or teams to watch. If you don’t watch or play sports, please make up your favorite sports to play or teams to watch. You will be incorporating images into your web page, as well as other concepts learned in this unit. Create an external style sheet using a text editor of your choosing. In the CSS file add the following style rules: A background image...
Write an original essay about a book, TV show, article, song or movie that taught you...
Write an original essay about a book, TV show, article, song or movie that taught you a lesson about money or changed your understanding about money.
About 27% of US citizens say football is their favorite sport to watch on TV. A...
About 27% of US citizens say football is their favorite sport to watch on TV. A random sample of 100 US citizens is obtained. Is the sampling distribution of the sample proportion normally distributed? Why?
Instructions 1. Create a class named after your favorite object in the whole world. For example,...
Instructions 1. Create a class named after your favorite object in the whole world. For example, if you love pizza, then create a class called Pizza.java. This class should not have a main method (1 point) 2. Create Instance Variables (attributes) (2 point) Create at least 3 private instance fields (attributes) for your class You must use at least 3 different data types for your fields 3. Create getter (accessor) and setter (mutator) methods   Create a getter (accessor) method for...
Chose (movie, or TV show) and identify 5-10 different psychological concepts you learned about in this...
Chose (movie, or TV show) and identify 5-10 different psychological concepts you learned about in this class that is demonstrated in your chosen (___). Do not simply summarize the (___); instead, make connections between selected psychological concepts and how they are demonstrated in your chosen (___).
Databases Terrier Television wants to create a database of its TV series recordings. Each Series consists...
Databases Terrier Television wants to create a database of its TV series recordings. Each Series consists of 13 episodes. Actors may appear in more than one series. Terrier TV wants the database to be searchable be series, episode and actor. Why would a relational database be the most appropriate solution for this? List the tables and attributes for when the database is implemented in Access and identify the primary key and the foreign key for each table.
9. Create a Web page about your favorite musical group. Include the name of the group,...
9. Create a Web page about your favorite musical group. Include the name of the group, the individuals in the group, a hyperlink to the group’s Web site, your favorite three (or fewer if the group is new) CD releases, and a brief review of each CD. ● Use an unordered list to organize the names of the individuals. ● Use a definition list for the names of the CDs and your reviews. I would like it on Pink Floyd...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT