[210] | 1 | package negotiator.onetomany;
|
---|
| 2 |
|
---|
| 3 | import java.util.ArrayList;
|
---|
[215] | 4 | import java.util.HashMap;
|
---|
[210] | 5 | import java.util.List;
|
---|
[219] | 6 | import java.util.Set;
|
---|
[210] | 7 |
|
---|
| 8 | /**
|
---|
[225] | 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 | *
|
---|
[210] | 17 | * @author Faria Nassiri-Mofakham
|
---|
| 18 | *
|
---|
| 19 | */
|
---|
| 20 | public class DemandPlan
|
---|
| 21 | {
|
---|
[215] | 22 | private HashMap<Product, Integer> demandPlan;
|
---|
[226] | 23 | private HashMap<Product, Double> weight;
|
---|
| 24 |
|
---|
[210] | 25 |
|
---|
[215] | 26 |
|
---|
| 27 | public DemandPlan()
|
---|
| 28 | {
|
---|
| 29 | this.demandPlan = new HashMap<Product, Integer>();
|
---|
[226] | 30 | this.weight = new HashMap<Product, Double>();
|
---|
[215] | 31 | }
|
---|
| 32 |
|
---|
| 33 | public HashMap<Product, Integer> getDemandPlan()
|
---|
| 34 | {
|
---|
| 35 | return demandPlan;
|
---|
| 36 | }
|
---|
| 37 |
|
---|
[226] | 38 | public HashMap<Product, Double> getWeight()
|
---|
| 39 | {
|
---|
| 40 | return weight;
|
---|
| 41 | }
|
---|
[215] | 42 |
|
---|
[226] | 43 |
|
---|
[215] | 44 | @Override
|
---|
| 45 | public String toString()
|
---|
| 46 | {
|
---|
| 47 | return demandPlan.toString();
|
---|
| 48 | }
|
---|
[224] | 49 |
|
---|
[219] | 50 | public void setQuantity(Product p, Integer n)
|
---|
| 51 | {
|
---|
| 52 | demandPlan.put(p,n);
|
---|
| 53 | }
|
---|
[224] | 54 |
|
---|
| 55 |
|
---|
[226] | 56 | public void setWeight(Product p, Double e)
|
---|
| 57 | {
|
---|
| 58 | weight.put(p,e);
|
---|
| 59 | }
|
---|
| 60 |
|
---|
[219] | 61 | public Integer getQuantity(Product p)
|
---|
| 62 | {
|
---|
| 63 | if (this.demandPlan.containsKey(p))
|
---|
| 64 | return demandPlan.get(p);
|
---|
| 65 | else
|
---|
| 66 | return 0;
|
---|
| 67 | }
|
---|
| 68 |
|
---|
[226] | 69 | public Double getWeight(Product p)
|
---|
[219] | 70 | {
|
---|
[226] | 71 | if (this.weight.containsKey(p))
|
---|
| 72 | return weight.get(p);
|
---|
| 73 | else
|
---|
| 74 | return 0.0;
|
---|
[219] | 75 | }
|
---|
[224] | 76 |
|
---|
[226] | 77 | // public Set<Product> getKeys()
|
---|
| 78 | // {
|
---|
| 79 | // return demandPlan.keySet();
|
---|
| 80 | // }
|
---|
| 81 | //
|
---|
| 82 | //
|
---|
| 83 | // public Set<Integer> getValues()
|
---|
| 84 | // {
|
---|
| 85 | // return (Set<Integer>) demandPlan.values();
|
---|
| 86 | // }
|
---|
[210] | 87 | }
|
---|