Last active
August 29, 2015 14:10
-
-
Save kozake/382c64950411c904c2f2 to your computer and use it in GitHub Desktop.
しょぼちむ Advent Calendar 2014 のソース(おこづかい)
This file contains 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 syobochim; | |
import java.math.BigDecimal; | |
import java.util.stream.Stream; | |
public enum おこづかい { | |
金欠("金欠だ~ヽ(;▽;)ノ"), | |
金ならあるんだ("金ならあるんだ!!(((o(*゚▽゚*)o)))") | |
; | |
String val; | |
おこづかい(String val) { | |
this.val = val; | |
} | |
@Override | |
public String toString() { | |
return val; | |
} | |
public static Stream<可能性<おこづかい>> のこるの(可能性<支払い> おごり) { | |
BigDecimal 確率 = おごり.確率; | |
switch (おごり.選択肢) { | |
case おごるよ: | |
return Stream.of( | |
可能性.create(金欠 | |
, new BigDecimal("0.9").multiply(確率)) | |
, 可能性.create(金ならあるんだ | |
, new BigDecimal("0.1").multiply(確率)) | |
); | |
case ごちになります: | |
return Stream.of( | |
可能性.create(金欠 | |
, new BigDecimal("0.1").multiply(確率)) | |
, 可能性.create(金ならあるんだ | |
, new BigDecimal("0.9").multiply(確率)) | |
); | |
case 割り勘: | |
return Stream.of( | |
可能性.create(金欠 | |
, new BigDecimal("0.7").multiply(確率)) | |
, 可能性.create(金ならあるんだ | |
, new BigDecimal("0.3").multiply(確率)) | |
); | |
default: | |
return Stream.of( | |
可能性.create(金欠 | |
, new BigDecimal("1.0").multiply(確率)) | |
); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment