Question: Implement the class Media, which stores information about rentable media. Derive Video which is subclass of Media . The Media class represents the media which

  1. Implement the class Media, which stores information about rentable media.
  2. Derive Video which is subclass of Media.

The Media class represents the media which is rented.

class will need to implement the following:

  • 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) indicates whether this media is the other media which is passed in as a parameter.
  • @Override public int hashCode() one of Java's unenforced requirements is that if we ever override an equals method, we must also override hashCode such that if two object are equal, they also have the same hash code. It is sufficent for this method to return getName().hashCode().
  • @Override public String toString() displays information about the media as a string, in the format "NAME (YEAR)".The Imitation Game (2014)

Video Task: public class Video extends Media.

This class should provide the following:

  • public static final int DVD = 0;
  • public static final int BLURAY = 1;
  • public Video(String name, int year, int runtime, String rating, int format) a constructor which initializes the movie with the provided name, publication year, runtime in minutes, rating, and format (DVD or BLURAY).
  • public int getRuntime() retrieves the stored runtime.
  • public String getRating() retrieves the stored rating.
  • public int getFormat() retrieves the stored disc format.
  • @Override public String toString() displays information about the video as a string, in the format "NAME (YEAR) FORMAT [RATING, RUNTIME min]". Print the format as either DVD or BLURAY. For example:

    The Imitation Game (2014) DVD [PG-13, 114 min]

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!