Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import static java.lang.System.*;
- public class Koronda {
- public static void main(String[] args) {
- play();
- }
- public static void play() {
- Scanner scan = new Scanner(in);
- out.println("ダルマさんが転んだ!をします\n"
- + "5回以内に8歩分進めばクリアです\n"
- + "多く進めばオニに見つかる可能性も上がります");
- out.println();
- int count = 8;
- int step;
- boolean isSafe = true;
- for (int i = 5; i >= 1; i--) {
- do {
- out.println("残り" + count + "歩分、あと" + i + "回です\n"
- + "何歩進みますか?0~8を入力して下さい");
- step = scan.nextInt();
- if (0 <= step && step <= 8) break;
- out.println("0~8を入力して下さい\n");
- } while (true);
- out.println("オニ「ダルマさんが…転んだ!」\n");
- switch (step) {
- case 0:
- out.println("オニ「…」");
- break;
- case 1:
- if (Math.random() <= 0.9) {
- out.println("オニ「…」");
- count -= 1;
- } else {
- out.println("オニ「アウト!」");
- isSafe = false;
- }
- break;
- case 2:
- if (Math.random() <= 0.75) {
- out.println("オニ「…」");
- count -= 2;
- } else {
- out.println("オニ「アウト!」");
- isSafe = false;
- }
- break;
- case 3:
- if (Math.random() <= 0.5) {
- out.println("オニ「…」");
- count -= 3;
- } else {
- out.println("オニ「アウト!」");
- isSafe = false;
- }
- break;
- case 4:
- if (Math.random() <= 0.35) {
- out.println("オニ「…」");
- count -= 4;
- } else {
- out.println("オニ「アウト!」");
- isSafe = false;
- }
- break;
- case 5:
- if (Math.random() <= 0.2) {
- out.println("オニ「…」");
- count -= 5;
- } else {
- out.println("オニ「アウト!」");
- isSafe = false;
- }
- break;
- case 6:
- if (Math.random() <= 0.1) {
- out.println("オニ「…」");
- count -= 6;
- } else {
- out.println("オニ「アウト!」");
- isSafe = false;
- }
- break;
- case 7:
- if (Math.random() <= 0.05) {
- out.println("オニ「…」");
- count -= 7;
- } else {
- out.println("オニ「アウト!」");
- isSafe = false;
- }
- break;
- case 8:
- if (Math.random() <= 0.01) {
- out.println("オニ「…」");
- count -= 8;
- } else {
- out.println("オニ「アウト!」");
- isSafe = false;
- }
- break;
- }
- if (!isSafe) break;
- if (count <= 0) break;
- out.println();
- }
- if (!isSafe) {
- out.println("オニに見つかってしまいました!あなたの負けです!");
- } else if (count <= 0) {
- out.println("オニにタッチ!あなたの勝ちです!");
- } else {
- out.println("残念!オニにタッチ出来ませんでした!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement