Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 1: Write a java class Book which has the following variables: counter: A common variable to all Book's instances, counter's initial value is 0.

image text in transcribed

Part 1: Write a java class Book which has the following variables: counter: A common variable to all Book's instances, counter's initial value is 0. title: The book title; once it is set, it can't be changed. The default title is "Generic Book". numAvailableCopies: Number of available copies of the book. This variable default initial value is 1. isAvailable: A boolean variable that becomes true if numAvailableCopies > 0, and false otherwise. Add the following methods to the Book class: Overloaded constructors: 1. A no-argument constructor that initializes instance variables to their default valu 2. A constructor that receives two parameters (title, numAvailableCopies) and sets isAvailable accordingly. hint: both constructors must consider counter and isAvailable variables. getTitle, getNumAvailableCopies: Get methods for corresponding instance variables. setNumAvailableCopies: Receives an integer parameter to update numAvailableCopies. isAvailable must be updated accordingly. toString: Returns a string composed from book title, number of available copies and book availability. Part 2: Write a driver class Library with a main method that does the following (in the specified order): 1. Instansiate 1 object of class Book using the default no-argument constructor. 2. Instansiate 2 objects of class Book using the predefined variables (bookTitlei, numCopiesi, bookTitle2, numCopies2). 3. Use method toString to print booki, book2 and book3 information. 4. Update book3 number of available copies to 0. 5. Use method toString to print book3 information. 6. Print the total number of books entered in the system (not the number of available copies)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual C# And Databases

Authors: Philip Conrod, Lou Tylee

16th Edition

1951077083, 978-1951077082

More Books

Students also viewed these Databases questions

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago