Question
JAVA Exercise 2: Book and Author Class (40 points) Please develop a class called Book that represents a book, and another class called Author. The
JAVA
Exercise 2: Book and Author Class (40 points) Please develop a class called Book that represents a book, and another class called Author. The Book class represents the properties of a typical hardbound book, which consists of the following private attributes: (1) int - number of pages in the book; (2) int - year the book was published; (3) double - price of the book in USD; (4) String - title of the book; (5) Author an object representing the author of the book (we assume a book has only one author for this exercise).The Author class consists of the following private attributes: (1) String - first name of author; (2) String last name of author; (3) int birth year of author; (4) int number of publications the author has.Develop appropriate accessor / mutator methods for all attributes in these classes as well as default, parameterized, and copy constructors. For the Book class, you need to override the toString() method, which prints out all of the information of a Book object including the details of the author. (Note: when writing the setAuthor() method for the author field (attribute), you will need to pass in the appropriate fields so the Author object can be constructed.) (20 points) Please test your implementation of Book and Author class using a tester class named Ex2. The main method in class Ex2 starts your Java program. The main method should also contain code that illustrates the following functionality: (1) construct a Book object using the default constructor; (2) set the appropriate fields using the Books mutator(setter) methods; (3) print out the Books information (including the Authors information) by calling the Books toString() method; (4) test that your copy constructor works by doing the following - (a) create another book that is a copy of your original Book object using the copy constructor; (b) print out the fields of the copied object to the console and confirm that all of the fields are the same as the original object; (c) change the state of the object by incrementing the number of publications for the Author of the Book; (d) print out the copied object with the updated number of publications. (16 points) Please provide java-doc comments for all member methods and classes that you use in your code. (4 points)
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