Advertisement
Guest User

Untitled

a guest
Jan 10th, 2020
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. import java.util.Scanner;
  2. import static java.lang.System.*;
  3.  
  4. public class Koronda {
  5. public static void main(String[] args) {
  6. play();
  7. }
  8.  
  9. public static void play() {
  10. Scanner scan = new Scanner(in);
  11.  
  12. out.println("ダルマさんが転んだ!をします\n"
  13. + "5回以内に8歩分進めばクリアです\n"
  14. + "多く進めばオニに見つかる可能性も上がります");
  15. out.println();
  16.  
  17. int count = 8;
  18. int step;
  19. boolean isSafe = true;
  20.  
  21. for (int i = 5; i >= 1; i--) {
  22. do {
  23. out.println("残り" + count + "歩分、あと" + i + "回です\n"
  24. + "何歩進みますか?0~8を入力して下さい");
  25. step = scan.nextInt();
  26. if (0 <= step && step <= 8) break;
  27. out.println("0~8を入力して下さい\n");
  28. } while (true);
  29.  
  30. out.println("オニ「ダルマさんが…転んだ!」\n");
  31. switch (step) {
  32. case 0:
  33. out.println("オニ「…」");
  34. break;
  35. case 1:
  36. if (Math.random() <= 0.9) {
  37. out.println("オニ「…」");
  38. count -= 1;
  39. } else {
  40. out.println("オニ「アウト!」");
  41. isSafe = false;
  42. }
  43. break;
  44. case 2:
  45. if (Math.random() <= 0.75) {
  46. out.println("オニ「…」");
  47. count -= 2;
  48. } else {
  49. out.println("オニ「アウト!」");
  50. isSafe = false;
  51. }
  52. break;
  53. case 3:
  54. if (Math.random() <= 0.5) {
  55. out.println("オニ「…」");
  56. count -= 3;
  57. } else {
  58. out.println("オニ「アウト!」");
  59. isSafe = false;
  60. }
  61. break;
  62. case 4:
  63. if (Math.random() <= 0.35) {
  64. out.println("オニ「…」");
  65. count -= 4;
  66. } else {
  67. out.println("オニ「アウト!」");
  68. isSafe = false;
  69. }
  70. break;
  71. case 5:
  72. if (Math.random() <= 0.2) {
  73. out.println("オニ「…」");
  74. count -= 5;
  75. } else {
  76. out.println("オニ「アウト!」");
  77. isSafe = false;
  78. }
  79. break;
  80. case 6:
  81. if (Math.random() <= 0.1) {
  82. out.println("オニ「…」");
  83. count -= 6;
  84. } else {
  85. out.println("オニ「アウト!」");
  86. isSafe = false;
  87. }
  88. break;
  89. case 7:
  90. if (Math.random() <= 0.05) {
  91. out.println("オニ「…」");
  92. count -= 7;
  93. } else {
  94. out.println("オニ「アウト!」");
  95. isSafe = false;
  96. }
  97. break;
  98. case 8:
  99. if (Math.random() <= 0.01) {
  100. out.println("オニ「…」");
  101. count -= 8;
  102. } else {
  103. out.println("オニ「アウト!」");
  104. isSafe = false;
  105. }
  106. break;
  107. }
  108. if (!isSafe) break;
  109. if (count <= 0) break;
  110. out.println();
  111. }
  112. if (!isSafe) {
  113. out.println("オニに見つかってしまいました!あなたの負けです!");
  114. } else if (count <= 0) {
  115. out.println("オニにタッチ!あなたの勝ちです!");
  116. } else {
  117. out.println("残念!オニにタッチ出来ませんでした!");
  118. }
  119. }
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement