Question: For this java problem, use the below UML diagram to create a class called Book. A Book has a title, and a year of publication.
For this java problem, use the below UML diagram to create a class called Book. A Book has a title, and a year of publication. It has a constructor that will set both attributes, get and set methods for both attributes, and a method called howOld that will return how many years it has been since the book was written. Note: subtract the year of publication from 2019.
Then, create a demo class that contains the main method, and create the following two Book objects.
b1 (title - Moby Smith, year - 1851) b2 (title - A Handmaid's Tale, year 1985)
Details
Youre going to have two classes this time around. Class names: Book and BookDemo
Output
Sample output: Moby Smith is 168 years old A Handmaids Tale is 34 years old
Book title: String - year: int + Bbok (t : string, yr : int) + getTitle () : string +getYear (): int + setTitle (t : string ) : void + setYear (yt int) : void +howold () : intStep by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
