package com.mycompany;
public class Main {
public static void main
(String[] args
) { System.
out.
println("Let's get it started!"); Turn t1;
Turn t2;
do {
t1 = Turn.random();
System.
out.
printf("Игрок 1 выбирает %s%n", t1.
definition); t2 = Turn.random();
System.
out.
printf("Игрок 2 выбирает %s%n", t2.
definition); if (t1 == t2) {
System.
out.
println("Ничья, повтор хода!"); }
} while (t1 == t2);
if (Math.
abs(t1.
order - t2.
order) == 2) { if (t1.order < t2.order) {
t2.order -= 3;
} else {
t1.order -= 3;
}
}
System.
out.
println(t1.
order < t2.
order ? "Игрок 1 побеждает!" : "Игрок 2 побеждает!"); }
private enum Turn {
ROCK(0, "Камень"),
SCISSORS(1, "Ножницы"),
PAPER(2, "Бумага");
int order;
Turn
(int order,
String definition
) { this.order = order;
this.definition = definition;
}
public static Turn random() {
switch ((int)(Math.
random() * 3)) { case 0: return ROCK;
case 1: return SCISSORS;
default: return PAPER;
}
}
}
}
cGFja2FnZSBjb20ubXljb21wYW55OwoKcHVibGljIGNsYXNzIE1haW4gewogICAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiTGV0J3MgZ2V0IGl0IHN0YXJ0ZWQhIik7CiAgICAgICAgVHVybiB0MTsKICAgICAgICBUdXJuIHQyOwogICAgICAgIGRvIHsKICAgICAgICAgICAgdDEgPSBUdXJuLnJhbmRvbSgpOwogICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50Zigi0JjQs9GA0L7QuiAxINCy0YvQsdC40YDQsNC10YIgJXMlbiIsIHQxLmRlZmluaXRpb24pOwogICAgICAgICAgICB0MiA9IFR1cm4ucmFuZG9tKCk7CiAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRmKCLQmNCz0YDQvtC6IDIg0LLRi9Cx0LjRgNCw0LXRgiAlcyVuIiwgdDIuZGVmaW5pdGlvbik7CiAgICAgICAgICAgIGlmICh0MSA9PSB0MikgewogICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCLQndC40YfRjNGPLCDQv9C+0LLRgtC+0YAg0YXQvtC00LAhIik7CiAgICAgICAgICAgIH0KICAgICAgICB9IHdoaWxlICh0MSA9PSB0Mik7CiAgICAgICAgaWYgKE1hdGguYWJzKHQxLm9yZGVyIC0gdDIub3JkZXIpID09IDIpIHsKICAgICAgICAgICAgaWYgKHQxLm9yZGVyIDwgdDIub3JkZXIpIHsKICAgICAgICAgICAgICAgIHQyLm9yZGVyIC09IDM7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICB0MS5vcmRlciAtPSAzOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbih0MS5vcmRlciA8IHQyLm9yZGVyID8gItCY0LPRgNC+0LogMSDQv9C+0LHQtdC20LTQsNC10YIhIiA6ICLQmNCz0YDQvtC6IDIg0L/QvtCx0LXQttC00LDQtdGCISIpOwogICAgfQoKICAgIHByaXZhdGUgZW51bSBUdXJuIHsKICAgICAgICBST0NLKDAsICLQmtCw0LzQtdC90YwiKSwKICAgICAgICBTQ0lTU09SUygxLCAi0J3QvtC20L3QuNGG0YsiKSwKICAgICAgICBQQVBFUigyLCAi0JHRg9C80LDQs9CwIik7CiAgICAgICAgaW50IG9yZGVyOwogICAgICAgIFN0cmluZyBkZWZpbml0aW9uOwogICAgICAgIFR1cm4oaW50IG9yZGVyLCBTdHJpbmcgZGVmaW5pdGlvbikgewogICAgICAgICAgICB0aGlzLm9yZGVyID0gb3JkZXI7CiAgICAgICAgICAgIHRoaXMuZGVmaW5pdGlvbiA9IGRlZmluaXRpb247CiAgICAgICAgfQogICAgICAgIHB1YmxpYyBzdGF0aWMgVHVybiByYW5kb20oKSB7CiAgICAgICAgICAgIHN3aXRjaCAoKGludCkoTWF0aC5yYW5kb20oKSAqIDMpKSB7CiAgICAgICAgICAgICAgICBjYXNlIDA6IHJldHVybiBST0NLOwogICAgICAgICAgICAgICAgY2FzZSAxOiByZXR1cm4gU0NJU1NPUlM7CiAgICAgICAgICAgICAgICBkZWZhdWx0OiByZXR1cm4gUEFQRVI7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9Cn0K