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