Created
November 7, 2016 09:24
-
-
Save naka-Eff/16e766a48f080cd8c0a8ea8410463f87 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 mtkdQuestOne; | |
import java.util.Random; | |
public class start { | |
private static final int FOUR = 4; | |
private static final String zun = "ズン"; | |
private static final String doko = "ドコ"; | |
public static void main(String[] args) { | |
boolean flag = true; | |
String n[] = new String[5]; | |
while (flag) { | |
int i = 0; | |
n[i] = getRandom(); | |
// 1回目 | |
if (exe(n, i)) { | |
continue; | |
} else { | |
i++; | |
n[i] = getRandom(); | |
// 2回目 | |
if (exe(n, i)) { | |
i = 0; | |
continue; | |
} else { | |
i++; | |
n[i] = getRandom(); | |
// 3回目 | |
if (exe(n, i)) { | |
i = 0; | |
continue; | |
} else { | |
i++; | |
n[i] = getRandom(); | |
// 4回目 | |
if (exe(n, i)) { | |
i = 0; | |
continue; | |
} else{ | |
i++; | |
n[i] = getRandom(); | |
// last | |
if(exe(n, i)){ | |
System.out.println("finish"); | |
for(String str: n){ | |
System.out.println(str); | |
} | |
System.out.println("キヨシ!"); | |
break; | |
}else{ | |
i = 0; | |
continue; | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
private static String getRandom() { | |
Random rnd = new Random(); | |
int x = rnd.nextInt(10); | |
if (x <= FOUR) { | |
return zun; | |
} | |
return doko; | |
} | |
private static boolean exe(String[] kiyosi, int num) { | |
if (kiyosi[num].equals(doko)) { | |
return true; | |
} | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment