Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class Disc { // ***** Instance Variables ***** private String sku; private String title; private float price; private boolean used; // ***** Static Variable

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

public class Disc { // ***** Instance Variables ***** private String sku; private String title; private float price; private boolean used;

// ***** Static Variable ***** private static int count;

// ***** Constructors ***** public Disc() { sku = "00000"; title = "Generic Disc"; price = 0.0f; used = false; }

// ***** Static Methods ***** public static void incrCount() { count++; }

public static int readCount() { return count; }

// ***** Getters and Setters ***** public String getSKU() { return sku; }

public void setSKU(String sku) { this.sku = sku; }

public String getTitle() { return title; }

public void setTitle(String title) { this.title = title; }

public double getPrice() { return price; }

public void setPrice(float price) { this.price = price; }

public boolean getUsed() { return used; }

public void setUsed(boolean u) { used = u; } // To be overriden public String readDiscInfo() { return "If you see this, you haven't followed instructions correctly."; } }

Assignment 2 Download the full Driver class and the partially-created Disc class from Canvas In this assignment, you will add a constructor in the Disc dass and create two subclasses of Disc MovieDVD and Musiccn. After you finish the two subclasses with the required instance variables, constructors, and methods as specified below, run the Driver class. Do not change anything in the Driver class. If you created the subclasses correctly, the Driver class will run as designed and produce the output message bones shown on p. 4. 1. The Disc dass has the following instance variables: Instance Variable Name Data Type Parameter Name in Setter Method & Non- Default Constructor aku Use of Instance Variable SKU number Disc title Unit Price Disc is used new String String float boolean title title price price Add a non-default constructor that takes four parameters as specified in the above table and assigns the parameter value to their respective instance variables. 2. Create a Movie DVD dass and make it a subclass of the Disc class. This class must have the following instance variables: Instance Variable Data Use of Instance Variable Parameter Name in Setter Method & Non- Default Constructor for at Suring Format of DVD Movie run time New release or not format Eine TunTime nerelease boolean 3. For each of the instance variables, write a getter and a setter method. When writing the setter methods, you must use the parameter name as specified in the fourth column in the above table. For example, the setter method for the format must accept a parameter by the name format. 4. Write a non-default constructor that has a list of seven parameters. It assigns the parameters values to the instance variables in the Disc and MovieDVD classes, using the parameter names as specified in the following table. Call the superclass constructor if necessary. BCS 360 Enterprise Programming Instance Variable to Be Initialued Parameter Name in Non-Default Constructor Instance Variable to Be Initialized Parameter Name Non-Default Constructor Instance Variable to Be Initialized Parameter Name in Non-Default Constructor instance Variable to Be Initialized Non-Default Constructor 5. Still in the Movieb dass, override the read i ng method in the super class, which accepts no parameters and returns disc information as a string that contains the following inomat vie DVD SKU: value of SKU value of DVD title> value of DVD formats value of DVD run time minutes Cew Release not displayed otherwise Buy New Or Deeds for COVD price is currency format In runtime, the values in the angle brackets should be replaced by real values. For instance, when the program runs the third line may become something like Kungfu Panda, no value of DVD title. If a disc is a new release, the responding line will show New Release. If a disc is new and has a price of $9.99, the last line will be Buy Now for $9.99. Do not hard code the angle bracketed portion instead, write proper code to retrieve the values from instance variables process them with it statements if necessary. Use a Decimalternatore te format the price in curry format 6. Create a Musica class, which is also a subclaws of the Disclass. This class must have the following instance variables: Instance Variabile Name Type Variable Parameter Name in Setter Method & Non- Default Constructor singer Sing in Singer of the song Number of tracks Umowacka Write a non-default constructor that has a list of six parameters. It assigns the parameters values to the instance variables in the Disc and Music classes, using the parameter names as specified in the following table. Call the superclass constructor if necessary Instance Variable to Be Parameter Name in Non-Default Instance Variable to Be Parameter Name in Non-Default 7. In the Musico dass also override the readDiscinfo method in the super class, which accepts no parameters and returns disc information as a string that contains the following 7. In the Musieco dass also override the readisinfot method in the super das, which accepts no parameters and returns diseinformation as a string that the foowing information ste CD Artists calce of artist Title value of CD title> Trackstuber of tracks Price: CD price is currency format o *Again, in time, the values in the angle brackets must be replaced by real values Testing the Program The Driver class instantiates a Disc array that holds both move and discs. The first two elements contain two move objects and the thinda c o . It is totally fine boste subclass objects in an array of superclass objects. In fact this is an aspect of polymorpem (the Pin the OOP "PE"). The three objects to be created are as follows Movie DVD 1 Movie DVD 2 Music CD SKU Kung Panda Greatest Hits Vol 2 The Rad- Redemption 5240 No Used Format Blu-Ray DVD 100 Run Time New Release Artis Number of Tracks The Driver classes a torloop to display the information of the dissone by one. The loop poes through the three elements in the discs array. Each time, it calls the disent method of that array element to obtain a String containing disc info It then uses optionPane to display that information. Since, whether the elementi LDV sec, the disented method has ben overriden in that das (albeit differently we don't have to write code to check the type of the subclass, tell the program which of the method in other words, the lines of code in the loop body work for all elements in the disc amb seca This is a common use of polymorphism Do not modify the code in the river class. Write your so that they work with the Driver dass seamlessly DVD and Music cases correctly The result of running the saint method will be like the following BCIS Enterpris i ng Disc Info Die Info Movie DVD i Movie DVD SKU: 16005 The Raid - Redemption (DVD) 100 minutes New Release Buy New for $24.99 SKU: 00481 Kungfu Panda (Blu-Ray 12 minutes Buy Used for $16.99 Discindo i Music CD O discs displayed SKU: 05129 Artisti Eagles Title: Greatest Hits Vol 2 Tracks: 10 Price: $14.99 (New) Submission Due Date: 11:59 I'M on Saturday, February 15, 2020 Submission Requirements: . Submit your assignment only through Canvas. . Create a folder and name it 3680-HW2-Yowr Last Name-YourFirst Name Copy Dise.java, MovieDVD.java, Musicco.java, Driver.java, and their respective.class files into the folder. Zip your into 3680-HW2-YourLastName-Your FirstName.zip (RAR or 7-Zip is fine too). Submit the zip file as an attachment on Canvas . Check the content of your zip file before you attach it. Empty zip files will not receive any credit. Before the assignment is due, you may resubmit your work for unlimited times. Simply attach a new version of your assignment. Only the attachment with the latest timestamp will be graded Failure to comply with these requirements will cause point deduction SCIS. Enterpriseg ting . T-Mobile Wi-Fi 6:52 PM

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_2

Step: 3

blur-text-image_3

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

Database 101

Authors: Guy Kawasaki

1st Edition

0938151525, 978-0938151524

More Books

Students also viewed these Databases questions