Answered step by step
Verified Expert Solution
Question
1 Approved Answer
5. Implement the Movie class. 6. (a) Add the following public instance variables to the Movie class: An instance variable called title of type
5. Implement the Movie class. 6. (a) Add the following public instance variables to the Movie class: An instance variable called title of type String. An instance variable called director of type String. An instance variable called year of type int. (b) Add the following methods to the Movie class: A void method called readinput that prompts the user for a title, a director, and a year, and initializes the title, director, and year instance variables to those values. A void method called writeOutput that displays the title and director of the movie followed by the year in parentheses. For example, if the title of the movie is Blade Runner, the director is Ridley Scott and the year is 1982, it should display Blade Runner dir. Ridley Scott (1982). Write code in the main method of your main class to test the Movie class: (a) Create a new Movie object. (b) Call the read Input method on the object. (c) Call the writeOutput method on the object. (d) Prompt the user for a new title for the movie. (e) Set the title instance variable to the new title. (f) Call the writeOutput method on the object again. 7. Test your program. The output should look something like this: Enter the title of the movie: Extra Terrestrial Visitors Enter the director of the movie: 8. 9. Juan Piquer Simon Enter the year the movie was released: 1983 Extra Terrestrial Visitors dir. Juan Piquer Simon (1983) Enter a new title: Pod People Pod People dir. Juan Piquer Simon (1983) Modify your program so it uses information hiding. (a) Change all of the public instance variables to private instance variables. (b) Add accessor methods getTitle, getDirector, and get Year that each return the values of the corresponding instance variables. (c) Add a mutator method called setMovie that takes three arguments and uses them to initialize the three instance variables. Modify the main method to test the new methods. (a) Remove the line that sets the title instance variable directly. (b) Use the getDirector and getYear methods to store the director and year in variables. (c) Use the setMovie method to reset the instance variables using the new title, the old director, and the old year. (d) Make sure that you display the movie as you did before. 10. Test your program. The output should look exactly the same as it did before.
Step by Step Solution
★★★★★
3.34 Rating (151 Votes )
There are 3 Steps involved in it
Step: 1
Below is an example Java implementation for the Movie class based on the provided instructions java ...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