source: src/main/java/bargainingchips/wishlist/WishListBuilder.java@ 343

Last change on this file since 343 was 340, checked in by Tim Baarslag, 5 years ago

Change BilateralProtocol loop to avoid busy wait; note that this fixes only a part of the busy wait problem.

Package structure now in line with latest Acumex discussions.

Pinpointed error avoidance in Agent.

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