COMP2396
Loading...
Searching...
No Matches
Television.java
Go to the documentation of this file.
1package tutorial4.part2;
2
3/**
4 * Television class, which is a subclass of the ElectronicsProduct class. It should have an
5 * extra attribute that records it’s warranty period (in months).
6 */
7public class Television extends ElectronicsProduct {
8 private int warrantyPeriod;
9
10 public Television(String productId, String name, double price, int warrantyPeriod) {
11 super(productId, name, price);
12 this.warrantyPeriod = warrantyPeriod;
13 }
14
15 public int getWarrantyPeriod() {
16 return warrantyPeriod;
17 }
18
19 public void extendWarranty(int months) {
20 warrantyPeriod += months;
21 }
22}
ElectronicsProduct class with attributes for product ID, name, and price.
Television class, which is a subclass of the ElectronicsProduct class.
Television(String productId, String name, double price, int warrantyPeriod)
void extendWarranty(int months)