Created
December 10, 2010 04:47
-
-
Save janogonzalez/735800 to your computer and use it in GitHub Desktop.
Lucky 13: Roulette mini DSL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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