Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle9i Database Administrator Implementation And Administration

Authors: Carol McCullough-Dieter

1st Edition

0619159006, 978-0619159009

More Books

Students also viewed these Databases questions