[JAVA] Simple slot machine implementation that can be used with copy and paste

Simple slot machine implementation that can be used with copy and paste

51dfdc85977ada043ac57c858b1ee611.png

python


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Slot machine 1</title>
<style>
input {
	width:40px;
	font-size:30px;
	text-align:center;
}
button {
	width:50px;
}
.x1 {
	padding:10px 0;
}
.x1 div {
	float:left;
	width:60px;
	text-align:center;
}
</style>
<script>
window.onload = function() {
	var a = document.getElementById('a');
	var b1 = document.getElementById('b1');
	var b2 = document.getElementById('b2');
	var b3 = document.getElementById('b3');
	var c1 = document.getElementById('c1');
	var c2 = document.getElementById('c2');
	var c3 = document.getElementById('c3');
	var t1 = null;
	var t2 = null;
	var t3 = null;

	function start() {
		if (t1) {
			clearInterval(t1);
		}
		if (t2) {
			clearInterval(t2);
		}
		if (t3) {
			clearInterval(t3);
		}
		c1.value = Math.floor(Math.random() * 10);
		c2.value = Math.floor(Math.random() * 10);
		c3.value = Math.floor(Math.random() * 10);
		t1 = setInterval(function () {
			c1.value = (+c1.value + 1) % 10;
		}, 200);
		t2 = setInterval(function () {
			c2.value = (+c2.value + 1) % 10;
		}, 200);
		t3 = setInterval(function () {
			c3.value = (+c3.value + 1) % 10;
		}, 200);
	}

	function stop1() {
		if (t1) {
			clearInterval(t1);
			t1 = null;
		}
		check();
	}

	function stop2() {
		if (t2) {
			clearInterval(t2);
			t2 = null;
		}
		check();
	}

	function stop3() {
		if (t3) {
			clearInterval(t3);
			t3 = null;
		}
		check();
	}

	function check() {
		if (!t1 && !t2 && !t3) {
			if (c1.value == c2.value && c1.value == c3.value) {
				alert('Around!');
			} else {
				alert('Off!');
			}
		}
	}

	a.addEventListener('click', start);
	b1.addEventListener('click', stop1);
	b2.addEventListener('click', stop2);
	b3.addEventListener('click', stop3);

	start();
}
</script>
</head>
<body>
	<button type="button" id="a">start</button>
	<div class="x1">
		<div>
			<input type="text" id="c1">
			<button type="button" id="b1">stop</button>
		</div>
		<div>
			<input type="text" id="c2">
			<button type="button" id="b2">stop</button>
		</div>
		<div>
			<input type="text" id="c3">
			<button type="button" id="b3">stop</button>
		</div>
	</div>
</body>
</html>

That's all from the scene!

Recommended Posts

Simple slot machine implementation that can be used with copy and paste
Firebase-Realtime Database on Android that can be used with copy
[Swift] Color Picker that can be used with copy and paste (palette that allows you to freely select colors)
Organize methods that can be used with StringUtils
[Ruby] Methods that can be used with strings
Performance analysis and failure diagnostic tools that can be used with OpenJDK
Summary of css selectors that can be used with Nookogiri
Create a page control that can be used with RecyclerView
Syntax and exception occurrence conditions that can be used when comparing with null in Java
Copy and paste test with RSpec
SwiftUI View that can be used in combination with other frameworks
[Rails] "pry-rails" that can be used when saving with the create method
Ruby array methods that can be used with Rails (other than each)
Compiled kotlin with cli with docker and created an environment that can be executed with java
Range where variables can be used with ruby [Scope]
About the matter that hidden_field can be used insanely
Convenient shortcut keys that can be used in Eclipse
[Java 8] Sorting method in alphabetical order and string length order that can be used in coding tests
Learning Ruby with AtCoder Beginners Selection [Some Sums] Increase the methods that can be used
Four-in-a-row with gravity that can be played on the console
Problems that can easily be mistaken for Java and JavaScript
List of copy and paste collections that are useful when creating apps with Ruby on Rails
Static analysis tool that can be used on GitHub [Java version]
Summary of ORM "uroboroSQL" that can be used in enterprise Java
File form status check sheet that can be deleted with thumbnails
I made a question that can be used for a technical interview
Power skills that can be used quickly at any time --Reflection
About the range and scope where Day16 variables can be used
Summary of JDK that can be installed with Homebrew (as of November 2019)
Introduction to Java that can be understood even with Krillin (Part 1)
[OpenJDK11 & JavaFX13] Build a javaFX app with IntelliJ + gradle and create a package that can be distributed with a lightweight JRE