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