song
Class SongRating

java.lang.Object
  extended by song.SongRating
All Implemented Interfaces:
java.lang.Comparable

public class SongRating
extends java.lang.Object
implements java.lang.Comparable


Field Summary
static int HIGHEST_RATING
           
static int LOWEST_RATING
           
 
Constructor Summary
SongRating()
          Creates a new default instance of SongRating
SongRating(Song sg)
          creates a new instance of SongRating given a Song.
SongRating(Song sg, int rate)
          creates a new instance of SongRating given a Song and a rating.
 
Method Summary
 int compareTo(java.lang.Object obj)
          Compares two SongRatings - needed for sorting - required since implements Comparable interface returns negative if object comparing to is less, zero if object comparing to is equal, positive if object comparing to is greater.
 boolean decreaseRating()
          decrease song rating by one.
 boolean decreaseRating(int amt)
          decrease song rating by passed value.
 boolean equals(java.lang.Object obj)
          determine if a passed SongRating has the same contents as the calling object (all contents).
 int getRating()
          report song rating
 Song getSongInfo()
          report song info
 boolean increaseRating()
          increase song rating by one.
 boolean increaseRating(int amt)
          increase song rating by passed value.
 boolean setRating(int rate)
          change song rating.
 boolean setSongInfo(Song info)
          change song - not sure if we should really provide this
 java.lang.String toShortString()
          produce a shorter friendly string version of the object
 java.lang.String toString()
          produce a friendly string version of the object
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOWEST_RATING

public static final int LOWEST_RATING
See Also:
Constant Field Values

HIGHEST_RATING

public static final int HIGHEST_RATING
See Also:
Constant Field Values
Constructor Detail

SongRating

public SongRating()
Creates a new default instance of SongRating


SongRating

public SongRating(Song sg)
creates a new instance of SongRating given a Song. Since an object, it is the EXACT SAME SONG passed (same reference)


SongRating

public SongRating(Song sg,
                  int rate)
creates a new instance of SongRating given a Song and a rating. Since an object, it is the EXACT SAME SONG passed (same reference)

Method Detail

getSongInfo

public Song getSongInfo()
report song info


getRating

public int getRating()
report song rating


setSongInfo

public boolean setSongInfo(Song info)
change song - not sure if we should really provide this


setRating

public boolean setRating(int rate)
change song rating. Returns false if trying to set too high or too low


increaseRating

public boolean increaseRating()
increase song rating by one. Return false if can't go any higher.


decreaseRating

public boolean decreaseRating()
decrease song rating by one. Return false if can't go any lower.


increaseRating

public boolean increaseRating(int amt)
increase song rating by passed value. Return false if amt is negative or if can't go that high (setting rating to max)


decreaseRating

public boolean decreaseRating(int amt)
decrease song rating by passed value. Return false if amt is negative or if can't go that high (setting rating to max)


toString

public java.lang.String toString()
produce a friendly string version of the object

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
determine if a passed SongRating has the same contents as the calling object (all contents). Overrides version in java.lang.Object

Overrides:
equals in class java.lang.Object

compareTo

public int compareTo(java.lang.Object obj)
Compares two SongRatings - needed for sorting - required since implements Comparable interface returns negative if object comparing to is less, zero if object comparing to is equal, positive if object comparing to is greater. Compare based on song rating itself.

Specified by:
compareTo in interface java.lang.Comparable

toShortString

public java.lang.String toShortString()
produce a shorter friendly string version of the object