Rev | Line | |
---|
[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;
|
---|
[210] | 23 |
|
---|
[215] | 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 | }
|
---|
[224] | 41 |
|
---|
[219] | 42 | public void setQuantity(Product p, Integer n)
|
---|
| 43 | {
|
---|
| 44 | demandPlan.put(p,n);
|
---|
| 45 | }
|
---|
[224] | 46 |
|
---|
| 47 |
|
---|
[219] | 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 |
|
---|
[224] | 56 |
|
---|
| 57 |
|
---|
[219] | 58 | public Set<Product> getKeys()
|
---|
| 59 | {
|
---|
| 60 | return demandPlan.keySet();
|
---|
| 61 | }
|
---|
[224] | 62 |
|
---|
| 63 |
|
---|
[219] | 64 | public Set<Integer> getValues()
|
---|
| 65 | {
|
---|
| 66 | return (Set<Integer>) demandPlan.values();
|
---|
| 67 | }
|
---|
[210] | 68 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.