retun power ;
return channel ;
return volume ;
respectively.
/**
* This class represents a television, which can be turned on and off,
* change channels, and change volume
*
* @author
*/
class Television
{
private int channel;
private int volume;
private boolean power;
// Constructor
/**
* Creates a new Television
*/
public Television(int channel, int volume)
{
channel=0;
volume=0;
power = false ; //power shud be off initially
}
// Instance Methods
/**
* Turn the TV on or off, to whatever it wasn't before
*/
public void switchOnOff(Boolean power)
{
this.power = power ; // this means this classes in particular
//(The power var declared above
// the other power is argument to the function
}
/**
* Change the channel to the given channel number;
* If the new channel is not between 1 and 5 inclusive, then nothing happens
*/
public void changeChannel(int channel)
{
if(channel>=1 && channel<=5)
this.channel = channel;
}
/**
* Increase the volume level by 1;
* If the tv is already at maximum volume, nothing happens
*/
public void increaseVolume(int volume)
{
this.volume++;
}
/**
* Decrease the volume level by 1;
* If the tv is already at minimum volume, nothing happens
*/
public void decreaseVolume(int volume)
{
this.volume--; //why the hell decrease volume should ++ ?? silly ?
}
// Accessor methods
/**
* Returns true if the TV is on,
* else, returns false
*/
public boolean isOn()
{
return power ;
}
public int getChannel()
{
return channel;
}
public int getVolume()
{
return volume;
}
}
also note power is boolean so the argument of isOnOff() should not be boolean.
If i am not wrong, u are asked to characterize a real life thing on OOP perspective typical CSE question, i faced them a lot in my last year. If i am wrong then plz 4give me.