Question
Please help me by writting this java program A. The Disk class is the super class. The code is below: public class Disk { private
Please help me by writting this java program
A. The Disk class is the super class. The code is below:
public class Disk { private String title; private int playTime; public Disk(String title, int playTime) { this.title = title; this.playTime = playTime; } public String getTitle() { return title; } public int getplayTime() { return playTime; } public String toString() { return "Title: " + title + " Play time: " + playTime; } }
B. The Audio class inherits from the class Disk. It has as data a String artist and an array list tracksList to store the names of the tracks. This class has: A constructor that initializes all attributes and creates the tracksList. The getter methods for the attributes. addTrack method that takes as parameter the name of the track ( to be added to the array list. removeTrack method that takes as parameter the name of the track to be deleted from the array list. A toString( ) method that overrides the toString() method in the Disk class by adding the data fields of the Audio class in the form shown below. The toString returns: "Title: " + title + " Play time: " + playTime; "Artist name: " + artist + " List of tracks: "; "track 1:"+ nameOfTrack1; "track 2:"+ nameOfTrack2; "track 3:"+ nameOfTrack3; .. etc..
C. The Video class inherits from the class Disk. The code is below: public class Video extends Disk { private String director; private String description; public Video(String director, String description, String title,int playTime){ super(title, playTime); this.director = director; this.description = description; } public String toString(){ String result = super.toString() +" Video Director = " + director + " Description = " + description; return result; } } Question II : Write a client class (application) in which you: a) Create an array D of 10 disks (not an ArrayList). Write code to insert one audio and one video in the array. The values of these two objects are given by the programmer. Assume the remaining cells of the array D are filled with audio and video objects. b) Write code that displays the director of each video disk in D. c) Write code that adds one track named Hello to the first audio in the array D. Note: You have to search for the first audio disk and not assume it is in cell 0 or 1. d) Prompt the user to enter a track name as a String. Then, display whether the name is found among the audio disks in the array or not. You need to check the trackslist of each audio disk in the array D.
Disk - title: String - playTime: int // in minutes + Disk(title: String, playTime: int) + getters + toString(): String Audio - artist: String - tracksList: ArrayList + Audio(artist: String, ti: String, pTime: int) + getArtist(): String + getTracksList(): ArrayList + addTrack(name: String): void + removeTrack(name: String): void + toString(): String Video - director: String description: String + Video(dir: String, desc: String, ti: String, pTime: int) + toString(): StringStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started