Line | |
---|
1 | package negotiator.onetomany;
|
---|
2 |
|
---|
3 | import java.util.ArrayList;
|
---|
4 | import java.util.HashMap;
|
---|
5 | import java.util.List;
|
---|
6 | import java.util.Set;
|
---|
7 |
|
---|
8 | /**
|
---|
9 | * * A demand plan is a specification of the demand of an agent for each product.
|
---|
10 | * An example:
|
---|
11 | * Red -> 4, Blue -> 4, Yellow -> 2
|
---|
12 | *
|
---|
13 | *
|
---|
14 | *
|
---|
15 | *
|
---|
16 | *
|
---|
17 | * @author Faria Nassiri-Mofakham
|
---|
18 | *
|
---|
19 | */
|
---|
20 | public class DemandPlan
|
---|
21 | {
|
---|
22 | private HashMap<Product, Integer> demandPlan;
|
---|
23 |
|
---|
24 |
|
---|
25 | public DemandPlan()
|
---|
26 | {
|
---|
27 | this.demandPlan = new HashMap<Product, Integer>();
|
---|
28 | }
|
---|
29 |
|
---|
30 | public HashMap<Product, Integer> getDemandPlan()
|
---|
31 | {
|
---|
32 | return demandPlan;
|
---|
33 | }
|
---|
34 |
|
---|
35 |
|
---|
36 | @Override
|
---|
37 | public String toString()
|
---|
38 | {
|
---|
39 | return demandPlan.toString();
|
---|
40 | }
|
---|
41 |
|
---|
42 | public void setQuantity(Product p, Integer n)
|
---|
43 | {
|
---|
44 | demandPlan.put(p,n);
|
---|
45 | }
|
---|
46 |
|
---|
47 |
|
---|
48 | public Integer getQuantity(Product p)
|
---|
49 | {
|
---|
50 | if (this.demandPlan.containsKey(p))
|
---|
51 | return demandPlan.get(p);
|
---|
52 | else
|
---|
53 | return 0;
|
---|
54 | }
|
---|
55 |
|
---|
56 |
|
---|
57 |
|
---|
58 | public Set<Product> getKeys()
|
---|
59 | {
|
---|
60 | return demandPlan.keySet();
|
---|
61 | }
|
---|
62 |
|
---|
63 |
|
---|
64 | public Set<Integer> getValues()
|
---|
65 | {
|
---|
66 | return (Set<Integer>) demandPlan.values();
|
---|
67 | }
|
---|
68 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.