Appliance.java public class Appliance { //Declaring instance variables private S
ID: 3875057 • Letter: A
Question
Appliance.java
public class Appliance {
//Declaring instance variables
private String name;
private String location;
int value;
//Zero argumented constructor
public Appliance() {}
//Parameterized constructor
public Appliance(String name, String location, int value) {
this.name = name;
this.location = location;
this.value = value;
}
//getters and setters
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
//toString method is used to display the contents of an object inside it
@Override
public String toString() {
return "The " + name + " is located in the " + location;
}
}
__________________
TV.java
public class TV extends Appliance {
//Declaring instance variables
private int size;
private int channel;
private int volume;
//Zero argumented constructor
public TV() {
}
//Parameterized constructor
public TV(String name, String location, int value, int size, int channel, int volume) {
super(name, location, value);
this.size = size;
this.channel = channel;
this.volume = volume;
}
//getters and setters
public int getSize() {
return size;
}
public void setSize(int size) {
this.size = size;
}
public int getChannel() {
return channel;
}
public void setChannel(int channel) {
this.channel = channel;
}
public int getVolume() {
return volume;
}
public void setVolume(int volume) {
this.volume = volume;
}
//toString method is used to display the contents of an object inside it
@Override
public String toString() {
return "The " + getName() + " is located in the " + getLocation() + " and is on channel " + channel;
}
}
_________________
Client.java
public class Client {
public static void main(String[] args) {
//Creating an Instance of TV class object by passing the values as arguments
TV tv1=new TV("Hitachi","Bedroom",399,32,1215,0);
//Displaying the TV class info
System.out.println(tv1);
}
}
_________________
Output:
The Hitachi is located in the Bedroom and is on channel 1215
Explanation / Answer
Ya..could you please tell me what I have to do with this code.This code was developed by me.Do i have to do any further modifications?
I developed This in Java.Do you want me to develop in c++ langauge ...?Could u plz tell me.
I used Inheritance as per in the requirement which you mentioned.
______________
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.