Question
For this activity, you will model a book in java. To do this, you will create a class called Book. A book will have the
For this activity, you will model a book in java. To do this, you will create a class called Book. A book will have the following properties:
- Book title
- Author name
- Number of pages
- Date published
- Publisher name
Incorporate information hiding when it comes to your instance variables. This means, Main.java should not have access to them directly. Create getters and setters for each instance variable.
You will also have a Main.java class. In this class, from main(), you will create 3 books. For each book, set each each instance variable (as mentioned above) using the set functions available. Then, print out each book's details (their instance variables).
Use real books for values to fill in the instance variables with. You can use the book for this class for one of your book object as a n example.
NOTE: do not create a custom constructor. Do not use toString().
Sample Runs
Sample Program Run (1 book shown. Print out 3 total)
Book 1:
Book Name: Fahrenheit 451
Author Name: Ray Bradbury
Number of pages: 256
Date Published: October 19, 1953
Publisher Name: Ballantine Books
Rubric
- Book.java contains all instance variables, and incorporates information hiding principles. (2 pts)
- Setters and getters created properly. (3 pts)
- 3 book objects created in Main. (2 pts)
- Values from book objects are set and printed out correctly. (2 pts)
In Java PLEASE
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