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