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 | * @author Faria Nassiri-Mofakham
|
---|
10 | *
|
---|
11 | */
|
---|
12 | public class DemandPlan
|
---|
13 | {
|
---|
14 | private HashMap<Product, Integer> demandPlan;
|
---|
15 |
|
---|
16 |
|
---|
17 | public DemandPlan()
|
---|
18 | {
|
---|
19 | this.demandPlan = new HashMap<Product, Integer>();
|
---|
20 | }
|
---|
21 |
|
---|
22 | public HashMap<Product, Integer> getDemandPlan()
|
---|
23 | {
|
---|
24 | return demandPlan;
|
---|
25 | }
|
---|
26 |
|
---|
27 | // public void addProduct(Product p, Integer i)
|
---|
28 | // {
|
---|
29 | // demandPlan.add(p,i);
|
---|
30 | // }
|
---|
31 |
|
---|
32 | @Override
|
---|
33 | public String toString()
|
---|
34 | {
|
---|
35 | return demandPlan.toString();
|
---|
36 | }
|
---|
37 |
|
---|
38 | public void setQuantity(Product p, Integer n)
|
---|
39 | {
|
---|
40 | demandPlan.put(p,n);
|
---|
41 | }
|
---|
42 |
|
---|
43 | public Portfolio getPortfolio()
|
---|
44 | {
|
---|
45 | return (Portfolio) demandPlan.keySet();
|
---|
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 | //Generates a random number between 1 to 5
|
---|
57 | // public Integer intQuantity()
|
---|
58 | public int intQuantity()
|
---|
59 |
|
---|
60 | {
|
---|
61 | // double q = Math.random();
|
---|
62 | // q *=5;
|
---|
63 | // q++;
|
---|
64 | // return Integer((int)q);
|
---|
65 | //return (int)q;
|
---|
66 | return (int)Math.random()*5+1;
|
---|
67 | }
|
---|
68 |
|
---|
69 | public Set<Product> getKeys()
|
---|
70 | {
|
---|
71 | return demandPlan.keySet();
|
---|
72 | }
|
---|
73 |
|
---|
74 | public Set<Integer> getValues()
|
---|
75 | {
|
---|
76 | return (Set<Integer>) demandPlan.values();
|
---|
77 | }
|
---|
78 | }
|
---|