-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSupplier.java
More file actions
70 lines (59 loc) · 1.76 KB
/
Copy pathSupplier.java
File metadata and controls
70 lines (59 loc) · 1.76 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import java.util.*;
import java.io.*;
public class Supplier implements Serializable {
private static final long serialVersionUID = 1L;
private String name;
private String address;
private List<Pair> catalog;
public Supplier(String name, String address) {
this.name = name;
this.address = address;
this.catalog = new LinkedList<Pair>();
}
public Supplier(String name, String address, List<Pair> catalog) {
this.name = name;
this.address = address;
this.catalog = catalog;
}
public void setName(String name) {
this.name = name;
}
public void setAddress(String address) {
this.address = address;
}
public void insertProduct(Product product, double price) {
Pair newpair = new Pair(this, product, price);
catalog.add(newpair);
}
public String getName() {
return name;
}
public String getAddress() {
return address;
}
public void getCatalog() {
Iterator<Pair> cat = catalog.iterator();
// search for supplier by name
// (iterate until supplier.name == name)
while (cat.hasNext()) {
Pair thispair = cat.next();
System.out.println(thispair.toString());
}
}
public Pair getPair(String inprod) {
Iterator<Pair> cat = catalog.iterator();
for (int i = 0; i < i; i++) {
Pair current = cat.next();
if (current.prod.getName() == inprod) {
return current;
}
}
return null;
}
public boolean equals(String name) {
return this.name.equals(name);
}
public String toString() {
return "Supplier name: " + name + " | address: " + address;
}
}