Question: This is java problem this is the code: /////////////////////////////MOVIE.JAVA| public class Movie /* */ { /** The title of the Movie represented by this class.

This is java problem

This is java problem this is the code: /////////////////////////////MOVIE.JAVA|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ public class Movie

this is the code:

/////////////////////////////MOVIE.JAVA|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

public class Movie /* */

{

/** The title of the Movie represented by this class. */

private String title;

/** The release date of the movie. */

private int year;

/**

* This is the default constructor for the class Movie.

*/

public Movie()

{

year = 0;

title = "";

}

/**

* This is the constructor for the class Movie.

* It instantiates the class with user supplied values.

*

* @param title The title of the movie.

* @param year The release date of the movie.

*/

public Movie(String title, int year)

{

this.title = new String( title );

this.year = year;

}

/**

* Returns the title of the movie.

*

* @return The title of the movie as a string.

*/

public String getName()

{

return title;

}

/**

* This method returns the attributes of this movie as

* a single string.

*

* @return String representing the

* contents of this object.

*/

public String toString()

{

// Add the code for toString() here.

return Integer.toString(year); // Make sure you replace

// this return statement.

}

/**

* This method compares an instance of Movie with

* this instance of Movie to see if they are equal.

*

* Algorithm:

* ????

*

* @param obj The object we are comparing

* this instance of Movie with.

* @return Returns true if the two instances are

* equal, false otherwise.

*/

public boolean equals( Object obj )

{

// Add the code for equals() here.

return true; // Make sure you replace this return statement.

}

/**

* This method compares an instance of Movie with

* this instance of Movie to determine their relationship.

*

* Algorithm:

* ????

*

* @param other The object we are comparing

* this instanceof Movie with.

* @return ?????????

*/

public int compareTo( Object obj )

{

// Add the code for compareTo() here.

return (int)year; // Make sure you replace this

// return statement.

}

}

Step 1: Complete the implementation of the movie class. Make sure you fill in the class and method header comments and declarations where information is missing. First, read the entire Movie.java file. After reading the file, add code to complete the implementation of the tostring), equals), and compareTo () methods. Before you can search a List for an item, you must sort the List by calling the sort ) method of the Collections class. This method will call the compareTo method of each item that is present in the List. Sample code that uses sort 0 to sort a list is given below List myList new ArrayListo myList.add ( new Person (. ) ), Collectons.sort (myList In order to search a List to find a particular object you must call the binarysearch ) method of the Collections class. This method takes as a parameter an object (called the key) that represents the object we are searching for. If binarysearch ) finds the key in the list, it will return the index to the item in the list that matches the key, otherwise it will return a negative integer (we talked about how this negative integer is computed in class). Sample code that uses binarysearch ) to search for an item in a list is given below Person key = new Person( ); Person result int index; index = collections.binarysearch ( myList, key ), if( index> index "in the list." else t list!" result = List.get( index ); system.out.println( result.tostring) + " resides at index "+ System.out.println( key.tostring () was not found in the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!