<< Back to Object Oriented Programming Portfolio
Television Assignment
public class Television
{
private String brand;
private String model;
private int volume;
private int channel;
private String childLockCode;
private boolean isChildLockSet;
public Television(String brand, String model)
{
this.brand = brand;
this.model = model;
this.volume = 50;
this.channel = 1;
this.childLockCode = "";
this.isChildLockSet = false;
}
public void increaseVolume()
{
if(volume < 100)
{
volume++;
}
}
public void decreaseVolume()
{
if(volume > 0)
{
volume--;
}
}
public void increaseChannel()
{
if(channel < 75)
{
channel++;
}
}
public void decreaseChannel()
{
if(channel > 0)
{
channel--;
}
}
public String getBrand()
{
return this.brand;
}
public String getModel()
{
return this.model;
}
public int getChannel()
{
return this.channel;
}
public String getChildLockCode()
{
return this.childLockCode;
}
public boolean getIsChildLockSet()
{
return this.isChildLockSet;
}
public void setBrand(String brand)
{
this.brand = brand;
}
public void setModel(String model)
{
this.model = model;
}
public void setChildLockCode(String childLockCode)
{
this.childLockCode = childLockCode;
}
public void setIsChildLockSet(boolean isChildLockSet)
{
this.isChildLockSet = isChildLockSet;
}
public int setVolume(int volume)
{
this.volume = volume;
return this.volume;
}
public int setChannel(int channel)
{
this.channel = channel;
return this.channel;
}
public void enableChildLock(String childLockCode)
{
if (this.childLockCode.equals(childLockCode))
{
this.isChildLockSet = true;
}
}
public void disableChildLock(String childLockCode)
{
if (this.childLockCode.equals(childLockCode))
{
this.isChildLockSet = false;
}
}
}