COMP2396
Loading...
Searching...
No Matches
tutorial4.part2.Tester Class Reference

Static Public Member Functions

static void main (String[] args) throws IOException
 

Detailed Description

Definition at line 4 of file Tester.java.

Member Function Documentation

◆ main()

static void tutorial4.part2.Tester.main ( String[] args) throws IOException
inlinestatic

Definition at line 5 of file Tester.java.

5 {
6 InputStreamReader isr = new InputStreamReader(System.in);
7 BufferedReader inData = new BufferedReader(isr);
8 String c1_info[] = inData.readLine().split(" ");
9 String c2_info[] = inData.readLine().split(" ");
10
11 // Part 1: ElectronicsProduct object
12 String productID1 = c1_info[0];
13 String name1 = c1_info[1];
14 double price1 = Double.valueOf(c1_info[2]);
15 ElectronicsProduct product = new ElectronicsProduct(productID1, name1, price1);
16
17 // Apply a discount and display the final price
18 product.applyDiscount(10);
19 System.out.println("Product ID: " + product.getProductId());
20 System.out.println("Name: " + product.getName());
21 System.out.println("Price after discount: $" + product.getPrice());
22 System.out.println("--------------------");
23
24 // Part 2: WashingMachine object
25 String productID2 = c2_info[0];
26 String name2 = c2_info[1];
27 double price2 = Double.valueOf(c2_info[2]);
28 int warrantyPeriod2 = Integer.valueOf(c2_info[3]);
29 Television tv = new Television(productID2, name2, price2, warrantyPeriod2);
30
31 // Apply a discount and display the final price
32 tv.applyDiscount(15);
33 System.out.println("Product ID: " + tv.getProductId());
34 System.out.println("Name: " + tv.getName());
35 System.out.println("Price after discount: $" + tv.getPrice());
36 System.out.println("Warranty period: " + tv.getWarrantyPeriod() + " months");
37
38 // Extend the warranty period and display the new warranty period
39 tv.extendWarranty(12);
40 System.out.println("Warranty period: " + tv.getWarrantyPeriod() + " months");
41 }

References tutorial4.part2.ElectronicsProduct.applyDiscount(), tutorial4.part2.Television.extendWarranty(), tutorial4.part2.ElectronicsProduct.getName(), tutorial4.part2.ElectronicsProduct.getPrice(), tutorial4.part2.ElectronicsProduct.getProductId(), and tutorial4.part2.Television.getWarrantyPeriod().

Here is the call graph for this function:

The documentation for this class was generated from the following file: