Assignment 2
Assignment 2
PROGRAM
// Base class Product
class Product {
this.name = name;
this.price = price;
this.quantity = quantity;
return name;
return price;
return quantity;
}
this.name = name;
this.price = price;
this.quantity = quantity;
// Default discount is 5%
// Subclass ElectronicProduct
public ElectronicProduct(String name, double price, int quantity, String brand, int warranty) {
this.brand = brand;
this.warranty = warranty;
return brand;
return warranty;
this.brand = brand;
}
this.warranty = warranty;
@Override
@Override
super.displayProductDetails();
// Subclass ClothingProduct
this.size = size;
this.fabricType = fabricType;
return size;
return fabricType;
this.size = size;
this.fabricType = fabricType;
@Override
@Override
super.displayProductDetails();
product1.displayProductDetails();
product2.displayProductDetails();