
Using an inheritance hierarchy, design a Java program to model items at a library (books, journal articles, videos and CDs.) It is a simplified libray system with limited functionality. Have an abstract superclass called Item and include common information that the library must have for every item (such as unique identification number, and a title). No actual objects of type Item will be created - each actual item will be an object of a (non-abstract) subclass. Place item-typespecific behavior in subclasses (such as a video's year of release, a CD's musical genre, or a book's author). A Assume that titles are unique. Two different objects will have different titles. More in detail: 1. Implement an abstract superclass called Item and define all common operations on this class (constructors, getters, setters, borrowed, returned, toString, etc). Have private data for each item: identification number, title, whether the item is available in the library or not, and the number of available copies. 2. Implement an abstract subclass of Item named WrittenItem and define all common operations on this class. Add private data for author. 3. Implement 2 subclasses of WrittenItem: Book and JournalPaper. 3.1. Class Book: no new private data. When needed, override/overload methods from the 3.2. Class JournalPaper: add private data for year published. When needed, override/overload methods from the superclass. 4. Implement another abstract subclass of Item named MediaItem and define all common operations on this class. Add private data for runtime (double). 5. Implement 2 subclasses of MediaItem: Video and CD. 5.1. Class Video: added private data for director, genre and year released. When needed, override/overload methods from the superclass. 5.2. Class CD: added private data for artist and genre. When needed, override/overload methods from the superclass.
Write the definitions of these classes and a client program showing them in use. Use an ArrayList as the data structure holding the library's collection (for example, 3 books, 4 journal articles, 2 videos and 3CDs). Interact with the user by providing a menu including different options. For example: Option 1:(AddNewItem), Option 2: (BorrowItem), Option 3: (ReturnItem), Option 4: (DisplayAllLibraryItems), Option 5: (exit).
For instance, ask the user to indicate which option they wish to perform, they can respond by number, you read the number and ask questions to fill in the required fields. As an example, if the option is 1, then you ask information on the item to be added (book, Cd, ..), followed by questions to fill in the required fields of that item. Display the updated ArrayList after executing each option.

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 5 images

- JAVA:arrow_forwardWrite a Java program A2p1.java with a public class A2p1 and no named packages to read from stdin information for several singers and dancers. You should design a superclass Person with appropriate constructor(s) to initialize member variables such as name (of type String), sex (of type String) and age (of type int). You should design two additional subclasses Singer and Dancer of the Person class with appropriate constructor(s) to initialize additional member variables such as favorite (of type String). You can add the toString method to these three classes to provide a suitable string representation for objects of these classes. Put all four classes in the same file. A sample run can look like the following (you can also try running it with standard input redirection): [~/temp] $ java A2p1 [kwang@computer] How many persons do you want to input? 3 Enter information for person 1: Name: Tom Sex ('F' or 'M') : M Age: 18 Singer or Dancer ('S' or 'D'): S Favorite song: songl Enter…arrow_forwardJAVA Write an abstract super class encapsulating a vacation: A vacation has one attribute: a destination. It has an overloaded constructor a toString() and an abstract calculate cost method that returns the total cost of each vacation. This class has two non-abstract subclasses: one encapsulating an all-inclusive vacation, and the other encapsulating a vacation bought piece-meal. An all-inclusive vacation has three additional attributes: a brand (for instance ClubMed); a rating, expressed as a number of stars; and a price. In addition an all-inclusive vacation has an overloaded constructor, a toString() and a concrete calculate cost method that returns the total cost of the all-inclusive vacation vacation ( price). A piecemeal vacation has three additional attributes: hotel, meal, airfare as corresponding costs. In addition an all-inclusive vacation has an overloaded constructor, a toString() and a concrete calculate cost method that returns the total cost of the all-inclusive vacation…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





