Question
Please use Java Script! PP In this programming exercise, we are going to add a few methods to DVD example covered in the class. In
Please use Java Script! PP In this programming exercise, we are going to add a few methods to DVD example covered in the class.
In the DVD class, add a getter method getTitle to return the title of DVD.
In the DVDCollection class, add a method findDVD to search a particular DVD title searchTitle. If searchTitle matches the title of a DVD in the collection, return its index value in the DVD array; otherwise return -1.
In the Movies class, add the following three statements at the end of the main method.
System.out.println("Iron Man is at index " + movies.findDVD("Iron Man"));
System.out.println("Iron Man 2 is at index " + movies.findDVD("Iron Man 2"));
System.out.println("Iron Man 3 is at index " + movies.findDVD("Iron Man 3"));
If your implementation is correct, you should expect to see the following output.
Hint: Use a for loop to go through the DVD array to look for the searchTitle. You may find the String method equals useful to compare the contents of two strings s1 and s2: s1.equals(s2). This exercise is very useful for your individual assignment 3.
|
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