Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Lab: Please look at the bullet points carefully as some of the questions posted over here are similar but this one is different and

Java Lab:

Please look at the bullet points carefully as some of the questions posted over here are similar but this one is different and needs to be coded from scratch. Thank you

Create the following class hierarchy:

  • MusicMedia
    • An abstract class with fields for music title and artist.
    • Constructor that takes parameters to set both fields. Parameters must be validated appropriately before they are assigned to the fields. If either parameter is invalid throw an IllegalArgumentException and exit the program.
    • Getter and setter for each field
    • toString() to display the field values
    • Abstract method void play()
  • CompactDisc
    • Inherits from MusicMedia
    • Has a field to hold the number of tracks on the CD
    • Constructor takes parameters for title, artist. The number of tracks. The number of tracks should be validated appropriately and an IllegalArgumentException will be thrown if the value is bad.
    • Getter and setter for the number of tracks field
    • toString that will display the number of tracks, title, and artist
    • play() method will display a simple message indicating that the cd is being played.
  • AudioFile
    • Inherits from MusicMedia
    • Fields for the file name and the file size in bytes per second (eg. 320 bps)
    • Constructor with parameters for title, artist, filename, file size. File name and file size must be validated appropriately and an IllegalArgumentException will be thrown if the values are bad.
    • Getters, setters toString
    • play() method will display a simple message indicating that the file is being played.
  • VinylRecord
    • Inherits from MusicMedia
    • Fields for the number of tracks, the size, and the weight in grams
    • Constructor will take parameters for title, artist, number of tracks, size, and weight. Appropriate validations will be done and IllegalArgumentExeptions will be thrown when values are bad.
    • Valid size will be either 12
    • The following are valid weight values; 140g, 180g, 200g
    • Getter, setters, toString
    • play() method will display a simple message indicating that the record is being played.
  • Driver class
    • Will implement main(...)
      • create instance of each subtype and assign the address to a MusicMedia reference
      • display the objects field values
      • call the play() methods

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

The Structure Of The Relational Database Model

Authors: Jan Paredaens ,Paul De Bra ,Marc Gyssens ,Dirk Van Gucht

1st Edition

3642699588, 978-3642699580

More Books

Students also viewed these Databases questions

Question

LO1 Explain how the workforce is changing in unpredicted ways.

Answered: 1 week ago

Question

LO6 List the components of job descriptions.

Answered: 1 week ago