Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 interface, and should provide the following: A constructor that takes 2 arguments: a String and an int (in that order) for initializing title and year. A method that satisfies the Comparable interface. Movies should be compared first by title and then by year.

Methods getTitle() and getYear() that do the right thing. An equals() method that is compatible with the method that satisfies the Comparable interface. A toString() method that prints Movie followed by 1 space followed by the title followed by 1 space followed by open-parenthesis followed by the year followed by close-parenthesis. Example: Movie The Maltese Falcon (1941)

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

101 Database Exercises Text Workbook

Authors: McGraw-Hill

2nd Edition

0028007484, 978-0028007489

Students also viewed these Databases questions

Question

dy dx Find the derivative of the function y=(4x+3)5(2x+1)2.

Answered: 1 week ago

Question

Draw and explain the operation of LVDT for pressure measurement

Answered: 1 week ago

Question

2. Identify and choose outcomes to evaluate a training program.

Answered: 1 week ago

Question

6. Conduct a cost-benefit analysis for a training program.

Answered: 1 week ago