Question: JAVA OOP (b) The code below violates the rule on encapsulation. Re-write class libraryBook so that encapsulation is preserved. Class Book private String title private
JAVA OOP

(b) The code below violates the rule on encapsulation. Re-write class libraryBook so that encapsulation is preserved. Class Book private String title private int publishYear public Book (String title, double publishYear) { this.title = title; this.publishYear = publishYear } public String get Title(){return title:} public int getPublishYear ({return publishYear:} public void set Title(String title){this. title = title;} public void setPublishYear (int publishYear) { this.publishYear = publishYear: } } class libraryBook { private Book book: private String catalogue; public libraryBook (Book book, String catalogue this book = book; this.catalogue = catalogue; } public Book getBook(){return book:} public String getCatalogue ({return catalogue;} }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
