Q Search ask #1 Creating a New Class 1. In a new file, create a class definition
ID: 3884220 • Letter: Q
Question
Explanation / Answer
Note : As in this question as it didnt provided to create the Driver class.I didnt wrote it.If u need just tell me.Thank You.
_________________
Television.java
public class Television {
// Declaring instance variables
private String manufacturer;
private int volume;
private boolean powerOn;
private float screenSize;
private int channel;
// Parameterized constructor
public Television(String manufacturer, float screenSize) {
super();
this.manufacturer = manufacturer;
this.screenSize = screenSize;
this.powerOn = false;
this.volume = 20;
this.channel = 2;
}
/*
* This method return the manufacturer name
*
* @Params : void
*
* @return String
*/
public String getManufacturer() {
return manufacturer;
}
/*
* This method return the volume
*
* @Params : void
*
* @return int
*/
public int getVolume() {
return volume;
}
/*
* This method return the screen size
*
* @Params : void
*
* @return float
*/
public float getScreenSize() {
return screenSize;
}
/*
* This method return the channel no
*
* @Params : void
*
* @return int
*/
public int getChannel() {
return channel;
}
/*
* This method sets the channel number
*
* @Params : int
*
* @return void
*/
public void setChannel(int channel) {
this.channel = channel;
}
/*
* This method return the power on or off status
*
* @Params : void
*
* @return boolean
*/
public boolean getPower() {
return powerOn;
}
/*
* This method turn on or off the television
*
* @Params : void
*
* @return void
*/
public void power() {
this.powerOn = !powerOn;
}
/*
* This method increase the volume
*
* @Params : void
*
* @return void
*/
public void increaseVolume() {
volume++;
}
/*
* This method decrease the volume
*
* @Params : void
*
* @return void
*/
public void decreaseVolume() {
volume--;
}
}
_______________________
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.