Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Intermediate Programming with objects assignment Array List and Inheritance Due of this assignment is at 10 a.m Question 1 [20 points] Implement the class Audio

image text in transcribed

image text in transcribed

Intermediate Programming with objects assignment Array List and Inheritance Due of this assignment is at 10 a.m

Question 1 [20 points] Implement the class Audio only. The code of the classes Disk and Video is provided below. 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, p Time: int) + getArtist(): String + getTracks List(): 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(: String 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; 3 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. remove Track 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:"+ nameOfTrackl; "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; } + director + public String toString() { String result = super.toString()+" Video Director = " " Description = " + description; return result; } } Question 2 [20 points] 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

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

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

7. It is advisable to do favors for people whenever possible.

Answered: 1 week ago