-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathElectronics.java
More file actions
53 lines (43 loc) · 1.57 KB
/
Electronics.java
File metadata and controls
53 lines (43 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
public class Electronics extends Product {
private int warrantyPeriod;
private String brand;
// Constructor
public Electronics(int productID, String productName, String category, double price, int quantityInStock, int warrantyPeriod, String brand) {
super(productID, productName, category, price, quantityInStock);
this.warrantyPeriod = warrantyPeriod;
this.brand = brand;
}
// Getters
public int getWarrentyPeriod() {
return this.warrantyPeriod;
}
public String getBrand() {
return this.brand;
}
// Setters
public void setWarrantyPeriod(int newWarrantyPeriod) {
this.warrantyPeriod = newWarrantyPeriod;
}
public void setBranding(String newBrand) {
this.brand = newBrand;
}
// Overriden addStock() method
@Override
public void addStock(int quantity) {
if (this.warrantyPeriod > 0) {
super.addStock(quantity);
} else {
System.out.println("The product cannot be added as the warranty has expired.");
}
}
@Override
public void displayProductInfo() {
System.out.println("Product info for "+super.getProductName());
System.out.println("Product ID: "+super.getProductID());
System.out.println("Category: "+super.getCategory());
System.out.println("Price: "+super.getPrice());
System.out.println("Qty in Stock: "+super.getQuantityInStock());
System.out.println("Warranty Period: "+this.warrantyPeriod);
System.out.println("Brand: "+this.brand);
}
}