Java Reference
In-Depth Information
public int volumeUp(int increment) {
if(!power) {
// If the power is off
return 0;
// Nothing works
}
// Set volume - must not be greater than the maximum
volume += increment;
volume = min(volume, MAX_VOLUME);
System.out.println(make + " "+ screensize + " inch TV volume
level: "
+ volume);
return volume;
}
public int volumeDown(int decrement) {
if(!power) {
// If the power is off
return 0;
// Nothing works
}
// Set volume - must not be less than the minimum
volume -= decrement;
volume = max(volume, MIN_VOLUME);
System.out.println(make + " "+ screensize + " inch TV volume
level: "
+ volume);
return volume;
}
public void mute() {
if(!power) {
// If the power is off
return;
// Nothing works
}
volume = MIN_VOLUME;
System.out.println(make + " "+ screensize + " inch TV volume
level: "
+ volume);
}
public int setChannel(int newChannel) {
if(!power) {
// If the power is off
return 0;
// Nothing works
}
// Channel must be from MIN_CHANNEL to MAX_CHANNEL
if(newChannel>=MIN_CHANNEL && newChannel<=MAX_CHANNEL)
channel = newChannel;
System.out.println(make + " "+ screensize + " inch TV tuned to
channel: "
+ channel);
return channel;
}
Search WWH ::




Custom Search