编程语言
首页 > 编程语言> > C#简单的石头剪刀布游戏 初学不算太好马上更新

C#简单的石头剪刀布游戏 初学不算太好马上更新

作者:互联网

using System;
using System.Dynamic;

namespace WSL
{
    class main : Many
    {
        static void Main(String[] args)
        {
            main ma = new main();
            ma.Player = 3;
            ma.SystemPlayer = 1;
            ma.Game(ma.Player,ma.SystemPlayer);
            if (Many.Win == false)
            {
                Console.WriteLine("输了");
            }
            else if (Many.Win == true)
            {
                Console.WriteLine("赢了awa");
            }
            else if(Many.Winner == true)
            {
                Console.WriteLine("平局");
            }
        }
    }

    class Many
    {
        private Random random = new Random();
        
        protected int Q { get; set; }
        protected int Player { get; set; }
        protected int SystemPlayer { get; set; }
        protected static bool Win { get; set; }
        protected static bool Winner { get; set; }
        

        protected void Game(int PlayerInput,int SystemPlayerInput)
        {
            if (PlayerInput != SystemPlayerInput)
            {
                Many.PlayerInNumberOne(PlayerInput,SystemPlayerInput);
            }
            else
            {
                Many.Winner = true;
                
            }  
        }

        protected static void PlayerInNumberOne(int PlayerInput, int SystemPlayerInput)
        {
            if ((PlayerInput == 1 || PlayerInput == 3) && (SystemPlayerInput == 1 || SystemPlayerInput == 3))
            {
                Many.Win = (PlayerInput < SystemPlayerInput) ? true : false;
            }
            else
            {
                Many.Win = (PlayerInput > SystemPlayerInput) ? true : false;
                
            }
        }
    }
}

石头剪刀布游戏,3是剪刀 2是布 1是石头  Player是玩家 SystemPlayer是系统玩家

第一次写,不是太好qwq

标签:太好,PlayerInput,ma,C#,Many,SystemPlayerInput,int,初学,protected
来源: https://blog.csdn.net/flexyacc/article/details/121230997