Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

program should be in java . please comment the code. Thanks. public class Media public Media(String name, int year) a constructor which initializes the media

program should be in java .please comment the code. Thanks. public class Media

public Media(String name, int year) a constructor which initializes the media with the provided name and publication year.

  • public String getName() retrieves the stored name of the media.
  • public int getYear() retrieves the stored year of the media.
  • @Override public boolean equals(Object other)
  • @Override public int hashCode()
  • @Override public String toString() displays information about the media as a string, in the format "NAME (YEAR)". For example:

    The Imitation Game (2014)

Payment Task: public class Payment{

  • public Payment(String cardNo, String name, int expMonth, int expYear) initializes the payment method with the provided credit card number, cardholder name, expiration month and expiration year. Behavior for out of bounds dates is not specified - including checks is recommended but will not be tested.
  • public String getCardNo() returns the stored credit card number.
  • public String getName() returns the stored cardholder name.
  • public int getExpMonth() returns the stored expiration month.
  • public int getExpYear() returns the stored expiration year.
  • @Override public String toString() returns a string representation of the payment information in the format "#CARDNUMBER (NAME), exp MONTH/YEAR". For example:

    #0011223344556677 (abc def ), exp 10/2025

public class Rental{

The class should contain the following:

  • public Rental(Media media, Payment payment, LocalDate today, double fee) rents the specified media using the provided payment method, with the rental perod beginning on the provided date, using the specified rental fee. When the object is created, the media is assumed to be rented out.
  • public Media getMedia() retrieves the media which has been rented.
  • public Payment getPayment() retrieves the payment method used to rent the media.
  • public LocalDate getRentDate() retrieves the date on which the media was rented.
  • public double getFee() retrieves the rental fee.
  • public double dropoff(LocalDate today) drops off the video on the current date and reports the total rental fee.
  • public boolean isRented() returns true until the first time that dropoff is called, after which it returns false.
  • public int daysRented(LocalDate today) if the rental has already been returned, then this method will indicate the total number of days that it was rented. Otherwise, this method will report the total number of days from the rental date until the date provided as a parameter.
  • public double getTotalFee(LocalDate today) computes the total fee for the rental. In this case, it simply returns the flat fee which was passed in when the object was created.
  • @Override public String toString() returns information about the rental as a string, in the following format: "MEDIA, rented on DATE using PAYMENT"
  • . For example:

    The Imitation Game (2014) DVD [PG-13, 114 min], rented on 2019-09-15 using #0011223344556677 (abc def), exp 10/2025

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

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions

Question

List four advantages of regression analysis.

Answered: 1 week ago

Question

7. Where Do We Begin?

Answered: 1 week ago