Question: available _ copies: int book _ copies: int total _ available _ books: static int Book ( title : String, author : String, book _

available_copies: int
book_copies: int
total_available_books: static int
Book( title : String, author : String, book_copies : int )
borrow_book (): void
return_book (): void
set_author(String author): void
get_title (): String
get_author (): String
get_available_copies () : int
get_book_copies () : int
get_borrowed_copies (): int
Attributes:
title: String (Title of the book)
author: String (Author of the book)
available_copies: int (Number of available copies of the book in the library, including only the unborrowed book)
book_copies: int (Number of copies of the book in the library or with borrowers, including the borrowed and unborrowed book)
total_available_books: static int (Number of all the currently available copies of unborrowed books)
Methods:
Book(title: String, author: String, book_copies: 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: total_available_books.
borrow_book(): Decrements the available_copies by 1 when a book is borrowed. This method should update the static variable: total_available_books.
return_book(): Increments the available_copies by 1 when a book is returned. This method should update the static variable: total_available_books.
set_author(author: String): sets the author's name of the book.
get_title(): Returns the title of the book.
get_author(): Returns the author of the book.
get_available_copies(): Returns the number of available copies.
get_book_copies(): Returns the total number of copies (including borrowed and unborrowed).
get_borrowed_copies(): Returns the number of borrowed copies.
1- In Book Class, Write the code for the constructor described in the methods list
Book(title: String, author: String, book_copies: 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: total_available_books by adding the book_copies to it.
2- In Book Class, Write the code for the method get_borrowed_copies
3- In Book Class, Write the code for the method borrow: The method decrements the available_copies by 1 if it is greater than 0. This method should also update the static variable: total_available_books after borrowing one book [1.5 pt].
4- In the Main Class
a.[1 pt] Create 2 Book objects as the following:
\table[[title,author,book_copies],[Intro to Java,Ahmed Khalid,10],[Data Structure,Tom John,8]]
b.[1 pt] Borrow 2 books from the first book "Into to Java".
c.[1 pt] Print the title, author, book_copies, and available_copies of the first book.
d.[0.5 pt] Print the total_books.
 available_copies: int book_copies: int total_available_books: static int Book( title : String,

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!