Having considered which constructor, accessor, mutator and other methods we migh
ID: 3641166 • Letter: H
Question
Having considered which constructor, accessor, mutator and other methods we might use, we can represent these design decisions in UML.-MANUFACTURER: String
-SCREEN_SIZE: int
-powerOn: boolean
-channel: int
-volume: int
+Television(brand: String, size: int):
+setChannel (station: int): void
+power( ): void
+increaseVolume( ): void
+decreaseVolume( ): void
+getChannel( ): int
+getVolume( ): int
+getManufacturer( ): String
+getScreenSize( ): int
We will write the television class. Each object that is created from the television class must be able to hold information about that instance of a television in fields. So a television object will have the following attributes:
Explanation / Answer
Hi, I am done with the Televison.java. Pelase run it using TelevisionDemo.java /** * The purpose of this class is to model a television * * @version 1.0 * @author Sumitha */ public class Television { private String MANUFACTURER; // hold the brand name private int SCREEN_SIZE; // hold the size of the television screen boolean powerOn = false; // old the value true if the power is on, and false // if the power is off. int channel = 2; // hold the value of the station that the television is // showing. int volume = 20; // hold a number value representing the loudness /** * Constructor to initialize the values of brand and size of the screen * * @param brand * @param size */ Television(String brand, int size) { this.MANUFACTURER = brand; this.SCREEN_SIZE = size; } /** * This method will return the constant value stored in the MANUFACTURER * field. * * @return */ public String getMANUFACTURER() { return MANUFACTURER; } /** * The getScreenSize method will return the constant value stored in the * SCREEN_SIZE field. * * @return */ public int getSCREEN_SIZE() { return SCREEN_SIZE; } /** * The power method will toggle 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() { if (!powerOn) { powerOn = true; } else { powerOn = false; } } /** * This method will increase the value stored in the volume field by 1. */ public void increaseVolume() { volume++; } /** * This method will decrease the value stored in the volume field by 1. */ public void decreaseVolume() { volume--; } /** * will return the value stored in the channel field. * * @return int */ public int getChannel() { return channel; } /** * This method store the desired station in the channel field. * * @param channel */ public void SetChannel(int channel) { this.channel = channel; } /** * will return the value stored in the volume field. */ public int getVolume() { return volume; } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.