public class Song
extends java.lang.Object
Constructor and Description |
---|
Song(java.lang.String title,
int songLength)
Construct a song from its title and duration
|
Song(java.lang.String title,
int songMinutes,
int songSeconds)
Construct a song from its title and duration
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object x)
Compares this Song with the specified Object for equality.
|
TimeDuration |
getDuration()
Returns the duration of this song.
|
static Song |
parseSong(java.lang.String description)
Factory method that builds a song using the given description.
|
java.lang.String |
toString()
Returns a printable representation of this song.
|
public Song(java.lang.String title, int songLength)
title
- the name of the songsongLength
- the song length in secondspublic Song(java.lang.String title, int songMinutes, int songSeconds)
title
- the name of the songsongMinutes
- the minutes portion of the song lengthsongSeconds
- the seconds part of the song lengthpublic static Song parseSong(java.lang.String description)
description
- A string in the format "minutes:seconds name" where minutes
and seconds are integers, and name is a string. A single blank separates
the time from the song name.public boolean equals(java.lang.Object x)
equals
in class java.lang.Object
x
- Object to which this Song is to be compared.public java.lang.String toString()
toString
in class java.lang.Object
0:55 Layla
1:23 Blackbird
11:42 Caravan
0:06 Shorty
public TimeDuration getDuration()