import java.util.ArrayList; import java.util.List; import java.util.Random; /** * This utility class simulates a one armed bandit. * * @author Franck van Breugel */ public class OneArmedBandit { private OneArmedBandit() {} /** * Returns the coins from one pull. * * @param coin the coin deposited in the one armed bandit. * @return the payoff from one pull of the lever. */ public static List pull(Coin coin) { Random random = new Random(System.currentTimeMillis()); final int MAX = 25; final int THRESHOLD = 10; List result = new ArrayList(); int choice = random.nextInt(MAX + 1); if (choice < THRESHOLD) { for (int c = 0; c < choice; c++) { result.add(Coin.getInstance()); } } return result; } }