ズンドコキヨシ(Java, リズム重視版)

無断転載禁止 ズンドコキヨシ(Java, リズム重視版)

社内でご指名いただきましたので、Javaでやってみました。
ことの発端はこちらを参照ください→ 例のズンドコキヨシに参加してみた。

こちらはリズム重視です。ズンの後に少し間が開くのでちょっとドキドキしますね。
下の方に実行結果をgifアニメにして置いておきましたのでぜひご覧ください。

 


import java.util.Random;

public class Zundoko{
	final static String[] ZUNDOKO = {"ズン", "ドコ"};
	static Random rnd = new Random();
	static String out = "";
	static Status s = Status.DOKO;
	static int ainoteWait = 100;
	
	
	public static void main(String[] args) {
		while(true) {
			out = zunOrDoko();
			System.out.println(out);
			
			if (s.next.equals(out)) {
				s = Status.values()[s.ordinal() + 1];
			} else {
				s = Status.DOKO;
				System.out.println();
			}

			try{
				Thread.sleep(s.wait);
			} catch(InterruptedException e) {}
			
			if (Status.ZUNZUZUNZUNDOKO == s) {
				break;
			}
		}
		System.out.print("キ");
		try{Thread.sleep(ainoteWait);} catch(InterruptedException e) {}
		System.out.print("・");
		try{Thread.sleep(ainoteWait);} catch(InterruptedException e) {}
		System.out.print("ヨ");
		try{Thread.sleep(ainoteWait);} catch(InterruptedException e) {}
		System.out.print("・");
		try{Thread.sleep(ainoteWait);} catch(InterruptedException e) {}
		System.out.print("シ");
		try{Thread.sleep(ainoteWait);} catch(InterruptedException e) {}
		System.out.print("!");
		System.out.println();
	}
	
	
	
	static String zunOrDoko() {
		return ZUNDOKO[Math.abs(rnd.nextInt() % 2)];
	}

	enum Status {
		DOKO("ズン", 0),
		ZUN("ズン", 1000),
		ZUNZUN("ズン", 500),
		ZUNZUZUN("ズン", 500),
		ZUNZUZUNZUN("ドコ", 500),
		ZUNZUZUNZUNDOKO("", 500);
	
		final String next;
		final int wait;
		private Status(String next, int wait){
			this.next = next;
			this.wait = wait;
		}
	}
	
}

 

実行結果は以下のとおり。

zundoko

zundoko

今回何が大変だったって、このgifアニメ作るところですかね。。なにぶん初めてなもので。
しかも元動画は1分半ぐらいズンドコやってましたし。

Pocket
LINEで送る