Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Page Practice Implement this data structure exactly as shown and test it in main: > Copiable > Comparable deepCopy0: Copiable MovieList Movie -title: String -year:

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Page Practice Implement this data structure exactly as shown and test it in main: > Copiable > Comparable deepCopy0: Copiable MovieList Movie -title: String -year: int -list: Movie -count: int SIZE:int UnsortedMovieList +Movie(title: String, year: int) +getTitle(): String +getYear(): int +toString): String +equals(other: Object): boolean +hashCode(: int +compare To(other: Movie): int +deepCopy): Movie rMovieList(size: int) +add(movie: Movie): boolearn +get(index: int): Movie +indexOf(movie: Movie): int +getCount(): int -incrementCount): void +UnsortedMovieList(size: int) +add(movie: Movie): boolean +indexOf(movie: Movie): int +deepCopy(): MovieList Practice MovieList uses a partially-filled array of a set size that is determined by the constructor parameter (not growable) . UnsortedMovieList's add method adds the movie to the end of the array if there is still room and if the same movie (title and year) does not already exist in the array . The get method returns null if the index is out of range . The indexOf method returns -1 if movie doesn't exist The toString method returns: title (year) How to test (in main method): UnsortedMovieList myList = new UnsortedMovieList(12); if (myList.add (new Movie("Home", 2015))) ( System.out.println(myList.get (myList.getCount() 1)); if (myList.add (new Movie("Gravity", 2013))) ( System.out.printlnmyList.get (myList.getCount()1)); Movie walle = new Movie("Wall-e", if (mylist.add(walle)) 2008); System.out.printin(myList.get(myList.getcount() 1)); System.out.printIn(myList.add(new Movie("Home", 2015))? "Home added again": "Home not added again"); System.out.println("Count "myList.getCount ()); System.out.printIn("Wall-e found at #" + myList.indexOf (walle)); Output should be: Home (2015) Gravity (2013) Wall-e (2008) Home not added again Count :# 3 Wall-e found at #2

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

Step: 3

blur-text-image

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

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions

Question

Does being mindful improve health?

Answered: 1 week ago

Question

=+b. Who would the brand be as a famous person?

Answered: 1 week ago