-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProduct.java
More file actions
49 lines (40 loc) · 1.05 KB
/
Product.java
File metadata and controls
49 lines (40 loc) · 1.05 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
import java.util.*;
import java.lang.*;
import java.io.*;
public class Product extends Thing {
private String ProductName;
private int ProductID;
private LinkedList<Offer> offerList = new LinkedList<Offer>();
Product(String name, int ID) {
ProductName = name;
ProductID = ID;
}
String getName() {
return ProductName;
}
int getID() {
return ProductID;
}
public Offer getOffer(int mid) {
if (offerList.isEmpty())
return null;
else {
ListIterator<Offer> iter = offerList.listIterator();
while (iter.hasNext()) {
Offer o = iter.next();
if (o.getManuID() == mid)
return o;
}
}
return null;
}
public void deleteOffer(Offer o) {
offerList.remove(o);
}
public Iterator<Offer> getOffers() {
return offerList.iterator();
}
public String toString() {
return "Product Name: " + ProductName + "\nProduct ID: " + ProductID;
}
}