WEEK 7 ASSIGNMENT – PART 2 Audio and Video

Original price was: $35.00.Current price is: $30.00.

Rate this product

You have been provided with a file that implements two classes Audio and Video that
represent two different types of playable objects. Both classes contain a method playbackTime that
returns how long it takes to listen to the audio object or watch the video object. You are to implement
polymorphic class methods in the class Main that manipulate these objects. Make sure to use the most
general type of polymorphism for implementing each method. It is okay if the method works in other
scenarios, as long as it works in the scenarios specified.
You are not allowed to add or modify fields and methods in the Audio and Video classes, but you are
allowed to modify the class declarations if you need to. The code also contains test code in the main
function that is expected to work for a correct solution. Do not modify this test code.
1. Implement a polymorphic function selectRandom that takes a List<Audio> object and
selects and returns a random Audio object from the list, or takes a List<Video> object and
selects and returns a random Video object from the list. You can use the Java function
Math.random() to generate a random numbers between 0 and 1.
2. Implement a polymorphic function playbackTimeWithSpeed that accepts either an Audio
or a Video object and a second parameter speed and returns the play back time of the object
scaled by the provided speed.
3. Implement a polymorphic function totalPlaybackTime that takes a List<Audio> object
or a List<Video> object and returns the total playback time of all the objects in the list.
Solutions should be:
 Correct
 In good style, including indentation and line breaks
 Written using features discussed in class
Submission Instructions
Submit your file via Moodle. Do not submit any other files or compressed folders.


There are no reviews yet.

Be the first to review “WEEK 7 ASSIGNMENT – PART 2 Audio and Video”

Your email address will not be published. Required fields are marked *

Scroll to Top