Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I'm working on my comp sci project and when running the JUnit tests, this portion of my code fails in returning the movies that have
I'm working on my comp sci project and when running the JUnit tests, this portion of my code fails in returning the movies that have the same genre. Is there anything that you can notice is wrong in my code? Thanks.
/This method returns an array that contains only Movie objects whose *genre matches the targetGenre passed in *The array returned does not contain any NULL values *This method returns an array of length e if there are no matches *This method may call the getOnlyItems method public Movie[] findMoviesByGenre(String targetGenre)t Movie[ ]result; int count 0; Movie[]movieGenres -getOnlyItems (movies, numMovies); for(Movie movieGenre:movieGenres) if(movieGenre.getGenre().equals(targetGenre)) count++; result -new Movie[count]; int i 0; for(Movie movieGenre:movieGenres)t if(movieGenre.getGenre() .equals (targetGenre)) result[i]movieGenre; return result
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