Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Library class a. The class has three fields name(String),address (String), and books(Array of Book objects). b. Create a constructor that accepts 2 paratemeters (name, and

Library class
a. The class has three fields name(String),address (String), and books(Array of Book objects).
b. Create a constructor that accepts 2 paratemeters (name, and address). Also, in this constructor create the books array.
c. Write 2 accessor methods to return the values of name and address attributes.
d. Write 2 setter methods to change the value of name and address attributes.
e. Build toString() method to return string representation of the fileds name and address.
Book class
f. The class has three fields name(String), pagesNo(int), and ChaptersNo(int).
g. Create a constructor that accepts 3 paratemeters (name, pagesNo, and ChaptersNo).
h. Write 3 accessor methods to return the values of name, pagesNo. and ChaptersNo.attributes.
i. Write 3 setter methods to change the value of name, pagesNo. and ChaptersNo.attributes.
j. Build toString() method to return string representation of all the objects fileds.
k. Write CheckPagesNo( ) that checks the PagesNo of the book object. If the PagesNo >500,
then print the following This book is huge.
Main method
l. Create 2 library objects l1 and l2, add them in an array named Libraries, Using for loop.
m. Create 4 book objects b1,b2, b3 and b4 , using the constructor with 3 parameters.
n. Add the book objects b1 and b2 in the books array in l1 object, and Add the book objects
b3 and b4 in the books array in l2 object.
o. Use for loop to set the values of the fields (name, address) of l1 and l2, using the setter methods you built previousely.
p. Use for loop to set the values of fields (name, pagesNo, and ChaptersNo) of the b1, b2, b3 and b4 objects, using the setter methods you built previousely.
q. Use for loop to check the pagesNo of all book objects stored in the Libraries array, based on the CheckPagesNo() method created above. And print the results.
r. ALSO, use for loop to print the values of all library objects (l1 and l2) fileds(name, address, all fields of its books (books name, books pagesNo , and books ChaptersNo), using the toString() method built previously.
image text in transcribed
Write a java pregram to de the fellowiag prograns: Library class a. The class has three fields name(String), address (Strine), and books/Array of Book objects). b. Create a constructor that accepts 2 paratemeters (name, and address). Alse, in this constructor create the bocks array. c. Write 2 accessor methods to return the values of name and address attributes. d. Write 2 setter methods to change the value of name and address attribusts. e. Build tostring() method to return string representation of the fileds name and address. Beok class f. The class has three fields name(String), pagesNo(int), and ChaptersNo(int)- g. Create a constructor that accepts 3 paratemeters (name, pagesivo, and ChapteriNo). h. Write 3 accessor methods to return the values of name, pagesNo. and ChaptersNo.attributes. i. Write 3 setter methods to change the value of name, pogesNo. and ChaptersNo.attributes. 1. Build tostringi) method to return string representation of all the object' fieds. k. Write CheckPagesNo () that checks the PagesNo of the book object. If the PagesNo >500, then print the following "This book is huge". Main methed I. Create 2 library objects 11 and 12 , add them in an array named Ubraries, Using for loop. m. Create 4 book objects b1,b2, b3 and b4, using the constructor with 3 parameters. n. Add the book objects bl and b2 in the books array in II object, and Add the book objects b3 and b4 in the books arroy in 12 object. o. Use for loop to set the values of the fields (name, address) of II and t2, using the setter methods you bull previousely. p. Use for loop to set the values of fields (name, pagesNo, and ChaptersNo) of the b1, b., b3 and b4 objects, using the setter methods you built previousely. 4. Use for loop to check the pagesNo of all book objects stored in the Lbraries array, based on the CheckPagesNol) method created above. And print the results. r. ALSO, use for loop to print the values of all library' objects fil and I2) fileds(name, address, all fields of its books fbook's name, book's pagesNo, and book's Chapterstol. using the tostringl) method built previously

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

Modern Database Management

Authors: Fred R. McFadden, Jeffrey Slater, Mary B. Prescott

5th Edition

0805360549, 978-0805360547

More Books

Students also viewed these Databases questions

Question

Influences on Nonverbal Communication?

Answered: 1 week ago