Last active
May 3, 2024 17:53
-
-
Save asasu-m/732319d885e82bbf9b7ae966ded7a7dc to your computer and use it in GitHub Desktop.
おみくじのプログラム作ってみました
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
import java.util.Random; | |
import java.util.Scanner; | |
public class uranai { | |
public static void main(String[] args) | |
{ | |
new uranai(); | |
} | |
uranai() | |
{ | |
System.out.println("これから占いをします。さて、あなたの運勢は・・"); | |
System.out.println("さあ、ひとつ札を引いてください‥"); | |
System.out.println("(1):赤札 (2):黄札 (3):黒札"); | |
Scanner sc = new Scanner(System.in); | |
int uranaiHuda=sc.nextInt(); | |
String hudaMei=""; | |
if(uranaiHuda==1) | |
{ | |
hudaMei="赤札"; | |
}else if(uranaiHuda==2) | |
{ | |
hudaMei="黄札"; | |
}else if(uranaiHuda==3) | |
{ | |
hudaMei="黒札"; | |
}else | |
{ | |
hudaMei="選んではいけない札"; | |
System.out.println("それを選びましたか・・"); | |
System.out.println("ゲームオーバー・・"); | |
return; | |
} | |
System.out.println(hudaMei+"を選びましたね・・さあ結果は・・"); | |
Random rnd = new Random(); | |
int unsei=rnd.nextInt(4); | |
switch(unsei) | |
{ | |
case 0: | |
System.out.println("あなたは・・大吉です!今週はいいことありそう!"); | |
break; | |
case 1: | |
System.out.println("あなたは・・中吉です!何事も挑戦してみましょう。いいことあるかも"); | |
break; | |
case 2: | |
System.out.println("あなたは・・吉です!人生山あり谷ありですくじけず頑張りましょう"); | |
break; | |
case 3: | |
System.out.println("あなたは・・凶です!今週はおとなしく静かに過ごしていた方がよさそう・・"); | |
break; | |
default: | |
//ここにとうたつすることはない。 | |
System.out.println("ふはは。ひっかかったな!"); | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment