Question
Create a public class Movie in java with private instance variables String title and int year. The class should declare that it implements the Comparable
Create a public class Movie in java with private instance variables String title and int year. The class should declare that it implements the Comparable
Methods getTitle() and getYear() that do the right thing. An equals() method that is compatible with the method that satisfies the Comparable
A public static method getTestMovies(), which returns an array of 10 unique Movie instances. They dont have to be real movies its ok to make them up. The 0th and 1st array elements must be 2 movies with the same title but from different years (e.g. The Thomas Crown Affair 1968 and The Thomas Crown Affair 1999, or True Grit 1969 and True Grit 2010). The 2nd and 3rd elements (counting from 0) must be 2 movies with different titles but from the same year (e.g. The Martian 2015 and Bridge of Spies 2015). The 4th and 5th elements must be 2 different objects that represent the same movie (same title and same year). A hashCode() method. Use the following: public int hashCode() { return title.hashCode() + year; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started