Skip to content

Instantly share code, notes, and snippets.

@kozake
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kozake/382c64950411c904c2f2 to your computer and use it in GitHub Desktop.
Save kozake/382c64950411c904c2f2 to your computer and use it in GitHub Desktop.
しょぼちむ Advent Calendar 2014 のソース(おこづかい)
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