Answered step by step
Verified Expert Solution
Question
1 Approved Answer
available _ copies: int book _ copies: int total _ available _ books: static int Book ( title : String, author : String, book _
availablecopies: int
bookcopies: int
totalavailablebooks: static int
Book title : String, author : String, bookcopies : int
borrowbook : void
returnbook : void
setauthorString author: void
gettitle : String
getauthor : String
getavailablecopies : int
getbookcopies : int
getborrowedcopies : int
Attributes:
title: String Title of the book
author: String Author of the book
availablecopies: int Number of available copies of the book in the library, including only the unborrowed book
bookcopies: int Number of copies of the book in the library or with borrowers, including the borrowed and unborrowed book
totalavailablebooks: static int Number of all the currently available copies of unborrowed books
Methods:
Booktitle: String, author: String, bookcopies: int: Constructor that initializes the book's title, author, and the total number of copies. It should set the available copies initially to the same as total copies. This method should update the static variable: totalavailablebooks.
borrowbook: Decrements the availablecopies by when a book is borrowed. This method should update the static variable: totalavailablebooks.
returnbook: Increments the availablecopies by when a book is returned. This method should update the static variable: totalavailablebooks.
setauthorauthor: String: sets the author's name of the book.
gettitle: Returns the title of the book.
getauthor: Returns the author of the book.
getavailablecopies: Returns the number of available copies.
getbookcopies: Returns the total number of copies including borrowed and unborrowed
getborrowedcopies: Returns the number of borrowed copies.
In Book Class, Write the code for the constructor described in the methods list
Booktitle: String, author: String, bookcopies: int: Constructor that initializes the book's title, author, and the total number of copies. It should also set the available copies initially to the same value as the total copies. This method should also update the static variable: totalavailablebooks by adding the bookcopies to it
In Book Class, Write the code for the method getborrowedcopies
In Book Class, Write the code for the method borrow: The method decrements the availablecopies by if it is greater than This method should also update the static variable: totalavailablebooks after borrowing one book pt
In the Main Class
a pt Create Book objects as the following:
tabletitleauthor,bookcopiesIntro to Java,Ahmed Khalid,Data Structure,Tom John,
b pt Borrow books from the first book "Into to Java".
c pt Print the title, author, bookcopies, and availablecopies of the first book.
d pt Print the totalbooks.
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