DemoBlanket
public class Blanket {
protected String size;
protected String color;
protected String material;
protected double price;
public Blanket() {
this.size = "TWIN";
this.color = "WHITE";
this.material = "COTTON";
this.price = 30;
}
public Blanket(String size, String color, String material) {
this.size = size;
this.color = color;
this.material = material;
this.price = 30; // base price
// additional price for size
if(size.equalsIgnoreCase("DOUBLE")) this.price = this.price+10;
else if(size.equalsIgnoreCase("QUEEN")) this.price = this.price+25;
else if(size.equalsIgnoreCase("KING")) this.price = this.price+40;
//additional price for material
if(material.equalsIgnoreCase("WOOL")) this.price = this.price+20;
else if(material.equalsIgnoreCase("CASHMERE")) this.price = this.price+45;
}
@Override
public String toString() {
return " Size: "+this.size+", Color: "+this.color+", Material: "+material+", Price: $"+this.price;
}
}
Are there any code examples left?
New code examples in category TypeScript
-
TypeScript 2022-03-27 19:30:45 typescript promise
-
TypeScript 2022-03-27 17:25:44 how to search for imports in vscode
-
TypeScript 2022-03-27 17:15:20 angular formgroup mark as touched
-
TypeScript 2022-03-27 17:05:06 use of slice and splice add elements array
-
TypeScript 2022-03-27 16:50:23 android studio loop through all objects in layout
-
TypeScript 2022-03-27 14:35:08 wergensherts meaning
-
TypeScript 2022-03-27 13:50:15 remove all the elements from a numpy array python
-
TypeScript 2022-03-27 12:35:49 redux toolkit typescript install
-
TypeScript 2022-03-27 12:35:30 laravel middleware for apis