Question: Given the following class, how would you make it immutable, Re-write it by making the necessary changes. public class Movie ( (b) } public

Given the following class, how would you make it immutable, Re-write it by making the necessary changes.

Given the following class, how would you make it immutable, Re-write it by making the necessary changes. public class Movie ( (b) } public String title; public String director; public int runTime; public Movie (String title, String director, int runTime) { } this.title= title; this.director director; this.runTime = runTime; public int calculateExtendedRuntime (int time) ( runTime += time; return runTime; (8 marks)

Step by Step Solution

3.39 Rating (161 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To make the Movie class immutable you need to ensure that its state cannot be changed after it is constructed To accomplish this you should 1 Make all ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!