Rev | Line | |
---|
[315] | 1 | /**
|
---|
| 2 | * Bundle class
|
---|
| 3 | */
|
---|
| 4 | package onetomany.bargainingchipsgame;
|
---|
| 5 |
|
---|
| 6 | import java.util.HashMap;
|
---|
| 7 | import java.util.Map;
|
---|
| 8 |
|
---|
| 9 | /**
|
---|
| 10 | * Can be used to build bundles easily.
|
---|
| 11 | */
|
---|
| 12 | public class WishListBuilder
|
---|
| 13 | {
|
---|
| 14 | private Map<Chip, Integer> f;
|
---|
| 15 |
|
---|
| 16 | /**
|
---|
| 17 | * Makes sure bundle remains unmodifiable.
|
---|
| 18 | */
|
---|
| 19 | public WishListBuilder()
|
---|
| 20 | {
|
---|
| 21 | f = new HashMap<Chip, Integer>();
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | /**
|
---|
| 25 | * Add a wish to the wish list, such as 3 x Green
|
---|
| 26 | */
|
---|
| 27 | public WishListBuilder addWish(String c, int q)
|
---|
| 28 | {
|
---|
| 29 | f.put(new Chip(c), q);
|
---|
| 30 | return this;
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | /**
|
---|
| 34 | * @return Immutable bundle
|
---|
| 35 | */
|
---|
| 36 | public WishList build()
|
---|
| 37 | {
|
---|
| 38 | return new WishList(f);
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.