Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA PROGRAMMING. Please only answer if you can do the ENTIRE problem. Program MUST compile and have SCREENSHOTS of outputs so I can give you

JAVA PROGRAMMING. Please only answer if you can do the ENTIRE problem. Program MUST compile and have SCREENSHOTS of outputs so I can give you a thumbs up :-)

Youve been hired by Library Lenders to write a Java console application that shows the borrowing status of several items. The application has the following four classes:

Medium.java

This abstract class implements Serializable and represents a medium in the library inventory and includes:

Fields

- (constant) VERSION the version of this application.

Abstract methods

String getTitle()

int getDaysOverdue()

double calculateFine()

ElectronicMedium.java

This class extends Medium and represents one electronic item in the library inventory and includes:

Fields

- (static) count count of all distinct electronic media; initialize to 0 in declaration.

- title

- daysOverdue

A constructor with no parameters that sets the fields, respectively, to these values:

count = count + 1

title = "(not set)"

daysOverdue = 0

A constructor with two parameters that sets the fields, respectively, to these values:

count = count + 1

title set from parameter

daysOverdue set from parameter

Getter methods for each field (declare getCount static; prefix the returned title with (E) in getTitle).

Setter methods for each field (declare setCount static).

Override calculateFine to return 0 if daysOverdue <= 0, otherwise return daysOverdue * 0.75.

equals method that compares titles from two objects for equality.

toString method for returning instance variable values only.

PrintMedium.java

This class extends Medium and represents one print item in the library inventory and includes:

Fields

- (static) count count of all distinct print media; initialize to 0 in declaration.

- title

- daysOverdue

A constructor with no parameters that sets the fields, respectively, to these values:

count = count + 1

title = "(not set)"

daysOverdue = 0

A constructor with two parameters that sets the fields, respectively, to these values:

count = count + 1

title set from parameter

daysOverdue set from parameter

Getter methods for each field (declare getCount static; prefix the returned title with (P) in getTitle).

Setter methods for each field (declare setCount static).

Override calculateFine to return 0 if daysOverdue <= 0, otherwise return daysOverdue * 0.5.

equals method that compares titles from two objects for equality.

toString method for returning instance variable values only.

HW6.java

This class contains the main method and uses the other classes to show the borrowing status. Include the application version from Medium.java in the welcome message in the console output. Create text file MediumStatusIn.txt, paste the following data into it, and place the file in your project folder. It has the following columns:

1) Medium type E for electronic medium, P for print medium.

2) Medium title

3) Days overdue negative number means not overdue; positive number means overdue.

MediumStatusIn.txt

P The Atlas of Forgotten Places -10

E The Lost City of Z -9

P Beloved Hope -4

P Hum If You Don't Know the Words 12

E The Client -6

P Ballplayer Jones 5

E A Dog's Purpose 16

E The Great Wall -3

P Mercy Falls -7

E Romeo and Juliet -7

Create and call a method called readTextFile to read the data from file MediumStatusIn.txt into an array list of Medium objects called media. Create and call a method called printMediaStatus to show the following for each medium:

Title

Days overdue

Fine calculated fine of zero or greater.

Also, show the counts of electronic and print items. Create and call a method called writeObjectFile to write the ten objects to file MediumStatusOut.obj.

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

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions