Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create an interface called edu.udc.cs2.Song. Song must have 2 methods defined like: public String getSongName(); public int getSeconds(); //returns the number of SECONDS the song

Create an interface called edu.udc.cs2.Song. Song must have 2 methods defined like:

public String getSongName();

public int getSeconds(); //returns the number of SECONDS the song lasts

Create a class named edu.udc.cs2.Md. Create the following method:

in java

public static void showSong(List lst)

The method must iterate the passed in List of Song and will output according to the following:

If the song is outside of the range of 2 seconds and 20 minutes, inclusive, throw a RuntimeException at which point the program will automatically end unless you include a try catch in your call.

If the getSeconds() method returns the number of seconds for at least 5 minutes, output:

song name is a long song.

if less than 5 minutes, output:

song name is a short song.

Where song name is the name returned from getSongName() method.

Turn in TWO classes Song.java and Md.java.

Extra Credit

Create a class named edu.udc.cs2.Tune that will implement Song. You must be able to only instantiate as below:

Song s1 = new Tune("What You Did", 300);

Hopefully, you can figure out that in the example "What You Did" is the name of the Song and 300 is the number of seconds. These values must be properly returned from the interface methods.

Create a main method in the Md class and do the following in that main:

Create a List and add at least two instances to your list.

Properly call the showSong method created above to test your code, passing the List above into the method.

Wrap the call in a try/catch block to output "Invalid song" if an exception is thrown.

Include Tune.java in your submission for a total of 3 files submitted.

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

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Sham Navathe

4th Edition

0321122267, 978-0321122261

More Books

Students also viewed these Databases questions