-
Notifications
You must be signed in to change notification settings - Fork 0
/
ListProducts.java
82 lines (66 loc) · 1.74 KB
/
ListProducts.java
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package ExamMidTermOOP;
import java.util.Iterator;
public class ListProducts {
LaptopList laptop_list = new LaptopList();
private static String IDL;
private static String IDP;
public ListProducts(String iDL, String iDP) {
IDL= null;
IDP = null;
}
public ListProducts() {
}
public String getIDL() {
return IDL;
}
public void setIDL(String iDLaptop) {
IDL = iDLaptop;
}
public String getIDP() {
return IDP;
}
public void setIDProducts(String iDPC) {
IDP = iDPC;
}
public String InputLaptop(String id) {
for (Iterator<Laptop> it = laptop_list.LAPTOP.iterator(); it.hasNext();) {
Laptop l = it.next();
if (l.getIDLaptop().compareToIgnoreCase(id) == 0) {
IDL = l.getIDLaptop();
return id;
}
}
System.out.println("===== Mã Laptop không có trong dữ liệu =====");
return null;
}
public String PriceLaptop(String id) {
for (Iterator<Laptop> it = laptop_list.LAPTOP.iterator(); it.hasNext();) {
Laptop l = it.next();
if (l.getIDLaptop().compareToIgnoreCase(id) == 0) {
IDL = l.getPriceLaptop();
break;
}
}
return IDL;
}
public static String InputPC(String id) {
for (Iterator<PC> it = PCList.PC.iterator(); it.hasNext();) {
PC p = it.next();
if (p.getIDProducts().compareToIgnoreCase(id) == 0) {
IDP = p.getIDProducts();
return id;
}
}
System.out.println("===== Mã máy tính không có trong dữ liệu =====");
return null;
}
public static String PricePC(String id) {
for (Iterator<PC> it = PCList.PC.iterator(); it.hasNext();) {
PC p = it.next();
if (p.getIDProducts().compareToIgnoreCase(id) == 0) {
IDP = p.getPrice();
}
}
return IDP;
}
}