SlideShare a Scribd company logo
1 of 9
Download to read offline
Write a Java program that mimics the framework for an online movie information system similar
to IMDB written in Java. Create an abstract base class, two subclasses, and one interface to
provide basic functionality for the system. Use the provided UML, the class descriptions, and the
test output to determine the proper behavior for your classes.
Create an interface Rateable that: Provides a method vote(int numVotes, int voteScore).
Create an abstract class Movie that: Implements the Rateable and Comparable interfaces.
Provides the data fields: title, releaseYear, genre, numVotes, and voteScore. Provides four
constructors: o Default, no-arg constructor o Three convenience constructors that allow as
parameters: the title the title and releaseYear the title, releaseYear, and genre. Provides an
abstract getInfo() method. Provides a concrete toString() method that returns the only movie
title. Provides a concrete getRating() method that returns: o -1 if numVotes is 0, o
voteScore/numVotes otherwise. Implements the Rateable interface’s vote() method by
increasing the existing values of numVotes and voteScore by the amount passed in the
appropriate parameter. Implements the Comparable interface’s compareTo() method by
comparing ratings. Movies should be sorted in descending order, meaning that a higher rating
should be considered “less than” a lower rating.
Create a concrete class Horror that: Automatically sets the genre to Horror in its constructors.
Adds a data attribute for number of deaths, numOfDeaths, with the appropriate getter/setter
methods.
2
Provides a getInfo() method that returns “title, genre, releaseYear (rating): numDeaths deaths”
with the appropriate values. o Detects if it receives a -1 from getRating() and uses “No ratings”
as the rating. o To pass LiveLab’s auto-grader, make sure ratings are limited to one decimal
place (see documentation on using String.format() which works similar to System.out.printf()).
Create a concrete class Comedy that: Automatically sets the genre to Comedy in its
constructors. Adds a data attribute, hasProfanity, to indicate whether there is profanity in the
film with the appropriate getter/setter methods. Provides a getInfo() method that returns “title,
genre, releaseYear (rating): Profanity/No Profanity” with the appropriate values. o Detects if it
receives a -1 from getRating() and use “No ratings” as the rating. o To pass LiveLab’s auto-
grader, make sure ratings are limited to one decimal place (see documentation on using
String.format() which works similar to System.out.printf()).
NOTE: Movie, Horror, and Comedy should provide all of the appropriate accessor/mutator
methods for their data fields. For brevity, these are not included in the UML.
Main method Create the horror movies: o A Nightmare on Elm Street, 1984, 4 deaths o Final
Destination 5, 2011, 94 deaths1 o Saw, 2004, 6 deaths Create the comedy movies: o Napoleon
Dynamite, 2004, no profanity o Keeping Up with the Joneses, 2016, profanity o Uncle Buck,
1989, profanity
Use the vote() method to assign votes to the respective movies: (# votes - total vote score) o A
Nightmare on Elm Street: 151,963 – 1,139,723 o Final Destination 5: 84,907 – 500,951 o Saw:
303,578 – 2,337,551 o Napoleon Dynamite: 163,240 – 1,126,356 o Uncle Buck: 64,031 –
448,217
Create an Array of type Movie and populate it with all of the created movies. Do not create
them in sorted order, let the sort method handle that. Sort the array using the
java.util.Arrays.sort() method. Using a loop, print the results of the getInfo() call for each movies
in the sorted array. 1 http://finaldestination.wikia.com/wiki/List_of_deaths
3
Simplified UML
Test Output Saw, Horror, 2004 (7.7): 6 deaths A Nightmare on Elm Street, Horror, 1984 (7.5): 4
deaths Napoleon Dynamite, Comedy, 2004 (6.9): No Profanity Uncle Buck, Comedy, 1989 (6.9):
Profanity Final Destination 5, Horror, 2011 (5.9): 94 deaths Keeping Up with the Joneses,
Comedy, 2016 (No ratings): Profanity
Solution
PROGRAM CODE:
Rateable.java
package movies;
public interface Rateable {
//abstract method for the rateable class
public void vote(int numVotes, int voteScore);
}
Movie.java
package movies;
public abstract class Movie implements Rateable, Comparable{
// Data fields for the class
String title;
int releaseYear;
String genre;
int numVotes;
int voteScore;
// Default constructor
Movie()
{
title = "";
genre = "";
}
//Parameterized Constructors
Movie(String title)
{
this.title = title;
}
Movie(String title, int releaseYear)
{
this.title = title;
this.releaseYear = releaseYear;
}
Movie(String title, int releaseYear, String genre)
{
this.title = title;
this.releaseYear = releaseYear;
this.genre = genre;
}
//setters and getters
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public int getReleaseYear() {
return releaseYear;
}
public void setReleaseYear(int releaseYear) {
this.releaseYear = releaseYear;
}
public String getGenre() {
return genre;
}
public void setGenre(String genre) {
this.genre = genre;
}
public int getNumVotes() {
return numVotes;
}
public void setNumVotes(int numVotes) {
this.numVotes = numVotes;
}
public int getVoteScore() {
return voteScore;
}
public void setVoteScore(int voteScore) {
this.voteScore = voteScore;
}
// abstract method
public abstract String getInfo();
// toString() to return the movie title
public String toString()
{
return this.title;
}
//getRating() method to calculate rating
public int getRating()
{
if(this.numVotes > 0)
return -1;
else
return this.voteScore/numVotes;
}
// method to define from Comparable interface
@Override
public int compareTo(Movie movie) {
if(this.getRating() == movie.getRating())
return 0;
else if(this.getRating() > movie.getRating())
return 1;
else
return -1;
}
//method to define from Rateable interface
@Override
public void vote(int numVotes, int voteScore) {
this.numVotes = numVotes;
this.voteScore = voteScore;
}
}
Horror.java
package movies;
public class Horror extends Movie{
int numOfDeaths;
String genre;
//Setting the genre to Horror in default comstructor
public Horror() {
this.genre = "Horror";
}
//setter and getter
public int getNumOfDeaths() {
return numOfDeaths;
}
public void setNumOfDeaths(int numOfDeaths) {
this.numOfDeaths = numOfDeaths;
}
// Implementing the abstract method
public String getInfo()
{
String rating = this.getRating() < 0? "No ratings": String.valueOf(this.getRating());
return this.title + "," + this.genre + "," + this.releaseYear + "(" + rating + "):" +
this.numOfDeaths +"deaths";
}
}
Comedy.java
package movies;
public class Comedy extends Movie{
boolean hasProfanity;
//Setters and getters
public boolean isHasProfanity() {
return hasProfanity;
}
public void setHasProfanity(boolean hasProfanity) {
this.hasProfanity = hasProfanity;
}
public Comedy()
{
this.genre = "Comedy";
}
@Override
public String getInfo() {
String rating = this.getRating() < 0? "No ratings": String.valueOf(this.getRating()); // using
ternary operator to check if value is less than 0
String profanity = this.hasProfanity? "Profanity" : "No Profanity";
// using ternary operator to check if profanity is true or false and setting string value based
on that
return this.title + "," + this.genre + "," + this.releaseYear + "(" + rating + "):" +
profanity;
}
}
MainClass.java
package movies;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import javax.sound.midi.ControllerEventListener;
public class MainClass {
public static void main(String[] args) {
//creating objects for Horror and Comedy and adding data
Horror horror = new Horror();
horror.setTitle("A Nightmare on Elm Street");
horror.setReleaseYear(1984);
horror.setNumOfDeaths(4);
Horror horror2 = new Horror();
horror2.setTitle("Final Destination 5");
horror2.setReleaseYear(2011);
horror2.setNumOfDeaths(94);
Horror horror3= new Horror();
horror3.setTitle("Saw");
horror3.setReleaseYear(2004);
horror3.setNumOfDeaths(6);
Comedy comedy1 = new Comedy();
comedy1.setTitle("Napolean Dynamite");
comedy1.setReleaseYear(2004);
comedy1.setHasProfanity(false);
Comedy comedy2 = new Comedy();
comedy2.setTitle("Keeping Up with the Joneses");
comedy2.setReleaseYear(2016);
comedy2.setHasProfanity(true);
Comedy comedy3 = new Comedy();
comedy3.setTitle("Uncle Buck");
comedy3.setReleaseYear(1989);
comedy3.setHasProfanity(true);
horror.vote(151963, 1139723);
horror2.vote(84907, 500951);
horror3.vote(303578, 2337551);
comedy1.vote(163240, 1126356);
comedy3.vote(64031, 448217);
//creating an arraylist and adding all the movies into it
ArrayList movieList = new ArrayList<>();
movieList.add(horror);
movieList.add(horror2);
movieList.add(horror3);
movieList.add(comedy1);
movieList.add(comedy2);
movieList.add(comedy3);
//creating an arraylist and adding all the movies into it
Movie[] movies = new Movie[6];
movies[0] = horror;
movies[1] = horror2;
movies[2] = horror3;
movies[3] = comedy1;
movies[4] = comedy2;
movies[5] = comedy3;
//Sorting the arraylist
Arrays.sort(movies);
//printing the arrays
for(int i=0; i

More Related Content

Similar to Write a Java program that mimics the framework for an online movie i.pdf

Recommending Movies Using Neo4j
Recommending Movies Using Neo4j Recommending Movies Using Neo4j
Recommending Movies Using Neo4j Ilias Katsabalos
 
do it in eclips and make sure it compile Goals1)Be able to.docx
do it in eclips and make sure it compile Goals1)Be able to.docxdo it in eclips and make sure it compile Goals1)Be able to.docx
do it in eclips and make sure it compile Goals1)Be able to.docxjameywaughj
 
Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsMuhammadTalha436
 
Desing pattern prototype-Factory Method, Prototype and Builder
Desing pattern prototype-Factory Method, Prototype and Builder Desing pattern prototype-Factory Method, Prototype and Builder
Desing pattern prototype-Factory Method, Prototype and Builder paramisoft
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with JavaJussi Pohjolainen
 
Objectives The main objective of this assignment is checking .docx
Objectives The main objective of this assignment is checking .docxObjectives The main objective of this assignment is checking .docx
Objectives The main objective of this assignment is checking .docxamit657720
 
Objectives The main objective of this assignment is checking .docx
Objectives The main objective of this assignment is checking .docxObjectives The main objective of this assignment is checking .docx
Objectives The main objective of this assignment is checking .docxvannagoforth
 
Factorization Machines and Applications in Recommender Systems
Factorization Machines and Applications in Recommender SystemsFactorization Machines and Applications in Recommender Systems
Factorization Machines and Applications in Recommender SystemsEvgeniy Marinov
 
Windy City DB - Recommendation Engine with Neo4j
Windy City DB - Recommendation Engine with Neo4jWindy City DB - Recommendation Engine with Neo4j
Windy City DB - Recommendation Engine with Neo4jMax De Marzi
 
Goals1)Be able to work with individual bits in java.2).docx
Goals1)Be able to work with individual bits in java.2).docxGoals1)Be able to work with individual bits in java.2).docx
Goals1)Be able to work with individual bits in java.2).docxjosephineboon366
 
Modify Assignment 5 toReplace the formatted output method (toStri.docx
Modify Assignment 5 toReplace the formatted output method (toStri.docxModify Assignment 5 toReplace the formatted output method (toStri.docx
Modify Assignment 5 toReplace the formatted output method (toStri.docxadelaidefarmer322
 
Do I need tests when I have the compiler - Andrzej Jóźwiak - TomTom Dev Day 2020
Do I need tests when I have the compiler - Andrzej Jóźwiak - TomTom Dev Day 2020Do I need tests when I have the compiler - Andrzej Jóźwiak - TomTom Dev Day 2020
Do I need tests when I have the compiler - Andrzej Jóźwiak - TomTom Dev Day 2020Andrzej Jóźwiak
 
Review Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfReview Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfmayorothenguyenhob69
 
Production.javapublic class Production {    Declaring instance.pdf
Production.javapublic class Production {    Declaring instance.pdfProduction.javapublic class Production {    Declaring instance.pdf
Production.javapublic class Production {    Declaring instance.pdfsooryasalini
 
Polymorphism in C# Function overloading in C#
Polymorphism in C# Function overloading in C#Polymorphism in C# Function overloading in C#
Polymorphism in C# Function overloading in C#Abid Kohistani
 
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...Udayan Khattry
 
The Ring programming language version 1.4 book - Part 14 of 30
The Ring programming language version 1.4 book - Part 14 of 30The Ring programming language version 1.4 book - Part 14 of 30
The Ring programming language version 1.4 book - Part 14 of 30Mahmoud Samir Fayed
 
public static void main(String[], args) throws FileNotFoundExcepti.pdf
public static void main(String[], args) throws FileNotFoundExcepti.pdfpublic static void main(String[], args) throws FileNotFoundExcepti.pdf
public static void main(String[], args) throws FileNotFoundExcepti.pdffms12345
 

Similar to Write a Java program that mimics the framework for an online movie i.pdf (20)

Recommending Movies Using Neo4j
Recommending Movies Using Neo4j Recommending Movies Using Neo4j
Recommending Movies Using Neo4j
 
do it in eclips and make sure it compile Goals1)Be able to.docx
do it in eclips and make sure it compile Goals1)Be able to.docxdo it in eclips and make sure it compile Goals1)Be able to.docx
do it in eclips and make sure it compile Goals1)Be able to.docx
 
Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ Exams
 
Desing pattern prototype-Factory Method, Prototype and Builder
Desing pattern prototype-Factory Method, Prototype and Builder Desing pattern prototype-Factory Method, Prototype and Builder
Desing pattern prototype-Factory Method, Prototype and Builder
 
Scmad Chapter07
Scmad Chapter07Scmad Chapter07
Scmad Chapter07
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
 
Objectives The main objective of this assignment is checking .docx
Objectives The main objective of this assignment is checking .docxObjectives The main objective of this assignment is checking .docx
Objectives The main objective of this assignment is checking .docx
 
Objectives The main objective of this assignment is checking .docx
Objectives The main objective of this assignment is checking .docxObjectives The main objective of this assignment is checking .docx
Objectives The main objective of this assignment is checking .docx
 
Factorization Machines and Applications in Recommender Systems
Factorization Machines and Applications in Recommender SystemsFactorization Machines and Applications in Recommender Systems
Factorization Machines and Applications in Recommender Systems
 
Windy City DB - Recommendation Engine with Neo4j
Windy City DB - Recommendation Engine with Neo4jWindy City DB - Recommendation Engine with Neo4j
Windy City DB - Recommendation Engine with Neo4j
 
Goals1)Be able to work with individual bits in java.2).docx
Goals1)Be able to work with individual bits in java.2).docxGoals1)Be able to work with individual bits in java.2).docx
Goals1)Be able to work with individual bits in java.2).docx
 
Modify Assignment 5 toReplace the formatted output method (toStri.docx
Modify Assignment 5 toReplace the formatted output method (toStri.docxModify Assignment 5 toReplace the formatted output method (toStri.docx
Modify Assignment 5 toReplace the formatted output method (toStri.docx
 
Do I need tests when I have the compiler - Andrzej Jóźwiak - TomTom Dev Day 2020
Do I need tests when I have the compiler - Andrzej Jóźwiak - TomTom Dev Day 2020Do I need tests when I have the compiler - Andrzej Jóźwiak - TomTom Dev Day 2020
Do I need tests when I have the compiler - Andrzej Jóźwiak - TomTom Dev Day 2020
 
Review Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfReview Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdf
 
Production.javapublic class Production {    Declaring instance.pdf
Production.javapublic class Production {    Declaring instance.pdfProduction.javapublic class Production {    Declaring instance.pdf
Production.javapublic class Production {    Declaring instance.pdf
 
Core java
Core javaCore java
Core java
 
Polymorphism in C# Function overloading in C#
Polymorphism in C# Function overloading in C#Polymorphism in C# Function overloading in C#
Polymorphism in C# Function overloading in C#
 
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
 
The Ring programming language version 1.4 book - Part 14 of 30
The Ring programming language version 1.4 book - Part 14 of 30The Ring programming language version 1.4 book - Part 14 of 30
The Ring programming language version 1.4 book - Part 14 of 30
 
public static void main(String[], args) throws FileNotFoundExcepti.pdf
public static void main(String[], args) throws FileNotFoundExcepti.pdfpublic static void main(String[], args) throws FileNotFoundExcepti.pdf
public static void main(String[], args) throws FileNotFoundExcepti.pdf
 

More from mohdjakirfb

Describe the stages of malaria and the site of protozoal activity on.pdf
Describe the stages of malaria and the site of protozoal activity on.pdfDescribe the stages of malaria and the site of protozoal activity on.pdf
Describe the stages of malaria and the site of protozoal activity on.pdfmohdjakirfb
 
Database problem. Design a realtional schema based on E-R Diagram. B.pdf
Database problem. Design a realtional schema based on E-R Diagram. B.pdfDatabase problem. Design a realtional schema based on E-R Diagram. B.pdf
Database problem. Design a realtional schema based on E-R Diagram. B.pdfmohdjakirfb
 
d. What types of information systems ru currently utilized at PVF Pr.pdf
d. What types of information systems ru currently utilized at PVF Pr.pdfd. What types of information systems ru currently utilized at PVF Pr.pdf
d. What types of information systems ru currently utilized at PVF Pr.pdfmohdjakirfb
 
Bacteria growthExplain a growth curve.Explain lag phase, exponen.pdf
Bacteria growthExplain a growth curve.Explain lag phase, exponen.pdfBacteria growthExplain a growth curve.Explain lag phase, exponen.pdf
Bacteria growthExplain a growth curve.Explain lag phase, exponen.pdfmohdjakirfb
 
An ovum has all the nutrients stored that required for embryonic d.pdf
An ovum has all the nutrients stored that required for embryonic d.pdfAn ovum has all the nutrients stored that required for embryonic d.pdf
An ovum has all the nutrients stored that required for embryonic d.pdfmohdjakirfb
 
A plant with either the PP or Pp genotype has purple flowers, while .pdf
A plant with either the PP or Pp genotype has purple flowers, while .pdfA plant with either the PP or Pp genotype has purple flowers, while .pdf
A plant with either the PP or Pp genotype has purple flowers, while .pdfmohdjakirfb
 
________ ANOVA relies on matched samples in a similar way to the mat.pdf
________ ANOVA relies on matched samples in a similar way to the mat.pdf________ ANOVA relies on matched samples in a similar way to the mat.pdf
________ ANOVA relies on matched samples in a similar way to the mat.pdfmohdjakirfb
 
Write a program that converts an infix expression into an equivalent.pdf
Write a program that converts an infix expression into an equivalent.pdfWrite a program that converts an infix expression into an equivalent.pdf
Write a program that converts an infix expression into an equivalent.pdfmohdjakirfb
 
Which microtubule (MT) population binds to chromosomes during mitosi.pdf
Which microtubule (MT) population binds to chromosomes during mitosi.pdfWhich microtubule (MT) population binds to chromosomes during mitosi.pdf
Which microtubule (MT) population binds to chromosomes during mitosi.pdfmohdjakirfb
 
React to the following statement Knowledge is the technology wh.pdf
React to the following statement Knowledge is the technology wh.pdfReact to the following statement Knowledge is the technology wh.pdf
React to the following statement Knowledge is the technology wh.pdfmohdjakirfb
 
what animals first evolved true skeletonswhat animals first .pdf
what animals first evolved true skeletonswhat animals first .pdfwhat animals first evolved true skeletonswhat animals first .pdf
what animals first evolved true skeletonswhat animals first .pdfmohdjakirfb
 
true or false Different parts of the genome evolve at different spe.pdf
true or false Different parts of the genome evolve at different spe.pdftrue or false Different parts of the genome evolve at different spe.pdf
true or false Different parts of the genome evolve at different spe.pdfmohdjakirfb
 
The brightness in the center of a Fresnel diffraction pattern. Is al.pdf
The brightness in the center of a Fresnel diffraction pattern.  Is al.pdfThe brightness in the center of a Fresnel diffraction pattern.  Is al.pdf
The brightness in the center of a Fresnel diffraction pattern. Is al.pdfmohdjakirfb
 
Should Linda’s history of past improprieties lead Maria to withdraw .pdf
Should Linda’s history of past improprieties lead Maria to withdraw .pdfShould Linda’s history of past improprieties lead Maria to withdraw .pdf
Should Linda’s history of past improprieties lead Maria to withdraw .pdfmohdjakirfb
 
Problem 4.Organisms are present in ballast water discharged from a.pdf
Problem 4.Organisms are present in ballast water discharged from a.pdfProblem 4.Organisms are present in ballast water discharged from a.pdf
Problem 4.Organisms are present in ballast water discharged from a.pdfmohdjakirfb
 
Q2. Does Application Engine Generate SQLs like Query ManagerQ7. C.pdf
Q2. Does Application Engine Generate SQLs like Query ManagerQ7. C.pdfQ2. Does Application Engine Generate SQLs like Query ManagerQ7. C.pdf
Q2. Does Application Engine Generate SQLs like Query ManagerQ7. C.pdfmohdjakirfb
 
QUESTION 6- Delay spread of optical pulses results on multimode fibe.pdf
QUESTION 6- Delay spread of optical pulses results on multimode fibe.pdfQUESTION 6- Delay spread of optical pulses results on multimode fibe.pdf
QUESTION 6- Delay spread of optical pulses results on multimode fibe.pdfmohdjakirfb
 
31.A Biased sample is one that ______a. Is too smallb. Will al.pdf
31.A Biased sample is one that ______a. Is too smallb. Will al.pdf31.A Biased sample is one that ______a. Is too smallb. Will al.pdf
31.A Biased sample is one that ______a. Is too smallb. Will al.pdfmohdjakirfb
 
Please help me Im very confused thanks Find sin 2x, cos 2x, and tan .pdf
Please help me Im very confused thanks Find sin 2x, cos 2x, and tan .pdfPlease help me Im very confused thanks Find sin 2x, cos 2x, and tan .pdf
Please help me Im very confused thanks Find sin 2x, cos 2x, and tan .pdfmohdjakirfb
 
please explain in detail What is the PCAOB Please explain what is t.pdf
please explain in detail What is the PCAOB Please explain what is t.pdfplease explain in detail What is the PCAOB Please explain what is t.pdf
please explain in detail What is the PCAOB Please explain what is t.pdfmohdjakirfb
 

More from mohdjakirfb (20)

Describe the stages of malaria and the site of protozoal activity on.pdf
Describe the stages of malaria and the site of protozoal activity on.pdfDescribe the stages of malaria and the site of protozoal activity on.pdf
Describe the stages of malaria and the site of protozoal activity on.pdf
 
Database problem. Design a realtional schema based on E-R Diagram. B.pdf
Database problem. Design a realtional schema based on E-R Diagram. B.pdfDatabase problem. Design a realtional schema based on E-R Diagram. B.pdf
Database problem. Design a realtional schema based on E-R Diagram. B.pdf
 
d. What types of information systems ru currently utilized at PVF Pr.pdf
d. What types of information systems ru currently utilized at PVF Pr.pdfd. What types of information systems ru currently utilized at PVF Pr.pdf
d. What types of information systems ru currently utilized at PVF Pr.pdf
 
Bacteria growthExplain a growth curve.Explain lag phase, exponen.pdf
Bacteria growthExplain a growth curve.Explain lag phase, exponen.pdfBacteria growthExplain a growth curve.Explain lag phase, exponen.pdf
Bacteria growthExplain a growth curve.Explain lag phase, exponen.pdf
 
An ovum has all the nutrients stored that required for embryonic d.pdf
An ovum has all the nutrients stored that required for embryonic d.pdfAn ovum has all the nutrients stored that required for embryonic d.pdf
An ovum has all the nutrients stored that required for embryonic d.pdf
 
A plant with either the PP or Pp genotype has purple flowers, while .pdf
A plant with either the PP or Pp genotype has purple flowers, while .pdfA plant with either the PP or Pp genotype has purple flowers, while .pdf
A plant with either the PP or Pp genotype has purple flowers, while .pdf
 
________ ANOVA relies on matched samples in a similar way to the mat.pdf
________ ANOVA relies on matched samples in a similar way to the mat.pdf________ ANOVA relies on matched samples in a similar way to the mat.pdf
________ ANOVA relies on matched samples in a similar way to the mat.pdf
 
Write a program that converts an infix expression into an equivalent.pdf
Write a program that converts an infix expression into an equivalent.pdfWrite a program that converts an infix expression into an equivalent.pdf
Write a program that converts an infix expression into an equivalent.pdf
 
Which microtubule (MT) population binds to chromosomes during mitosi.pdf
Which microtubule (MT) population binds to chromosomes during mitosi.pdfWhich microtubule (MT) population binds to chromosomes during mitosi.pdf
Which microtubule (MT) population binds to chromosomes during mitosi.pdf
 
React to the following statement Knowledge is the technology wh.pdf
React to the following statement Knowledge is the technology wh.pdfReact to the following statement Knowledge is the technology wh.pdf
React to the following statement Knowledge is the technology wh.pdf
 
what animals first evolved true skeletonswhat animals first .pdf
what animals first evolved true skeletonswhat animals first .pdfwhat animals first evolved true skeletonswhat animals first .pdf
what animals first evolved true skeletonswhat animals first .pdf
 
true or false Different parts of the genome evolve at different spe.pdf
true or false Different parts of the genome evolve at different spe.pdftrue or false Different parts of the genome evolve at different spe.pdf
true or false Different parts of the genome evolve at different spe.pdf
 
The brightness in the center of a Fresnel diffraction pattern. Is al.pdf
The brightness in the center of a Fresnel diffraction pattern.  Is al.pdfThe brightness in the center of a Fresnel diffraction pattern.  Is al.pdf
The brightness in the center of a Fresnel diffraction pattern. Is al.pdf
 
Should Linda’s history of past improprieties lead Maria to withdraw .pdf
Should Linda’s history of past improprieties lead Maria to withdraw .pdfShould Linda’s history of past improprieties lead Maria to withdraw .pdf
Should Linda’s history of past improprieties lead Maria to withdraw .pdf
 
Problem 4.Organisms are present in ballast water discharged from a.pdf
Problem 4.Organisms are present in ballast water discharged from a.pdfProblem 4.Organisms are present in ballast water discharged from a.pdf
Problem 4.Organisms are present in ballast water discharged from a.pdf
 
Q2. Does Application Engine Generate SQLs like Query ManagerQ7. C.pdf
Q2. Does Application Engine Generate SQLs like Query ManagerQ7. C.pdfQ2. Does Application Engine Generate SQLs like Query ManagerQ7. C.pdf
Q2. Does Application Engine Generate SQLs like Query ManagerQ7. C.pdf
 
QUESTION 6- Delay spread of optical pulses results on multimode fibe.pdf
QUESTION 6- Delay spread of optical pulses results on multimode fibe.pdfQUESTION 6- Delay spread of optical pulses results on multimode fibe.pdf
QUESTION 6- Delay spread of optical pulses results on multimode fibe.pdf
 
31.A Biased sample is one that ______a. Is too smallb. Will al.pdf
31.A Biased sample is one that ______a. Is too smallb. Will al.pdf31.A Biased sample is one that ______a. Is too smallb. Will al.pdf
31.A Biased sample is one that ______a. Is too smallb. Will al.pdf
 
Please help me Im very confused thanks Find sin 2x, cos 2x, and tan .pdf
Please help me Im very confused thanks Find sin 2x, cos 2x, and tan .pdfPlease help me Im very confused thanks Find sin 2x, cos 2x, and tan .pdf
Please help me Im very confused thanks Find sin 2x, cos 2x, and tan .pdf
 
please explain in detail What is the PCAOB Please explain what is t.pdf
please explain in detail What is the PCAOB Please explain what is t.pdfplease explain in detail What is the PCAOB Please explain what is t.pdf
please explain in detail What is the PCAOB Please explain what is t.pdf
 

Recently uploaded

8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital ManagementMBA Assignment Experts
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppCeline George
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSean M. Fox
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxAdelaideRefugio
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxneillewis46
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptxPoojaSen20
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxMarlene Maheu
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi RajagopalEADTU
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismDabee Kamal
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...EADTU
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17Celine George
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint23600690
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文中 央社
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSAnaAcapella
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...Nguyen Thanh Tu Collection
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....Ritu480198
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code ExamplesPeter Brusilovsky
 

Recently uploaded (20)

8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 

Write a Java program that mimics the framework for an online movie i.pdf

  • 1. Write a Java program that mimics the framework for an online movie information system similar to IMDB written in Java. Create an abstract base class, two subclasses, and one interface to provide basic functionality for the system. Use the provided UML, the class descriptions, and the test output to determine the proper behavior for your classes. Create an interface Rateable that: Provides a method vote(int numVotes, int voteScore). Create an abstract class Movie that: Implements the Rateable and Comparable interfaces. Provides the data fields: title, releaseYear, genre, numVotes, and voteScore. Provides four constructors: o Default, no-arg constructor o Three convenience constructors that allow as parameters: the title the title and releaseYear the title, releaseYear, and genre. Provides an abstract getInfo() method. Provides a concrete toString() method that returns the only movie title. Provides a concrete getRating() method that returns: o -1 if numVotes is 0, o voteScore/numVotes otherwise. Implements the Rateable interface’s vote() method by increasing the existing values of numVotes and voteScore by the amount passed in the appropriate parameter. Implements the Comparable interface’s compareTo() method by comparing ratings. Movies should be sorted in descending order, meaning that a higher rating should be considered “less than” a lower rating. Create a concrete class Horror that: Automatically sets the genre to Horror in its constructors. Adds a data attribute for number of deaths, numOfDeaths, with the appropriate getter/setter methods. 2 Provides a getInfo() method that returns “title, genre, releaseYear (rating): numDeaths deaths” with the appropriate values. o Detects if it receives a -1 from getRating() and uses “No ratings” as the rating. o To pass LiveLab’s auto-grader, make sure ratings are limited to one decimal place (see documentation on using String.format() which works similar to System.out.printf()). Create a concrete class Comedy that: Automatically sets the genre to Comedy in its constructors. Adds a data attribute, hasProfanity, to indicate whether there is profanity in the film with the appropriate getter/setter methods. Provides a getInfo() method that returns “title, genre, releaseYear (rating): Profanity/No Profanity” with the appropriate values. o Detects if it receives a -1 from getRating() and use “No ratings” as the rating. o To pass LiveLab’s auto- grader, make sure ratings are limited to one decimal place (see documentation on using
  • 2. String.format() which works similar to System.out.printf()). NOTE: Movie, Horror, and Comedy should provide all of the appropriate accessor/mutator methods for their data fields. For brevity, these are not included in the UML. Main method Create the horror movies: o A Nightmare on Elm Street, 1984, 4 deaths o Final Destination 5, 2011, 94 deaths1 o Saw, 2004, 6 deaths Create the comedy movies: o Napoleon Dynamite, 2004, no profanity o Keeping Up with the Joneses, 2016, profanity o Uncle Buck, 1989, profanity Use the vote() method to assign votes to the respective movies: (# votes - total vote score) o A Nightmare on Elm Street: 151,963 – 1,139,723 o Final Destination 5: 84,907 – 500,951 o Saw: 303,578 – 2,337,551 o Napoleon Dynamite: 163,240 – 1,126,356 o Uncle Buck: 64,031 – 448,217 Create an Array of type Movie and populate it with all of the created movies. Do not create them in sorted order, let the sort method handle that. Sort the array using the java.util.Arrays.sort() method. Using a loop, print the results of the getInfo() call for each movies in the sorted array. 1 http://finaldestination.wikia.com/wiki/List_of_deaths 3 Simplified UML Test Output Saw, Horror, 2004 (7.7): 6 deaths A Nightmare on Elm Street, Horror, 1984 (7.5): 4 deaths Napoleon Dynamite, Comedy, 2004 (6.9): No Profanity Uncle Buck, Comedy, 1989 (6.9): Profanity Final Destination 5, Horror, 2011 (5.9): 94 deaths Keeping Up with the Joneses, Comedy, 2016 (No ratings): Profanity Solution PROGRAM CODE: Rateable.java package movies; public interface Rateable {
  • 3. //abstract method for the rateable class public void vote(int numVotes, int voteScore); } Movie.java package movies; public abstract class Movie implements Rateable, Comparable{ // Data fields for the class String title; int releaseYear; String genre; int numVotes; int voteScore; // Default constructor Movie() { title = ""; genre = ""; } //Parameterized Constructors Movie(String title) { this.title = title; } Movie(String title, int releaseYear) { this.title = title; this.releaseYear = releaseYear; } Movie(String title, int releaseYear, String genre) { this.title = title; this.releaseYear = releaseYear; this.genre = genre;
  • 4. } //setters and getters public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public int getReleaseYear() { return releaseYear; } public void setReleaseYear(int releaseYear) { this.releaseYear = releaseYear; } public String getGenre() { return genre; } public void setGenre(String genre) { this.genre = genre; } public int getNumVotes() { return numVotes; } public void setNumVotes(int numVotes) { this.numVotes = numVotes; } public int getVoteScore() { return voteScore; } public void setVoteScore(int voteScore) { this.voteScore = voteScore; } // abstract method public abstract String getInfo();
  • 5. // toString() to return the movie title public String toString() { return this.title; } //getRating() method to calculate rating public int getRating() { if(this.numVotes > 0) return -1; else return this.voteScore/numVotes; } // method to define from Comparable interface @Override public int compareTo(Movie movie) { if(this.getRating() == movie.getRating()) return 0; else if(this.getRating() > movie.getRating()) return 1; else return -1; } //method to define from Rateable interface @Override public void vote(int numVotes, int voteScore) { this.numVotes = numVotes; this.voteScore = voteScore; } } Horror.java package movies;
  • 6. public class Horror extends Movie{ int numOfDeaths; String genre; //Setting the genre to Horror in default comstructor public Horror() { this.genre = "Horror"; } //setter and getter public int getNumOfDeaths() { return numOfDeaths; } public void setNumOfDeaths(int numOfDeaths) { this.numOfDeaths = numOfDeaths; } // Implementing the abstract method public String getInfo() { String rating = this.getRating() < 0? "No ratings": String.valueOf(this.getRating()); return this.title + "," + this.genre + "," + this.releaseYear + "(" + rating + "):" + this.numOfDeaths +"deaths"; } } Comedy.java package movies; public class Comedy extends Movie{ boolean hasProfanity; //Setters and getters public boolean isHasProfanity() { return hasProfanity;
  • 7. } public void setHasProfanity(boolean hasProfanity) { this.hasProfanity = hasProfanity; } public Comedy() { this.genre = "Comedy"; } @Override public String getInfo() { String rating = this.getRating() < 0? "No ratings": String.valueOf(this.getRating()); // using ternary operator to check if value is less than 0 String profanity = this.hasProfanity? "Profanity" : "No Profanity"; // using ternary operator to check if profanity is true or false and setting string value based on that return this.title + "," + this.genre + "," + this.releaseYear + "(" + rating + "):" + profanity; } } MainClass.java package movies; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import javax.sound.midi.ControllerEventListener; public class MainClass { public static void main(String[] args) { //creating objects for Horror and Comedy and adding data Horror horror = new Horror(); horror.setTitle("A Nightmare on Elm Street"); horror.setReleaseYear(1984); horror.setNumOfDeaths(4);
  • 8. Horror horror2 = new Horror(); horror2.setTitle("Final Destination 5"); horror2.setReleaseYear(2011); horror2.setNumOfDeaths(94); Horror horror3= new Horror(); horror3.setTitle("Saw"); horror3.setReleaseYear(2004); horror3.setNumOfDeaths(6); Comedy comedy1 = new Comedy(); comedy1.setTitle("Napolean Dynamite"); comedy1.setReleaseYear(2004); comedy1.setHasProfanity(false); Comedy comedy2 = new Comedy(); comedy2.setTitle("Keeping Up with the Joneses"); comedy2.setReleaseYear(2016); comedy2.setHasProfanity(true); Comedy comedy3 = new Comedy(); comedy3.setTitle("Uncle Buck"); comedy3.setReleaseYear(1989); comedy3.setHasProfanity(true); horror.vote(151963, 1139723); horror2.vote(84907, 500951); horror3.vote(303578, 2337551); comedy1.vote(163240, 1126356); comedy3.vote(64031, 448217); //creating an arraylist and adding all the movies into it ArrayList movieList = new ArrayList<>(); movieList.add(horror); movieList.add(horror2); movieList.add(horror3); movieList.add(comedy1);
  • 9. movieList.add(comedy2); movieList.add(comedy3); //creating an arraylist and adding all the movies into it Movie[] movies = new Movie[6]; movies[0] = horror; movies[1] = horror2; movies[2] = horror3; movies[3] = comedy1; movies[4] = comedy2; movies[5] = comedy3; //Sorting the arraylist Arrays.sort(movies); //printing the arrays for(int i=0; i