Question: Problem 1 . You should implement the Classes as described in the figure on the left. LibraryItem is the superclass. Each LibraryItem has a unique

Problem 1. Problem 1. You should implement the Classes as described in the figure

You should implement the Classes as described in the figure on the left.

LibraryItem is the superclass. Each LibraryItem has a unique serial number, a name, a type, and a loan_period. The type can be Movies or Books.

Movie and Book are subclasses of LibraryItem. Novel is a subclass of Book. Loan period of 7 days for Movie, 14 days for Novel, and 30 days for Book.

Skeleton codes are provided for LibraryItem, Book, Novel, and Movie.

The LibraryDemo code will test your designs and implementations. You should NOT modify LibraryDemo.

An expected output of the test code is provided here:

on the left. LibraryItem is the superclass. Each LibraryItem has a unique

Skeleton Codes below

Library Item

serial number, a name, a type, and a loan_period. The type can

Movie

be Movies or Books. Movie and Book are subclasses of LibraryItem. Novel

Book

is a subclass of Book. Loan period of 7 days for Movie,

Novel

14 days for Novel, and 30 days for Book. Skeleton codes are

Library Demo

provided for LibraryItem, Book, Novel, and Movie. The LibraryDemo code will test

LibraryDemo

your designs and implementations. You should NOT modify LibraryDemo. An expected output

> Libraryltem Book Movie LibraryDemo Novel Big Java; Books; No. 1001; 0an period 30 God Father; Movies; No.1002; loan period 7 Harry Potter; Books; No.1003 stars 5; loan period 14 To Kill a Mocking Bird; Books; No. 1004 stars 3; oan period 14 The ususal suspects; Movies; No.1005; loan period 7 Physics; Books; No.1006; loan period 30 * Each LibraryItem should have the following variables * String name (The name of a LibraryItem instance) * String type (This could be "Books", "Movies" * int loan_period (the number of days that an LibrayItem instance can be borrowed) * int serial_number (Each LibraryItem has a unique serial_number) * These variables cannot be declared as "public" public abstract class LibraryItem /Your code here to declare the variables //None of the variables can be public public LibraryItem(String name_, String type.) //Your code here public abstract int getLoanPeriod); 1/ do not change this line /7 You can add other necessary methods here * Movie should be subclass of LibraryItem * A Movie should have4 a loan_period of 7 days ublic class Movie public Movie(String name_) //Your code here // Your codes here for other necessary methods public String toString() // This method should return name of the Movie, serial number, loan period /your code here * Book should be a subclass of LibraryItem * A book should have a loan_period of 30 days. public class Book public Book (String name_) / Your code here I Your codes here for othe necessary methods public String toString() // your code to return name, type, serial number, loan period Novel is a subclass of Book *A Novel should have a loan_period of 14 days A Novel also has a variable of number_of stars_rating public class Novel private int number-of-stars-rating = ; // Do not change this line public Novel String name) //your code here // Your codes here for other necessary methods public String toString() 1 // this method should return name, number of stars, and loan period of the Novel //your code here *Each LibraryItem should have the following variables * String name (The name of a LibraryItem instance) * String type (This could be "Books", "Movies") * int loan_period (the number of days that an LibrayItem instance can be borrowed) * int serial number (Each LibraryItem has a unique serial_number) * These variables cannot be declared as "public" public abstract class LibraryItem //Your code here to declare the variables /None of the variables can be public public LibraryItem(String name_, String type.) //Your code here public abstract int getLoanPeriod(); // do not change this line dO: // You can add other necessary methods here * This is a testing script. Do NOT modify the codes here. public class LibraryDemo public static void main(String[] args) LibraryItem[] lib - new LibraryItem[6]: Library!tem book new Book("B LibraryItem movie - new_ Movie("God Father"); LibraryItem novel - new Novel("Harry Potter"; h.set_star_ratings(5); lib[2] - h; LibraryItem novelnew Nov t.set_star_ratings (3); LibraryItem movienew Movie("The ususal suspects"; LibraryItem book -_new_Book ("Physics"): for ( int i = 0; 1

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!