Skip to content

Instantly share code, notes, and snippets.

@janogonzalez
Created December 10, 2010 04:47
Show Gist options
  • Save janogonzalez/735800 to your computer and use it in GitHub Desktop.
Save janogonzalez/735800 to your computer and use it in GitHub Desktop.
Lucky 13: Roulette mini DSL
package com.janogonzalez.engineyard;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Scanner;
public class Roulette {
private long expected, actual, bet;
private Roulette(long bet) { this.bet = bet; }
public static Roulette bet(long bet) { return new Roulette(bet); }
public Roulette to(long expected) { this.expected = expected; return this; }
public Roulette roll() throws IOException { this.actual = Long.parseLong((new Scanner((InputStream) new URL("http://roulette.engineyard.com/").getContent())).findInLine("\\d+")); return this; }
public long payout() { return (actual == expected) ? (bet * 35) : 0; }
public static void main(String[] args) throws IOException {
System.out.println(Roulette.bet(100000).to(13).roll().payout());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment