Created
April 27, 2013 13:49
-
-
Save anonymous/5473191 to your computer and use it in GitHub Desktop.
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 Roulette; | |
import java.text.MessageFormat; | |
public class Outcome<E> implements Comparable<E> { | |
public String name; | |
public int odds; | |
public Outcome(String name, int odds){ | |
this.name = name; | |
this.odds = odds; | |
} | |
public int winAmount(int amount){ | |
return amount*this.odds; | |
} | |
public boolean equals(Outcome<E> other){ | |
return (this.name.equals(other.name)); | |
} | |
public String toString() { | |
Object[] values= { name, new Integer(odds) }; | |
String msgTempl= "{0} ({1}:1)"; | |
return MessageFormat.format( msgTempl, values ); | |
} | |
@Override | |
public int compareTo(E arg0) { | |
if(this.equals(arg0)){ | |
return 0; | |
} | |
return 1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment