Question: 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
Get step-by-step solutions from verified subject matter experts
