Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You need to program a simple book library system. There are three java classes Book.java // book object class Library.java //library class A2.java //for testing
You need to program a simple book library system.
There are three java classes
Book.java // book object class
Library.java //library class
A2.java //for testing
The Book.java class represents book objects which contain the following fields
title: a string which represents the book title.
author: a string to hold the book author name
year: book publication year
isbn: a string of 10 numeric numbers.
The book class will have also 3 constructors.
-The default no argument constructor
- A constructor which takes the title and author names only
-A constructor which takes title, author and,year
For the book class, you need to add all setters and getters methods such as
setTitle / getTitle
setAuthor/getAuthor
setYear/getYear
setISBN/getISBN
finally, define a bookInfo() method which will print the book information in the following format
Book Title: book title
Author(S): author
Publication Year : the year
ISBN : the isbn number
The Library.java class
The library class will have the following fields
- An integer MAXCAPACITY.
which represent the maximum number of book that the library can hold. If the library is full, no more books can be added and a warning message will be displayed.
- capacity which represents the number of the books currently in the library. Every time a new book is added, capacity should be incremented.
- storage
This is basically an array of class book. It can hold only up to maximum capacity books.
- name
a string which will represent the library name. Example Future Library
The library class will have the following methods
Library( String name, int Capacity)
A constructor which will take library name and maximum capacity as input and initialize the library storage and then display a welcoming message indicating the library name and capacity. Example
- Welcome to Future Library
- I can hold upto 100 books.
Class Library methods
- addbook( Book aBook ) will add a book. Each time a new book is added the capacity should be increased by one.
- -search (Book a Book, String title) will search for a book according to its title and will return true if it is in the library and false otherwise.
A2.java is a simple test class where you need to test the implemented code by establishing a library and adding books to it.
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