Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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. image text in transcribed

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:

image text in transcribed

Skeleton Codes below

Library Item

image text in transcribed

Movie

image text in transcribed

Book

image text in transcribed

Novel

image text in transcribed

Library Demo

image text in transcribed

LibraryDemo

image text in transcribed

> 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

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

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions