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

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...
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...
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...
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...
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.
create the UML Diagram to model a Movie/TV viewing site. Draw a complete UML class diagram...
create the UML Diagram to model a Movie/TV viewing site. Draw a complete UML class diagram which shows: Classes (Only the ones listed in bold below) Attributes in classes (remember to indicate privacy level, and type) No need to write methods Relationships between classes (has is, is a, ...) Use a program like Lucid Cart and then upload your diagram. Each movie has: name, description, length, list of actors, list of prequals and sequals Each TV Show has: name, description,...
You are dining at your favorite restaurant and eating your favorite meal when you start to...
You are dining at your favorite restaurant and eating your favorite meal when you start to think about the digestion process (sorry to ruin your meal). Briefly explain this process when food enters your stomach then in your small intestine. Include the following terms/structures in your explanation: stomach; chyme; hydrochloric acid; 3 basic tasks of stomach; length of time in stomach; 3 structural parts of small intestine; describe what happens in the first 25 centimeters of the small intestine; role...
Is your favorite TV program often interrupted by advertising? CNBC presented statistics on the average number...
Is your favorite TV program often interrupted by advertising? CNBC presented statistics on the average number of programming minutes in a half-hour sitcom. For a random sample of 23 half-hour sitcoms, the mean number of programming minutes was 21.52 and the standard deviation was 1.15. Assume that the population is approximately normal. Estimate with 93% confidence the mean number of programming minutes during a half-hour television sitcom.  (Round to 2 decimal places.) Complete the following sentence to provide an interpretation of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT