Last change
on this file since 274 was 272, checked in by Tim Baarslag, 5 years ago |
Bundle immutable. Made aggregation work.
|
File size:
613 bytes
|
Rev | Line | |
---|
[272] | 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 BundleBuilder
|
---|
| 14 | {
|
---|
| 15 | private List<Stack> bundle;
|
---|
| 16 |
|
---|
| 17 | /**
|
---|
| 18 | * Makes sure bundle remains unmodifiable.
|
---|
| 19 | */
|
---|
| 20 | public BundleBuilder()
|
---|
| 21 | {
|
---|
| 22 | this.bundle = new ArrayList<Stack>();
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | public BundleBuilder addStack(String c, double p, int q)
|
---|
| 26 | {
|
---|
| 27 | bundle.add(new Stack(c, p, q));
|
---|
| 28 | return this;
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | /**
|
---|
| 32 | * @return Immutable bundle
|
---|
| 33 | */
|
---|
| 34 | public Bundle build()
|
---|
| 35 | {
|
---|
| 36 | return new Bundle(bundle);
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.