Television.java
unknown
java
2 years ago
1.9 kB
2
Indexable
package televisiondemo; /** *The purpose of this class is to model a television * Omar Obaid Alkhammash * Lab 5 * February 1 2023 */ public class Television { //defining attributes private String manufacturer; private int screensize; boolean powerOn; int channel; int volume ; //Constructor method assigns values to the corresponding feilds public Television(String brand, int size) { manufacturer = brand; screensize = size; powerOn = false; volume = 20; channel = 2; } // ------- Methods ------- /** * This method returns the value stored in the volume field */ public int getVolume() { return volume; } /** * This method returns the value stored in the channel field */ public int getChannel() { return channel; } /** * This method returns the constant value stored in the manufacturer field */ public String getManufacturer() { return manufacturer; } /** * This method returns the constant value stored in the SCREEN_SIZE field */ public int getScreenSize() { return screensize; } /** * This method stores the desired station in the channel field */ public void setChannel(int choosechannel) { channel = choosechannel; } /** * This method toggles the power between on and off, changing the value stored in the powerOn field from true to false or from false to true. */ public void power() { powerOn = !powerOn; } /** * This method increases the value stored in the volume field by 1 */ public void increaseVolume() { volume = volume + 1; } /** * This method decreases the value stored in the volume field by 1 */ public void decreaseVolume() { volume = volume - 1; } }
Editor is loading...