Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 . Design a Library Management system as follows: a . Define a class name Author It has two instance variables: First name and Last

1. Design a Library Management system as follows:
a. Define a class name Author
It has two instance variables: First name and Last Name
Write the set and get methods
Write the toString method
b. Define a class named Publication
It has four instance variables:
title: the title of the Publication. It is a String value. The title must contain at least 10 characters to be accepted.
publicationDate: an object of class Date (see class LocalDate Appendix) that specifies the date of publication. The year must be greater than 1900 for the date to be accepted.
numberOfAuthors: specifies the number of authors.
authors : an array of authors. Each author is an Author objects.
count: a static attribute used to calculates the number of created Publication objects. You must update count for each newly created object
The class Publication has one constructor with arguments (String title, Author [] a, LocalDate date) that sets the values of the four instance variables to those passed as parameters. LocalDate class defined in the appendix below.
The class Publication has second constructor with arguments (String title, int nbr, LocalDate date) that sets the values of instance variables to those passed as parameters and create the array of authors with nbr authors.
Finally, it defines the toString() method that returns the string in the format author1, author2,...,[title], publicationDate
c. Write a class Book that is derived from Publication.
This class contains one instance variable price, which is a double that specifies the price of the book.
The Book class has a method called compareTo(Book B) that returns -1 if that the Price of the Book B is strictly greater than the Price of the current book, and returns 1 in the opposite case, and 0 is both prices are equal.
d. Create class TestPublication with a main method that produces the following output
Number of created books: 2
Book[0]: (Anis Koubaa),(Basit Qurashi),[Computer Programming],10/10/2010. Price: 220.00
Book[1]: (Mohamed Affendi),[Networking],5/9/2012.
The program must have the following operations:
Create three authors objects named author1 for (Anis Koubaa), author2 for (Basit Qurashi) and author3 for (Mohamed Affendi).
Create an array of authors that contains only two authors author1 and author2
Create an array of authors that contains only one author author3
Create an array books that contains two Book objects, with book attributes are provided in the program output above.
Display the output shown above.

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_2

Step: 3

blur-text-image_3

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

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions