import java.util.ArrayList;
// Use of abstract class
public abstract class Furniture {
String name;
double price;
String photo;
// USE OF ABSTRACT METHODS
abstract void display();
abstract String getDetails();
}
// USE OF INHERITANCE
class Chair extends Furniture{
static int id_iterator = 1;
int height,diagonal;
int id;
//USE OF FINAL VARIABLE
final String details;
//USE OF CONSTRUCTOR OVERLOADING
Chair(String photo, double price ,int
height,int diagonal){
this.diagonal
=diagonal;
this.height
=height;
this.photo
=photo;
this.price
=price;
this.name
="Chair";
this.id =
id_iterator;
id_iterator
+=1;
//details =
"";
details ="Chair
," +"id : "+this.id + ", photo : "+this.photo +", diagonal : " +
this.diagonal + ", height : "+this.height;
}
// USE OF OVERRIDING
void display(){
System.out.println("Chair
," +"id : "+this.id + ", photo : "+this.photo + ", price : "+
this.price + ", diagonal : " + this.diagonal + ", height :
"+this.height);
}
public String getName(){
return
this.name;
}
public String getDetails(){
return
this.details;
}
}
class Table extends Furniture{
static int id_iterator = 1;
int height,width,length;
int id;
final String details;
Table(String photo, double price ,int
height,int width,int length){
this.length
=length;
this.width
=width;
this.height
=height;
this.photo
=photo;
this.price
=price;
this.name
="Table";
this.id =
id_iterator;
id_iterator
+=1;
details = "Table
," +"id : "+this.id + ", photo : "+this.photo + ", price : "+
this.price + ", width : " + this.width + ", length : "+this.length
+ " height : "+this.height;
}
void display(){
System.out.println("Table
," +"id : "+this.id + ", photo : "+this.photo + ", price : "+
this.price + ", width : " + this.width + ", length : "+this.length
+ " height : "+this.height);
}
public String getName(){
return
this.name;
}
public String getDetails(){
return
this.details;
}
}
class Lamp extends Furniture{
static int id_iterator = 1;
final String details;
int id,bulbs;
Lamp(String photo, double price ,int
bulbs){
this.bulbs
=bulbs;
this.photo
=photo;
this.price
=price;
this.name
="Lamp";
this.id =
id_iterator;
id_iterator
+=1;
details ="Lamp
," +"id : "+this.id + ", photo : "+this.photo + ", bulbs
: "+this.bulbs;
}
public String getName(){
return
this.name;
}
void display(){
System.out.println("Lamp
," +"id : "+this.id + ", photo : "+this.photo + ", price : "+
this.price + ", bulbs : "+this.bulbs);
}
public String getDetails(){
return
this.details;
}
}
class Sets{
String name;
ArrayList<Furniture> mySet ;
double total=0.0;
Sets(String name){
this.name =name;
mySet = new
ArrayList<>();
}
void addToSet(Furniture myFurniture){
mySet.add(myFurniture);
}
void displaySet(){
System.out.println(this.name
+ "(Set)");
for(Furniture f :
mySet){
total +=
f.price;
System.out.println(f.getDetails());
}
System.out.println("price
:"+ this.total);
}
}
class Test_Furniture{
public static void main(String args[]){
Chair c = new Chair("chair1.png", 11.99, 6, 12);
Chair c1 = new Chair("chair2.png", 12.34, 7,
13);
Table t =new Table("table1.png", 12.48, 10, 12,
8);
Lamp l = new Lamp("lamp1.png", 8.75, 2);
Sets s = new Sets("Kitchen");
s.addToSet(c);
s.addToSet(t);
s.addToSet(l);
c1.display();
c.display();
t.display();
l.display();
s.displaySet();
}
}
NOW HAVE A LOOK AT IDE CODE WITH PROPER INDENTATTION







NOW HAVE A LOOK AT THE OUTPUT SCREEN

HOPE I HELPED YOU.
1 File Edit Selection View Go Run Terminal Help • Furniture.java - loveEditor - Visual Studio Code Х Furniture.java Temperature.java Strinf_program.java Stack_array.java on.java makeGoFdictionary.py display_string.java HomeworkLib_pyhton.py D: > DS_questions > Furniture.java > $ Chair > Chair(String, double, int, int) 1 import java.util.ArrayList; 2 3 4 // Use of abstract class 5 6 public abstract class Furniture { 7 String name; 8 double price; 9 String photo; 10 11 // USE OF ABSTRACT METHODS 12 13 abstract void display(); 14 abstract String getDetails(); 15 16 } A 1.7
on.java А File Edit Selection View Go Run Terminal Help • Furniture.java - loveEditor - Visual Studio Code makeGoFdictionary.py display_string.java e HomeworkLib_pyhton.py Furniture.java Temperature.java Strinf_program.java Stack_array.java D: > DS_questions > Furniture.java > Es Chair > Chair(String, double, int, int) 20 class Chair extends Furniture{ 21 22 static int id_iterator = 1; 23 24 int height, diagonal; 25 int id; 26 27 //USE OF FINAL VARIABLE 28 29 final String details; 30 31 //USE OF CONSTRUCTOR OVERLOADING 32 33 Chair(String photo, double price , int height, int diagonal){ 34 this.diagonal -diagonal; 35 this.height =height; 36 this.photo =photo; 37 this.price =price; 38 this.name ="Chair"; 39 this.id = id_iterator; 40 id_iterator +=1; 41 //details 42 details ="Chair," +"id : "+this.id + ", photo : "+this.photo +", diagonal : + this.diagonal + ", height : "+this.height; 43 44 45 // USE OF OVERRIDING 46 47 void display(){ 48 System.out.println("Chair," +"id : "+this.id + ", photo : "+this.photo + ", price : "+ this.price + ", diagonal : + this.diagonal + 49 50 }
public String getName(){ return this.name; } 52 53 54 55 56 57 58 59 public String getDetails(){ return this.details; } }
60 61 class Table extends Furniture{ static int id_iterator = 1; 62 63 64 65 66 67 68 69 int height,width, length; int id; final String details; 0 70 71 72 73 Table(String photo, double price , int height, int width, int length) { this.length =length; this.width =width; this.height -height; this.photo =photo; this.price =price; this.name ="Table"; this.id = id_iterator; id_iterator +=1; 74 WA 75 76 77 78 79 details = "Table ," +"id : "+this.id + ", photo : "+this.photo + ", price : "+ this.price + ", width : " + this.width + ", length : "+thi: } 80 81 82 83 84 85 void display() { System.out.println("Table ," +"id : "+this.id + ", photo : "+this.photo + ", price : "+ this.price + ", width : BE + this.width + ", lengt 86 87 88 } public String getName() { return this.name; } 89 O 11 90
91 92 93 public String getDetails({ return this.details; } TC 94 } 95 96 97 98 99 100 class Lamp extends Furniture{ А 101 102 103 static int id_iterator = 1; final String details; int id, bulbs; 104 105 106 107 108 109 110 111 Lamp (String photo, double price , int bulbs) { this.bulbs =bulbs; this.photo =photo; this.price =price; this.name ="Lamp"; this.id = id_iterator; id_iterator +=1; details ="Lamp," +"id : "+this.id + ", photo : "+this photo + ", bulbs : "+this.bulbs; } 112 113 114 115 116 public String getName() { return this.name; } 117 118 119 120 void display() { System.out.println("Lamp," +"id : "+this.id + ", photo : "+this.photo + ", price : "+ this.price + ", bulbs : "+this.bulbs); 121 122 Dathon 39264bit an Inn Col 25 Sacer. TITE 8 O CRIE lay I-SE. 11 n
public String getDetails(){ return this.details; } } . class Sets{ String name; ArrayList<Furniture> mySet ; double total=0.0; Sets(String name) { this.name =name; mySet = new ArrayList<>(); } A 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 void addToSet (Furniture myFurniture) { mySet.add(myFurniture); } void displaySet({ System.out.println(this.name + "(Set)"); for(Furniture f: mySet){ total += f.price; System.out.println(f.getDetails()); } System.out.println("price :"+ this.total); } }
} System.out.println("price :"+ this.total); } go 150 151 152 153 154 155 156 } class Test_Furniture{ B. Run | Debug public static void main(String args[]) { А Chair c = new Chair("chair1.png", 11.99, 6, 12); Chair c1 = new Chair("chair2.png", 12.34, 7, 13); Table t =new Table("table1.png", 12.48, 10, 12, 8); Lamp 1 = new Lamp ("lamp1.png", 8.75, 2); 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 Sets s = new Sets("Kitchen"); s.addToSet(); s.addToSet(t); s.addToSet(1); c1.display(); c.display(); t.display(); 1.display(); s.displaySet(); } 8 }
class Test_Furniture{ 155 156 Run Debug PROBLEMS 4 OUTPUT DEBUG CONSOLE TERMINAL 4: Java Process Console v + А PS C:\Users\chirag.arora\loveEditor> cd 'c:\Users\chirag.arora\loveEditor'; & 'c:\Users\chirag. arora\.vscode\extensions\vscjava.vscode-java-debug-0.28.0\scripts\launcher.bat' 'C:\Pr ogram Files\Zulu\zulu-11\bin\java.exe' '-Dfile.encoding=UTF-8' '-cp' 'C:\Users\chirag.arora\AppData\Roaming\Code\User\workspaceStorage\1c2408ee2f2188618df263224cc83de8\redhat.java\jd t_ws\jdt.ls-java-project\bin' 'Test_Furniture' Chair ,id : 2, photo : chair2.png, price : 12.34, diagonal : 13, height : 7 Chair ,id : 1, photo : chair1.png, price : 11.99, diagonal : 12, height : 6 Table ,id : 1, photo : table1.png, price : 12.48, width : 12, length : 8 height : 10 Lamp ,id : 1, photo : lamp1.png, price : 8.75, bulbs : 2 Kitchen (Set) Chair ,id : 1, photo : chair1.png, diagonal : 12, height : 6 Table ,id : 1, photo : table1.png, price : 12.48, width : 12, length : 8 height : 10 Lamp ,id : 1, photo : lamp1.png, bulbs : 2 price :33.22 PS C:\Users\chirag.arora\loveEditor> CISE A