Methods Summary |
---|
private void | checkVolume(short volume)Helper method to make sure a volume value is legal.
if (volume < MINIMUM) {
throw new IllegalArgumentException("volume cannot be less than " +
MINIMUM);
}
if (volume > MAXIMUM) {
throw new IllegalArgumentException("volume cannot be more than " +
MAXIMUM);
}
|
public boolean | equals(java.lang.Object obj)Compare whether another object is equal to this one, following the
contract established by {@link Object}.
if (obj instanceof StereoVolume) {
StereoVolume other = (StereoVolume)obj;
return other.getLeft() == getLeft() &&
other.getRight() == getRight();
}
return false; // It wasn't a StereoVolume
|
public short | getLeft()Get the volume of the left channel
return left;
|
public short | getRight()Get the volume of the right channel.
return right;
|
public int | hashCode()Returns a hash code value for the StereoVolume. This method must be
consistent with the {@link #equals} method.
return (int)getLeft() * MAXIMUM * 10 + getRight();
|
public void | setLeft(short volume)Set the volume of the left channel.
checkVolume(volume);
left = volume;
|
public void | setRight(short volume)Set the volume of the right channel.
checkVolume(volume);
right = volume;
|
public java.lang.String | toString()Format a readable version of the volume levels, for debugging.
return "Volume[left=" + left + ", right=" + right + ']";
|