Net Core教程

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

这篇关于C#简单的石头剪刀布游戏 初学不算太好马上更新的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!