Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Media;
- using System.Text;
- using System.Threading.Tasks;
- namespace SSP
- {
- public class Program
- {
- static void Main(string[] args)
- {
- var game = new Game(new Random());
- while (Console.ReadLine() != "stop")
- {
- game.Play();
- }
- }
- }
- public class Game
- {
- private readonly Random random;
- readonly string[] items = {"Камень", "Ножницы", "Бумага"};
- readonly string[] winner = {"Первый", "Второй", "Ничья"};
- public Game(Random random)
- {
- this.random = random;
- }
- public void Play()
- {
- var indexes = new[] {random.Next(3), random.Next(3)};
- Console.WriteLine($"{items[indexes[0]]} vs {items[indexes[1]]}. Winner: {WhoWinner(indexes)}");
- }
- private string WhoWinner(int[] indexes)
- {
- if (indexes[0] == indexes[1])
- {
- return winner[2];
- }
- if (indexes[0] < indexes[1])
- {
- if (indexes[1] - indexes[0] == 1)
- {
- return winner[0];
- }
- return winner[1];
- }
- if (indexes[0] - indexes[1] == 1)
- {
- return winner[1];
- }
- else
- {
- return winner[0];
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement