-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtester.java
More file actions
42 lines (29 loc) · 1.29 KB
/
tester.java
File metadata and controls
42 lines (29 loc) · 1.29 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
import java.util.*;
import java.text.*;
import java.io.*;
class Tester{
public static void main(String[] args) {
System.out.println("This is a tester for Product and ProductList Class.");
ProductList productList = ProductList.instance();
//Creating Dummy Product 1 Object
System.out.println("Creating Product 1 Object: ");
Product product1 = new Product("Google Pixel", 534);
System.out.println("Product 1: " + product1);
//Creating Product 2 Object
System.out.println("Creating Product 2 Object: ");
Product product2 = new Product("Apple X", 535);
System.out.println("Product 2: " + product2);
//Adding all Dummy Objects to the List
System.out.println("Adding all Products to the ProductList: ");
productList.add(product1);
productList.add(product2);
//Calling the getProductList that returns Iterator
System.out.println("Getting the Iterator for the List of Product. ");
Iterator pList = productList.getList();
System.out.println("Printing the List of Product from Iterator. ");
while(pList.hasNext()){
Product newProduct = (Product)( pList.next());
System.out.println("Product Object: \n" + newProduct);
}
}
}