From 42c50b286030e7c71d53b421bd3fa552a9b3c1c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=8C=E6=98=82?= <2636153719@qq.com> Date: Fri, 4 Jun 2021 16:30:19 +0800 Subject: [PATCH 01/74] =?UTF-8?q?=E8=92=B2=E6=99=93=E9=AA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\350\222\262\346\231\223\351\252\217/NPC.cs" | 25 +++++ .../Program.cs" | 101 ++++++++++++++++++ .../Publicinfo.cs" | 23 ++++ .../player.cs" | 24 +++++ 4 files changed, 173 insertions(+) create mode 100644 "\350\222\262\346\231\223\351\252\217/NPC.cs" create mode 100644 "\350\222\262\346\231\223\351\252\217/Program.cs" create mode 100644 "\350\222\262\346\231\223\351\252\217/Publicinfo.cs" create mode 100644 "\350\222\262\346\231\223\351\252\217/player.cs" diff --git "a/\350\222\262\346\231\223\351\252\217/NPC.cs" "b/\350\222\262\346\231\223\351\252\217/NPC.cs" new file mode 100644 index 0000000..7f7a6bf --- /dev/null +++ "b/\350\222\262\346\231\223\351\252\217/NPC.cs" @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class NPC:Publicinfo + { + public NPC(string name):base(name) + { + this.Name = name; + } + public override int fist() + { + Random r = new Random(); + int a = r.Next(3) + 1; + + return a; + } + + + } +} diff --git "a/\350\222\262\346\231\223\351\252\217/Program.cs" "b/\350\222\262\346\231\223\351\252\217/Program.cs" new file mode 100644 index 0000000..82933eb --- /dev/null +++ "b/\350\222\262\346\231\223\351\252\217/Program.cs" @@ -0,0 +1,101 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + enum npcname + { + 刘备=1, + 孙权, + 曹操 + } + enum fist + { + 剪刀=1, + 石头, + 布 + } + class Program + { + + static void Main(string[] args) + { + int pgroud = 0; + int ngroud = 0; + int session = 0; + Console.WriteLine("----游戏即将开始----"); + Console.WriteLine("--------------------"); + Console.WriteLine("-----猜拳·开始-----"); + Console.WriteLine("--------------------"); + Console.WriteLine("出拳规则:1、剪刀 2、 石头 3、 布"); + Console.WriteLine("请选择对方角色:1、刘备 2 、孙权 3、 曹操 (请输入相应数字)"); + int choose1 = int.Parse(Console.ReadLine()); + npcname f = (npcname)choose1; + + Console.WriteLine("请输入您的名字"); + string play = Console.ReadLine(); + player player = new player(play); + game(f,ref pgroud, ref ngroud, ref session,player); + + } + public static void game(npcname f, ref int pgroud, ref int ngroud, ref int session,player player) + { + NPC npc = new NPC(f.ToString()); + int a = player.fist(); + fist playfist = (fist)a; + int b = npc.fist(); + fist npcfist = (fist)b; + Console.WriteLine("{0}出的拳为{1}", player.Name, playfist); + Console.WriteLine("{0}出的拳为{1}", npc.Name, npcfist); + string a1 = playfist.ToString(); + string a2 = npcfist.ToString(); + judge(a1, a2, ref pgroud, ref ngroud, ref session); + Console.WriteLine("是否开始下一轮 1、继续 2 、停止 "); + int choose = int.Parse(Console.ReadLine()); + switch (choose) + { + case 1: + game(f, ref pgroud, ref ngroud, ref session, player); + break; + case 2: + Console.WriteLine("{0}对阵{1}",player.Name,npc.Name); + Console.WriteLine("对阵次数{0}",session); + Console.WriteLine("姓名 得分"); + Console.WriteLine("{0} {1}",player.Name,pgroud); + Console.WriteLine("{0} {1}", npc.Name, ngroud); + break; + default: + Console.WriteLine("输入错误,重新开始"); + game(f, ref pgroud, ref ngroud, ref session, player); + break; + } + } + public void a() + { + + } + public static void judge(string player, string npcfist, ref int pgroud, ref int ngroud,ref int session) + { + if (player.Equals("石头") && npcfist.Equals("剪刀")|| player.Equals("剪刀") && npcfist.Equals("布")|| player.Equals("布") && npcfist.Equals("石头")) + { + Console.WriteLine("你获得胜利"); + pgroud++; + session++; + } + else if (player.Equals(npcfist)) + { + Console.WriteLine("平局了"); + session++; + } + else + { + Console.WriteLine("你输了"); + ngroud++; + session++; + } + } + } +} diff --git "a/\350\222\262\346\231\223\351\252\217/Publicinfo.cs" "b/\350\222\262\346\231\223\351\252\217/Publicinfo.cs" new file mode 100644 index 0000000..aebf75e --- /dev/null +++ "b/\350\222\262\346\231\223\351\252\217/Publicinfo.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Publicinfo + { + public string Name { get; set; } + + public Publicinfo(string name) + { + Name = name; + } + public virtual int fist() + { + return 0; + } + + } +} diff --git "a/\350\222\262\346\231\223\351\252\217/player.cs" "b/\350\222\262\346\231\223\351\252\217/player.cs" new file mode 100644 index 0000000..c24f2f5 --- /dev/null +++ "b/\350\222\262\346\231\223\351\252\217/player.cs" @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class player : Publicinfo + { + public player(string name) : base(name) + { + this.Name = name; + } + public override int fist() + { + Console.WriteLine("请出拳:1、剪刀 2 、石头 3、 布 (请输入相应数字)"); + int choose2 = int.Parse(Console.ReadLine()); + return choose2; + } + + + } +} -- Gitee From 764364c305bf8a9e51fef72fd744b7b5b2dec675 Mon Sep 17 00:00:00 2001 From: mao Date: Fri, 4 Jun 2021 16:35:24 +0800 Subject: [PATCH 02/74] 2021-6-4 16:35 --- .../IJanKenPunch].cs" | 14 +++ .../Judgment.cs" | 110 ++++++++++++++++++ "\351\231\210\350\257\227\346\235\260/NPC.cs" | 44 +++++++ .../Player.cs" | 30 +++++ .../Program.cs" | 110 ++++++++++++++++++ 5 files changed, 308 insertions(+) create mode 100644 "\351\231\210\350\257\227\346\235\260/IJanKenPunch].cs" create mode 100644 "\351\231\210\350\257\227\346\235\260/Judgment.cs" create mode 100644 "\351\231\210\350\257\227\346\235\260/NPC.cs" create mode 100644 "\351\231\210\350\257\227\346\235\260/Player.cs" create mode 100644 "\351\231\210\350\257\227\346\235\260/Program.cs" diff --git "a/\351\231\210\350\257\227\346\235\260/IJanKenPunch].cs" "b/\351\231\210\350\257\227\346\235\260/IJanKenPunch].cs" new file mode 100644 index 0000000..ce96a62 --- /dev/null +++ "b/\351\231\210\350\257\227\346\235\260/IJanKenPunch].cs" @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _2021_6_4 +{ + interface IJanKenPunch_ + { + janKenPunch DoJanKenPunch(); + janKenPunch DoJanKenPunch(int key); + } +} diff --git "a/\351\231\210\350\257\227\346\235\260/Judgment.cs" "b/\351\231\210\350\257\227\346\235\260/Judgment.cs" new file mode 100644 index 0000000..cf5e0aa --- /dev/null +++ "b/\351\231\210\350\257\227\346\235\260/Judgment.cs" @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _2021_6_4 +{ + class Judgment + { + public string playerName; + public int playerScore; + public string npcName; + public int npcScore; + public int countBattle; + + public Judgment(string Player , string Npc) + { + this.playerName = Player; + this.npcName = Npc; + } + public void Decide(janKenPunch player , janKenPunch npc) + { + //玩家出剪刀的情况 + if (player == janKenPunch.剪刀) + { + if (npc == janKenPunch.剪刀) + { + countBattle++; + Console.WriteLine("和局"); + } + else if (npc == janKenPunch.布) + { + countBattle++; + playerScore++; + Console.WriteLine($"{playerName}胜!"); + } + else + { + countBattle++; + npcScore++; + Console.WriteLine($"{npcName}胜!"); + } + } + //出石头的情况 + else if (player == janKenPunch.石头) + { + if (npc == janKenPunch.石头) + { + countBattle++; + Console.WriteLine("和局"); + } + else if (npc == janKenPunch.剪刀) + { + countBattle++; + playerScore++; + Console.WriteLine($"{playerName}胜!"); + } + else + { + countBattle++; + npcScore++; + Console.WriteLine($"{npcName}胜!"); + } + } + //出布的情况 + else + { + if (npc == janKenPunch.布) + { + countBattle++; + Console.WriteLine("和局"); + } + else if (npc == janKenPunch.石头) + { + countBattle++; + playerScore++; + Console.WriteLine($"{playerName}胜!"); + } + else + { + countBattle++; + npcScore++; + Console.WriteLine($"{npcName}胜!"); + + } + } + } + + public override string ToString() + { + string result; + + if (playerScore > npcScore) + { + result = $"{playerName}赢!"; + } + else if (playerScore < npcScore) + { + result = $"{npcName}赢!"; + } + else + { + result = "但是谁也没有赢"; + } + + return $"{playerName} VS {npcName}\n对局次数:{countBattle}\r\n姓名\t得分\n{playerName}\t{playerScore}\n{npcName}\t{npcScore}\n" + result; + } + } +} diff --git "a/\351\231\210\350\257\227\346\235\260/NPC.cs" "b/\351\231\210\350\257\227\346\235\260/NPC.cs" new file mode 100644 index 0000000..b20a67e --- /dev/null +++ "b/\351\231\210\350\257\227\346\235\260/NPC.cs" @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _2021_6_4 +{ + public enum janKenPunch + { + 剪刀, + 石头, + 布 + } + //NPC类 实现石头剪刀布 + class NPC : IJanKenPunch_ + { + private string npcName; + + public string NpcName { get => npcName; set => npcName = value; } + + public NPC(string name) + { + this.NpcName = name; + } + + /// + /// 随机出拳、剪、布 + /// + /// 枚举 + public janKenPunch DoJanKenPunch() + { + Random r = new Random(); + int id = r.Next(2); + + return (janKenPunch)id; + } + + public janKenPunch DoJanKenPunch(int key) + { + throw new NotImplementedException(); + } + } +} diff --git "a/\351\231\210\350\257\227\346\235\260/Player.cs" "b/\351\231\210\350\257\227\346\235\260/Player.cs" new file mode 100644 index 0000000..a1dc119 --- /dev/null +++ "b/\351\231\210\350\257\227\346\235\260/Player.cs" @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _2021_6_4 +{ + class Player : IJanKenPunch_ + { + private string playerName; + + public string PlayerName { get => playerName; set => playerName = value; } + + public Player(string name) + { + PlayerName = name; + } + + public janKenPunch DoJanKenPunch(int key) + { + return (janKenPunch)key; + } + + public janKenPunch DoJanKenPunch() + { + throw new NotImplementedException(); + } + } +} diff --git "a/\351\231\210\350\257\227\346\235\260/Program.cs" "b/\351\231\210\350\257\227\346\235\260/Program.cs" new file mode 100644 index 0000000..f339044 --- /dev/null +++ "b/\351\231\210\350\257\227\346\235\260/Program.cs" @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _2021_6_4 +{ + class Program + { + static void Main(string[] args) + { + while (true) + { + #region 开屏介绍及初始化 + Console.ForegroundColor = ConsoleColor.Green; + Console.WriteLine("——————欢迎进入游戏世界——————"); + Console.WriteLine("****************************************"); + Console.WriteLine("**************猜拳,开始****************"); + Console.WriteLine("****************************************"); + Console.WriteLine("--出拳规则:1、剪刀 2、石头 3、布"); + int key; + NPC enemy; + Player player; + Judgment jud; + #endregion + + #region 选择对手 + while (true) + { + Console.WriteLine("请选择你的对手:(1:刘备 2:孙权 3:曹操)"); + key = int.Parse(Console.ReadLine()); ; + if (key >= 1 && key <= 3) + { + enemy = RetrunNpc(key); + break; + } + else + { + Console.WriteLine("输入有误!"); + } + } + #endregion + + #region 创建玩家对象 + Console.WriteLine("请输入你的名字:"); + player = new Player(Console.ReadLine()); + jud = new Judgment(Player: player.PlayerName, Npc: enemy.NpcName); + #endregion + + #region 游戏过程 + while (true) + { + Console.WriteLine("请出拳:"); + key = int.Parse(Console.ReadLine()); + if (key >= 1 & key <= 3) + { + jud.Decide(player: player.DoJanKenPunch(key), npc: enemy.DoJanKenPunch()); + Console.WriteLine("按y开始下一局,任意键退出:"); + + if ((Console.ReadLine().Equals("y")) == false) + { + break; + } + } + else + { + Console.WriteLine("输入有误!"); + continue; + } + + } + #endregion + + #region 游戏结束 + Console.WriteLine("\n\r-----------------------------------"); + Console.WriteLine(jud); + Console.WriteLine("按y开始下一局,任意键退出"); + if ((Console.ReadLine().Equals("y")) == false) + { + break; + } + #endregion + } + + + } + /// + /// 返回一个对手对象 + /// + /// + /// NPC + public static NPC RetrunNpc(int key) + { + switch (key) + { + case 1: + return new NPC("刘备"); + case 2: + return new NPC("孙权"); + default: + return new NPC("曹操"); + } + + + } + + + } +} -- Gitee From 90daa08f72b8becc756f5d2dd3153bd4bf7301a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=8C=E6=98=82?= <2636153719@qq.com> Date: Fri, 4 Jun 2021 17:08:57 +0800 Subject: [PATCH 03/74] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20?= =?UTF-8?q?=E8=92=B2=E6=99=93=E9=AA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\350\222\262\346\231\223\351\252\217/NPC.cs" | 25 ----- .../Program.cs" | 101 ------------------ .../Publicinfo.cs" | 23 ---- .../player.cs" | 24 ----- 4 files changed, 173 deletions(-) delete mode 100644 "\350\222\262\346\231\223\351\252\217/NPC.cs" delete mode 100644 "\350\222\262\346\231\223\351\252\217/Program.cs" delete mode 100644 "\350\222\262\346\231\223\351\252\217/Publicinfo.cs" delete mode 100644 "\350\222\262\346\231\223\351\252\217/player.cs" diff --git "a/\350\222\262\346\231\223\351\252\217/NPC.cs" "b/\350\222\262\346\231\223\351\252\217/NPC.cs" deleted file mode 100644 index 7f7a6bf..0000000 --- "a/\350\222\262\346\231\223\351\252\217/NPC.cs" +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConsoleApp1 -{ - class NPC:Publicinfo - { - public NPC(string name):base(name) - { - this.Name = name; - } - public override int fist() - { - Random r = new Random(); - int a = r.Next(3) + 1; - - return a; - } - - - } -} diff --git "a/\350\222\262\346\231\223\351\252\217/Program.cs" "b/\350\222\262\346\231\223\351\252\217/Program.cs" deleted file mode 100644 index 82933eb..0000000 --- "a/\350\222\262\346\231\223\351\252\217/Program.cs" +++ /dev/null @@ -1,101 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConsoleApp1 -{ - enum npcname - { - 刘备=1, - 孙权, - 曹操 - } - enum fist - { - 剪刀=1, - 石头, - 布 - } - class Program - { - - static void Main(string[] args) - { - int pgroud = 0; - int ngroud = 0; - int session = 0; - Console.WriteLine("----游戏即将开始----"); - Console.WriteLine("--------------------"); - Console.WriteLine("-----猜拳·开始-----"); - Console.WriteLine("--------------------"); - Console.WriteLine("出拳规则:1、剪刀 2、 石头 3、 布"); - Console.WriteLine("请选择对方角色:1、刘备 2 、孙权 3、 曹操 (请输入相应数字)"); - int choose1 = int.Parse(Console.ReadLine()); - npcname f = (npcname)choose1; - - Console.WriteLine("请输入您的名字"); - string play = Console.ReadLine(); - player player = new player(play); - game(f,ref pgroud, ref ngroud, ref session,player); - - } - public static void game(npcname f, ref int pgroud, ref int ngroud, ref int session,player player) - { - NPC npc = new NPC(f.ToString()); - int a = player.fist(); - fist playfist = (fist)a; - int b = npc.fist(); - fist npcfist = (fist)b; - Console.WriteLine("{0}出的拳为{1}", player.Name, playfist); - Console.WriteLine("{0}出的拳为{1}", npc.Name, npcfist); - string a1 = playfist.ToString(); - string a2 = npcfist.ToString(); - judge(a1, a2, ref pgroud, ref ngroud, ref session); - Console.WriteLine("是否开始下一轮 1、继续 2 、停止 "); - int choose = int.Parse(Console.ReadLine()); - switch (choose) - { - case 1: - game(f, ref pgroud, ref ngroud, ref session, player); - break; - case 2: - Console.WriteLine("{0}对阵{1}",player.Name,npc.Name); - Console.WriteLine("对阵次数{0}",session); - Console.WriteLine("姓名 得分"); - Console.WriteLine("{0} {1}",player.Name,pgroud); - Console.WriteLine("{0} {1}", npc.Name, ngroud); - break; - default: - Console.WriteLine("输入错误,重新开始"); - game(f, ref pgroud, ref ngroud, ref session, player); - break; - } - } - public void a() - { - - } - public static void judge(string player, string npcfist, ref int pgroud, ref int ngroud,ref int session) - { - if (player.Equals("石头") && npcfist.Equals("剪刀")|| player.Equals("剪刀") && npcfist.Equals("布")|| player.Equals("布") && npcfist.Equals("石头")) - { - Console.WriteLine("你获得胜利"); - pgroud++; - session++; - } - else if (player.Equals(npcfist)) - { - Console.WriteLine("平局了"); - session++; - } - else - { - Console.WriteLine("你输了"); - ngroud++; - session++; - } - } - } -} diff --git "a/\350\222\262\346\231\223\351\252\217/Publicinfo.cs" "b/\350\222\262\346\231\223\351\252\217/Publicinfo.cs" deleted file mode 100644 index aebf75e..0000000 --- "a/\350\222\262\346\231\223\351\252\217/Publicinfo.cs" +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConsoleApp1 -{ - class Publicinfo - { - public string Name { get; set; } - - public Publicinfo(string name) - { - Name = name; - } - public virtual int fist() - { - return 0; - } - - } -} diff --git "a/\350\222\262\346\231\223\351\252\217/player.cs" "b/\350\222\262\346\231\223\351\252\217/player.cs" deleted file mode 100644 index c24f2f5..0000000 --- "a/\350\222\262\346\231\223\351\252\217/player.cs" +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConsoleApp1 -{ - class player : Publicinfo - { - public player(string name) : base(name) - { - this.Name = name; - } - public override int fist() - { - Console.WriteLine("请出拳:1、剪刀 2 、石头 3、 布 (请输入相应数字)"); - int choose2 = int.Parse(Console.ReadLine()); - return choose2; - } - - - } -} -- Gitee From f86bf438485b55ab7a1a78fcd9fc49b2405d5311 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=8C=E6=98=82?= <2636153719@qq.com> Date: Fri, 4 Jun 2021 17:09:16 +0800 Subject: [PATCH 04/74] =?UTF-8?q?=E7=8C=9C=E6=8B=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\350\222\262\346\231\223\351\252\217/NPC.cs" | 25 ++++ .../Program.cs" | 120 ++++++++++++++++++ .../Publicinfo.cs" | 23 ++++ .../player.cs" | 24 ++++ 4 files changed, 192 insertions(+) create mode 100644 "\350\222\262\346\231\223\351\252\217/NPC.cs" create mode 100644 "\350\222\262\346\231\223\351\252\217/Program.cs" create mode 100644 "\350\222\262\346\231\223\351\252\217/Publicinfo.cs" create mode 100644 "\350\222\262\346\231\223\351\252\217/player.cs" diff --git "a/\350\222\262\346\231\223\351\252\217/NPC.cs" "b/\350\222\262\346\231\223\351\252\217/NPC.cs" new file mode 100644 index 0000000..7f7a6bf --- /dev/null +++ "b/\350\222\262\346\231\223\351\252\217/NPC.cs" @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class NPC:Publicinfo + { + public NPC(string name):base(name) + { + this.Name = name; + } + public override int fist() + { + Random r = new Random(); + int a = r.Next(3) + 1; + + return a; + } + + + } +} diff --git "a/\350\222\262\346\231\223\351\252\217/Program.cs" "b/\350\222\262\346\231\223\351\252\217/Program.cs" new file mode 100644 index 0000000..7eb62d9 --- /dev/null +++ "b/\350\222\262\346\231\223\351\252\217/Program.cs" @@ -0,0 +1,120 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + enum npcname + { + 刘备=1, + 孙权, + 曹操 + } + enum fist + { + 剪刀=1, + 石头, + 布 + } + class Program + { + + static void Main(string[] args) + { + int pgroud = 0; + int ngroud = 0; + int session = 0; + against(ref pgroud, ref ngroud, ref session); + Console.WriteLine("要开始下一句吗?1、要 2、 不要"); + int choose3 = int.Parse(Console.ReadLine()); + switch (choose3) + { + case 1: + against(ref pgroud, ref ngroud, ref session); + break; + case 2: + Console.WriteLine("拜了个拜"); + break; + default: + Console.WriteLine("输入错误,重新开始"); + against(ref pgroud, ref ngroud, ref session); + break; + } + + } + + private static void against(ref int pgroud, ref int ngroud, ref int session) + { + Console.WriteLine("----游戏即将开始----"); + Console.WriteLine("--------------------"); + Console.WriteLine("-----猜拳·开始-----"); + Console.WriteLine("--------------------"); + Console.WriteLine("出拳规则:1、剪刀 2、 石头 3、 布"); + Console.WriteLine("请选择对方角色:1、刘备 2 、孙权 3、 曹操 (请输入相应数字)"); + int choose1 = int.Parse(Console.ReadLine()); + npcname f = (npcname)choose1; + + Console.WriteLine("请输入您的名字"); + string play = Console.ReadLine(); + player player = new player(play); + game(ref f, ref pgroud, ref ngroud, ref session,ref player); + + } + + public static void game(ref npcname f, ref int pgroud, ref int ngroud, ref int session,ref player player) + { + NPC npc = new NPC(f.ToString()); + int a = player.fist(); + fist playfist = (fist)a; + int b = npc.fist(); + fist npcfist = (fist)b; + Console.WriteLine("{0}出的拳为{1}", player.Name, playfist); + Console.WriteLine("{0}出的拳为{1}", npc.Name, npcfist); + string a1 = playfist.ToString(); + string a2 = npcfist.ToString(); + judge(a1, a2, ref pgroud, ref ngroud, ref session); + Console.WriteLine("是否开始下一轮 1、继续 2 、停止 "); + int choose = int.Parse(Console.ReadLine()); + switch (choose) + { + case 1: + game(ref f, ref pgroud, ref ngroud, ref session,ref player); + break; + case 2: + Console.WriteLine("{0}对阵{1}",player.Name,npc.Name); + Console.WriteLine("对阵次数{0}",session); + Console.WriteLine("姓名 得分"); + Console.WriteLine("{0} {1}",player.Name,pgroud); + Console.WriteLine("{0} {1}", npc.Name, ngroud); + break; + default: + Console.WriteLine("输入错误,重新开始"); + game(ref f, ref pgroud, ref ngroud, ref session,ref player); + break; + } + } + + public static void judge(string player, string npcfist, ref int pgroud, ref int ngroud,ref int session) + { + if (player.Equals("石头") && npcfist.Equals("剪刀")|| player.Equals("剪刀") && npcfist.Equals("布")|| player.Equals("布") && npcfist.Equals("石头")) + { + Console.WriteLine("你获得胜利"); + pgroud++; + session++; + } + else if (player.Equals(npcfist)) + { + Console.WriteLine("平局了"); + session++; + } + else + { + Console.WriteLine("你输了"); + ngroud++; + session++; + } + } + } +} diff --git "a/\350\222\262\346\231\223\351\252\217/Publicinfo.cs" "b/\350\222\262\346\231\223\351\252\217/Publicinfo.cs" new file mode 100644 index 0000000..aebf75e --- /dev/null +++ "b/\350\222\262\346\231\223\351\252\217/Publicinfo.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Publicinfo + { + public string Name { get; set; } + + public Publicinfo(string name) + { + Name = name; + } + public virtual int fist() + { + return 0; + } + + } +} diff --git "a/\350\222\262\346\231\223\351\252\217/player.cs" "b/\350\222\262\346\231\223\351\252\217/player.cs" new file mode 100644 index 0000000..c24f2f5 --- /dev/null +++ "b/\350\222\262\346\231\223\351\252\217/player.cs" @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class player : Publicinfo + { + public player(string name) : base(name) + { + this.Name = name; + } + public override int fist() + { + Console.WriteLine("请出拳:1、剪刀 2 、石头 3、 布 (请输入相应数字)"); + int choose2 = int.Parse(Console.ReadLine()); + return choose2; + } + + + } +} -- Gitee From fe8fd413989c1f33e075af48453ab2812b80f378 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=84=B8=E8=84=B8?= <1919008707@qq.com> Date: Fri, 4 Jun 2021 17:09:47 +0800 Subject: [PATCH 05/74] 1 --- "\350\203\241\350\266\212/Npc.cs" | 39 +++++++++++++++ "\350\203\241\350\266\212/Player.cs" | 72 +++++++++++++++++++++++++++ "\350\203\241\350\266\212/Program.cs" | 40 +++++++++++++++ "\350\203\241\350\266\212/Referee.cs" | 32 ++++++++++++ 4 files changed, 183 insertions(+) create mode 100644 "\350\203\241\350\266\212/Npc.cs" create mode 100644 "\350\203\241\350\266\212/Player.cs" create mode 100644 "\350\203\241\350\266\212/Program.cs" create mode 100644 "\350\203\241\350\266\212/Referee.cs" diff --git "a/\350\203\241\350\266\212/Npc.cs" "b/\350\203\241\350\266\212/Npc.cs" new file mode 100644 index 0000000..d0d0db2 --- /dev/null +++ "b/\350\203\241\350\266\212/Npc.cs" @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Npc + { + Random ran = new Random(); + public int ShowFist() + { + int result = ran.Next(1, 4); + Console.WriteLine("计算机出了:{0}", IntToFist(result)); + return result; + } + + private string IntToFist(int input) + { + string result = string.Empty; + + switch (input) + { + case 1: + result = "剪刀"; + break; + case 2: + result = "石头"; + break; + case 3: + result = "布"; + break; + } + return result; + } + + } +} diff --git "a/\350\203\241\350\266\212/Player.cs" "b/\350\203\241\350\266\212/Player.cs" new file mode 100644 index 0000000..e2432e2 --- /dev/null +++ "b/\350\203\241\350\266\212/Player.cs" @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Player + { + string name; + public string Name { get => name; set => name = value; } + + public int ShowFist() + { + Console.WriteLine("请问,你要出什么拳? 1.剪刀 2.石头 3.布"); + int result = ReadInt(1, 3); + string fist = IntToFist(result); + Console.WriteLine("玩家:{0}出了1个{1}", name, fist); + return result; + } + + //转换 + + private string IntToFist(int input) + { + string result = string.Empty; + switch (input) + { + case 1: + result = "剪刀"; + break; + case 2: + result = "石头"; + break; + case 3: + result = "布"; + break; + + } + return result; + } + private int ReadInt(int min, int max) + { + while (true) + { + //从控制台获取用户输入的数据 + string str = Console.ReadLine(); + + //将用户输入的字符串转换成Int类型 + int result; + if (int.TryParse(str, out result)) + { + //判断输入的范围 + if (result >= min && result <= max) + { + return result; + } + else + { + Console.WriteLine("请输入1个{0}-{1}范围的数", min, max); + continue; + } + } + else + { + Console.WriteLine("请输入整数"); + } + } + } + } +} diff --git "a/\350\203\241\350\266\212/Program.cs" "b/\350\203\241\350\266\212/Program.cs" new file mode 100644 index 0000000..35594d7 --- /dev/null +++ "b/\350\203\241\350\266\212/Program.cs" @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Program + { + + static void Main(string[] args) + { + Console.WriteLine("***************************"); + Console.WriteLine("*********猜拳,开始********"); + Console.WriteLine("***************************"); + + //Console.WriteLine("请选择对方角色 <1:刘备 2:孙权 3:曹操>"); + //int a = int.Parse(Console.ReadLine()); + + Console.WriteLine("请输入您的姓名:"); + string name = Console.ReadLine(); + + Player p1 = new Player() { Name = name }; + Npc c1 = new Npc(); + Referee j1 = new Referee(); + + + while (true) + { + int res1 = p1.ShowFist(); + int res2 = c1.ShowFist(); + j1.Determine(res1, res2); + Console.ReadKey(); + } + + + } + } +} diff --git "a/\350\203\241\350\266\212/Referee.cs" "b/\350\203\241\350\266\212/Referee.cs" new file mode 100644 index 0000000..7db0bd7 --- /dev/null +++ "b/\350\203\241\350\266\212/Referee.cs" @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Referee + { + public void Determine(int p1, int p2) + { + //1剪刀 2石头 3布 + //1 3 1-3=-2 在玩家出1剪刀的情况下,计算机出3布,玩家赢 + //2 1 2-1=1 在玩家出2石头的情况下,计算机出1剪刀,玩家赢 + //3 2 3-2=1 在玩家出3布的情况下,计算机出2石头,玩家赢 + if (p1 - p2 == -2 || p1 - p2 == 1) + { + Console.WriteLine("玩家胜利!"); + } + else if (p1 == p2) + { + Console.WriteLine("平局"); + } + else + { + Console.WriteLine("玩家失败!"); + } + } + + } +} -- Gitee From 10d7baf0a092ac8cdc6c8dae71270f5568798e2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=BE=E5=A4=A7=E6=98=9F=E5=91=80?= <2454478226@qq.com> Date: Fri, 4 Jun 2021 17:14:08 +0800 Subject: [PATCH 06/74] zy --- .../IJanKenPunch].cs" | 14 +++ .../Judgment.cs" | 110 ++++++++++++++++++ "\345\210\230\344\270\226\350\276\211/NPC.cs" | 44 +++++++ .../Player.cs" | 30 +++++ .../Program.cs" | 110 ++++++++++++++++++ 5 files changed, 308 insertions(+) create mode 100644 "\345\210\230\344\270\226\350\276\211/IJanKenPunch].cs" create mode 100644 "\345\210\230\344\270\226\350\276\211/Judgment.cs" create mode 100644 "\345\210\230\344\270\226\350\276\211/NPC.cs" create mode 100644 "\345\210\230\344\270\226\350\276\211/Player.cs" create mode 100644 "\345\210\230\344\270\226\350\276\211/Program.cs" diff --git "a/\345\210\230\344\270\226\350\276\211/IJanKenPunch].cs" "b/\345\210\230\344\270\226\350\276\211/IJanKenPunch].cs" new file mode 100644 index 0000000..ce96a62 --- /dev/null +++ "b/\345\210\230\344\270\226\350\276\211/IJanKenPunch].cs" @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _2021_6_4 +{ + interface IJanKenPunch_ + { + janKenPunch DoJanKenPunch(); + janKenPunch DoJanKenPunch(int key); + } +} diff --git "a/\345\210\230\344\270\226\350\276\211/Judgment.cs" "b/\345\210\230\344\270\226\350\276\211/Judgment.cs" new file mode 100644 index 0000000..cf5e0aa --- /dev/null +++ "b/\345\210\230\344\270\226\350\276\211/Judgment.cs" @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _2021_6_4 +{ + class Judgment + { + public string playerName; + public int playerScore; + public string npcName; + public int npcScore; + public int countBattle; + + public Judgment(string Player , string Npc) + { + this.playerName = Player; + this.npcName = Npc; + } + public void Decide(janKenPunch player , janKenPunch npc) + { + //玩家出剪刀的情况 + if (player == janKenPunch.剪刀) + { + if (npc == janKenPunch.剪刀) + { + countBattle++; + Console.WriteLine("和局"); + } + else if (npc == janKenPunch.布) + { + countBattle++; + playerScore++; + Console.WriteLine($"{playerName}胜!"); + } + else + { + countBattle++; + npcScore++; + Console.WriteLine($"{npcName}胜!"); + } + } + //出石头的情况 + else if (player == janKenPunch.石头) + { + if (npc == janKenPunch.石头) + { + countBattle++; + Console.WriteLine("和局"); + } + else if (npc == janKenPunch.剪刀) + { + countBattle++; + playerScore++; + Console.WriteLine($"{playerName}胜!"); + } + else + { + countBattle++; + npcScore++; + Console.WriteLine($"{npcName}胜!"); + } + } + //出布的情况 + else + { + if (npc == janKenPunch.布) + { + countBattle++; + Console.WriteLine("和局"); + } + else if (npc == janKenPunch.石头) + { + countBattle++; + playerScore++; + Console.WriteLine($"{playerName}胜!"); + } + else + { + countBattle++; + npcScore++; + Console.WriteLine($"{npcName}胜!"); + + } + } + } + + public override string ToString() + { + string result; + + if (playerScore > npcScore) + { + result = $"{playerName}赢!"; + } + else if (playerScore < npcScore) + { + result = $"{npcName}赢!"; + } + else + { + result = "但是谁也没有赢"; + } + + return $"{playerName} VS {npcName}\n对局次数:{countBattle}\r\n姓名\t得分\n{playerName}\t{playerScore}\n{npcName}\t{npcScore}\n" + result; + } + } +} diff --git "a/\345\210\230\344\270\226\350\276\211/NPC.cs" "b/\345\210\230\344\270\226\350\276\211/NPC.cs" new file mode 100644 index 0000000..b20a67e --- /dev/null +++ "b/\345\210\230\344\270\226\350\276\211/NPC.cs" @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _2021_6_4 +{ + public enum janKenPunch + { + 剪刀, + 石头, + 布 + } + //NPC类 实现石头剪刀布 + class NPC : IJanKenPunch_ + { + private string npcName; + + public string NpcName { get => npcName; set => npcName = value; } + + public NPC(string name) + { + this.NpcName = name; + } + + /// + /// 随机出拳、剪、布 + /// + /// 枚举 + public janKenPunch DoJanKenPunch() + { + Random r = new Random(); + int id = r.Next(2); + + return (janKenPunch)id; + } + + public janKenPunch DoJanKenPunch(int key) + { + throw new NotImplementedException(); + } + } +} diff --git "a/\345\210\230\344\270\226\350\276\211/Player.cs" "b/\345\210\230\344\270\226\350\276\211/Player.cs" new file mode 100644 index 0000000..a1dc119 --- /dev/null +++ "b/\345\210\230\344\270\226\350\276\211/Player.cs" @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _2021_6_4 +{ + class Player : IJanKenPunch_ + { + private string playerName; + + public string PlayerName { get => playerName; set => playerName = value; } + + public Player(string name) + { + PlayerName = name; + } + + public janKenPunch DoJanKenPunch(int key) + { + return (janKenPunch)key; + } + + public janKenPunch DoJanKenPunch() + { + throw new NotImplementedException(); + } + } +} diff --git "a/\345\210\230\344\270\226\350\276\211/Program.cs" "b/\345\210\230\344\270\226\350\276\211/Program.cs" new file mode 100644 index 0000000..f339044 --- /dev/null +++ "b/\345\210\230\344\270\226\350\276\211/Program.cs" @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _2021_6_4 +{ + class Program + { + static void Main(string[] args) + { + while (true) + { + #region 开屏介绍及初始化 + Console.ForegroundColor = ConsoleColor.Green; + Console.WriteLine("——————欢迎进入游戏世界——————"); + Console.WriteLine("****************************************"); + Console.WriteLine("**************猜拳,开始****************"); + Console.WriteLine("****************************************"); + Console.WriteLine("--出拳规则:1、剪刀 2、石头 3、布"); + int key; + NPC enemy; + Player player; + Judgment jud; + #endregion + + #region 选择对手 + while (true) + { + Console.WriteLine("请选择你的对手:(1:刘备 2:孙权 3:曹操)"); + key = int.Parse(Console.ReadLine()); ; + if (key >= 1 && key <= 3) + { + enemy = RetrunNpc(key); + break; + } + else + { + Console.WriteLine("输入有误!"); + } + } + #endregion + + #region 创建玩家对象 + Console.WriteLine("请输入你的名字:"); + player = new Player(Console.ReadLine()); + jud = new Judgment(Player: player.PlayerName, Npc: enemy.NpcName); + #endregion + + #region 游戏过程 + while (true) + { + Console.WriteLine("请出拳:"); + key = int.Parse(Console.ReadLine()); + if (key >= 1 & key <= 3) + { + jud.Decide(player: player.DoJanKenPunch(key), npc: enemy.DoJanKenPunch()); + Console.WriteLine("按y开始下一局,任意键退出:"); + + if ((Console.ReadLine().Equals("y")) == false) + { + break; + } + } + else + { + Console.WriteLine("输入有误!"); + continue; + } + + } + #endregion + + #region 游戏结束 + Console.WriteLine("\n\r-----------------------------------"); + Console.WriteLine(jud); + Console.WriteLine("按y开始下一局,任意键退出"); + if ((Console.ReadLine().Equals("y")) == false) + { + break; + } + #endregion + } + + + } + /// + /// 返回一个对手对象 + /// + /// + /// NPC + public static NPC RetrunNpc(int key) + { + switch (key) + { + case 1: + return new NPC("刘备"); + case 2: + return new NPC("孙权"); + default: + return new NPC("曹操"); + } + + + } + + + } +} -- Gitee From daa3898fc40357d8ad5b4dff99dfd9a021321eb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=8C=E6=98=82?= <2636153719@qq.com> Date: Fri, 4 Jun 2021 17:14:36 +0800 Subject: [PATCH 07/74] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20?= =?UTF-8?q?=E8=92=B2=E6=99=93=E9=AA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\350\222\262\346\231\223\351\252\217/NPC.cs" | 25 ---- .../Program.cs" | 120 ------------------ .../Publicinfo.cs" | 23 ---- .../player.cs" | 24 ---- 4 files changed, 192 deletions(-) delete mode 100644 "\350\222\262\346\231\223\351\252\217/NPC.cs" delete mode 100644 "\350\222\262\346\231\223\351\252\217/Program.cs" delete mode 100644 "\350\222\262\346\231\223\351\252\217/Publicinfo.cs" delete mode 100644 "\350\222\262\346\231\223\351\252\217/player.cs" diff --git "a/\350\222\262\346\231\223\351\252\217/NPC.cs" "b/\350\222\262\346\231\223\351\252\217/NPC.cs" deleted file mode 100644 index 7f7a6bf..0000000 --- "a/\350\222\262\346\231\223\351\252\217/NPC.cs" +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConsoleApp1 -{ - class NPC:Publicinfo - { - public NPC(string name):base(name) - { - this.Name = name; - } - public override int fist() - { - Random r = new Random(); - int a = r.Next(3) + 1; - - return a; - } - - - } -} diff --git "a/\350\222\262\346\231\223\351\252\217/Program.cs" "b/\350\222\262\346\231\223\351\252\217/Program.cs" deleted file mode 100644 index 7eb62d9..0000000 --- "a/\350\222\262\346\231\223\351\252\217/Program.cs" +++ /dev/null @@ -1,120 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConsoleApp1 -{ - enum npcname - { - 刘备=1, - 孙权, - 曹操 - } - enum fist - { - 剪刀=1, - 石头, - 布 - } - class Program - { - - static void Main(string[] args) - { - int pgroud = 0; - int ngroud = 0; - int session = 0; - against(ref pgroud, ref ngroud, ref session); - Console.WriteLine("要开始下一句吗?1、要 2、 不要"); - int choose3 = int.Parse(Console.ReadLine()); - switch (choose3) - { - case 1: - against(ref pgroud, ref ngroud, ref session); - break; - case 2: - Console.WriteLine("拜了个拜"); - break; - default: - Console.WriteLine("输入错误,重新开始"); - against(ref pgroud, ref ngroud, ref session); - break; - } - - } - - private static void against(ref int pgroud, ref int ngroud, ref int session) - { - Console.WriteLine("----游戏即将开始----"); - Console.WriteLine("--------------------"); - Console.WriteLine("-----猜拳·开始-----"); - Console.WriteLine("--------------------"); - Console.WriteLine("出拳规则:1、剪刀 2、 石头 3、 布"); - Console.WriteLine("请选择对方角色:1、刘备 2 、孙权 3、 曹操 (请输入相应数字)"); - int choose1 = int.Parse(Console.ReadLine()); - npcname f = (npcname)choose1; - - Console.WriteLine("请输入您的名字"); - string play = Console.ReadLine(); - player player = new player(play); - game(ref f, ref pgroud, ref ngroud, ref session,ref player); - - } - - public static void game(ref npcname f, ref int pgroud, ref int ngroud, ref int session,ref player player) - { - NPC npc = new NPC(f.ToString()); - int a = player.fist(); - fist playfist = (fist)a; - int b = npc.fist(); - fist npcfist = (fist)b; - Console.WriteLine("{0}出的拳为{1}", player.Name, playfist); - Console.WriteLine("{0}出的拳为{1}", npc.Name, npcfist); - string a1 = playfist.ToString(); - string a2 = npcfist.ToString(); - judge(a1, a2, ref pgroud, ref ngroud, ref session); - Console.WriteLine("是否开始下一轮 1、继续 2 、停止 "); - int choose = int.Parse(Console.ReadLine()); - switch (choose) - { - case 1: - game(ref f, ref pgroud, ref ngroud, ref session,ref player); - break; - case 2: - Console.WriteLine("{0}对阵{1}",player.Name,npc.Name); - Console.WriteLine("对阵次数{0}",session); - Console.WriteLine("姓名 得分"); - Console.WriteLine("{0} {1}",player.Name,pgroud); - Console.WriteLine("{0} {1}", npc.Name, ngroud); - break; - default: - Console.WriteLine("输入错误,重新开始"); - game(ref f, ref pgroud, ref ngroud, ref session,ref player); - break; - } - } - - public static void judge(string player, string npcfist, ref int pgroud, ref int ngroud,ref int session) - { - if (player.Equals("石头") && npcfist.Equals("剪刀")|| player.Equals("剪刀") && npcfist.Equals("布")|| player.Equals("布") && npcfist.Equals("石头")) - { - Console.WriteLine("你获得胜利"); - pgroud++; - session++; - } - else if (player.Equals(npcfist)) - { - Console.WriteLine("平局了"); - session++; - } - else - { - Console.WriteLine("你输了"); - ngroud++; - session++; - } - } - } -} diff --git "a/\350\222\262\346\231\223\351\252\217/Publicinfo.cs" "b/\350\222\262\346\231\223\351\252\217/Publicinfo.cs" deleted file mode 100644 index aebf75e..0000000 --- "a/\350\222\262\346\231\223\351\252\217/Publicinfo.cs" +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConsoleApp1 -{ - class Publicinfo - { - public string Name { get; set; } - - public Publicinfo(string name) - { - Name = name; - } - public virtual int fist() - { - return 0; - } - - } -} diff --git "a/\350\222\262\346\231\223\351\252\217/player.cs" "b/\350\222\262\346\231\223\351\252\217/player.cs" deleted file mode 100644 index c24f2f5..0000000 --- "a/\350\222\262\346\231\223\351\252\217/player.cs" +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConsoleApp1 -{ - class player : Publicinfo - { - public player(string name) : base(name) - { - this.Name = name; - } - public override int fist() - { - Console.WriteLine("请出拳:1、剪刀 2 、石头 3、 布 (请输入相应数字)"); - int choose2 = int.Parse(Console.ReadLine()); - return choose2; - } - - - } -} -- Gitee From 378ffdf1a5f601121d2252f31fb38a5a1d884986 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=8C=E6=98=82?= <2636153719@qq.com> Date: Fri, 4 Jun 2021 17:14:46 +0800 Subject: [PATCH 08/74] =?UTF-8?q?=E7=8C=9C=E6=8B=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\350\222\262\346\231\223\351\252\217/NPC.cs" | 25 ++++ .../Program.cs" | 123 ++++++++++++++++++ .../Publicinfo.cs" | 23 ++++ .../player.cs" | 24 ++++ 4 files changed, 195 insertions(+) create mode 100644 "\350\222\262\346\231\223\351\252\217/NPC.cs" create mode 100644 "\350\222\262\346\231\223\351\252\217/Program.cs" create mode 100644 "\350\222\262\346\231\223\351\252\217/Publicinfo.cs" create mode 100644 "\350\222\262\346\231\223\351\252\217/player.cs" diff --git "a/\350\222\262\346\231\223\351\252\217/NPC.cs" "b/\350\222\262\346\231\223\351\252\217/NPC.cs" new file mode 100644 index 0000000..7f7a6bf --- /dev/null +++ "b/\350\222\262\346\231\223\351\252\217/NPC.cs" @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class NPC:Publicinfo + { + public NPC(string name):base(name) + { + this.Name = name; + } + public override int fist() + { + Random r = new Random(); + int a = r.Next(3) + 1; + + return a; + } + + + } +} diff --git "a/\350\222\262\346\231\223\351\252\217/Program.cs" "b/\350\222\262\346\231\223\351\252\217/Program.cs" new file mode 100644 index 0000000..f7b2954 --- /dev/null +++ "b/\350\222\262\346\231\223\351\252\217/Program.cs" @@ -0,0 +1,123 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + enum npcname + { + 刘备=1, + 孙权, + 曹操 + } + enum fist + { + 剪刀=1, + 石头, + 布 + } + class Program + { + + static void Main(string[] args) + { + int pgroud = 0; + int ngroud = 0; + int session = 0; + against(ref pgroud, ref ngroud, ref session); + against2(ref pgroud, ref ngroud, ref session); + } + public static void against2(ref int pgroud, ref int ngroud, ref int session) + { + Console.WriteLine("要开始下一局吗?1、要 2、 不要"); + int choose3 = int.Parse(Console.ReadLine()); + switch (choose3) + { + case 1: + against(ref pgroud, ref ngroud, ref session); + against2(ref pgroud, ref ngroud, ref session); + break; + case 2: + Console.WriteLine("拜了个拜"); + break; + default: + Console.WriteLine("输入错误,重新开始"); + against(ref pgroud, ref ngroud, ref session); + break; + } + } + public static void against(ref int pgroud, ref int ngroud, ref int session) + { + Console.WriteLine("----游戏即将开始----"); + Console.WriteLine("--------------------"); + Console.WriteLine("-----猜拳·开始-----"); + Console.WriteLine("--------------------"); + Console.WriteLine("出拳规则:1、剪刀 2、 石头 3、 布"); + Console.WriteLine("请选择对方角色:1、刘备 2 、孙权 3、 曹操 (请输入相应数字)"); + int choose1 = int.Parse(Console.ReadLine()); + npcname f = (npcname)choose1; + + Console.WriteLine("请输入您的名字"); + string play = Console.ReadLine(); + player player = new player(play); + game(ref f, ref pgroud, ref ngroud, ref session,ref player); + + } + + public static void game(ref npcname f, ref int pgroud, ref int ngroud, ref int session,ref player player) + { + NPC npc = new NPC(f.ToString()); + int a = player.fist(); + fist playfist = (fist)a; + int b = npc.fist(); + fist npcfist = (fist)b; + Console.WriteLine("{0}出的拳为{1}", player.Name, playfist); + Console.WriteLine("{0}出的拳为{1}", npc.Name, npcfist); + string a1 = playfist.ToString(); + string a2 = npcfist.ToString(); + judge(a1, a2, ref pgroud, ref ngroud, ref session); + Console.WriteLine("是否开始下一轮 1、继续 2 、停止 "); + int choose = int.Parse(Console.ReadLine()); + switch (choose) + { + case 1: + game(ref f, ref pgroud, ref ngroud, ref session,ref player); + break; + case 2: + Console.WriteLine("{0}对阵{1}",player.Name,npc.Name); + Console.WriteLine("对阵次数{0}",session); + Console.WriteLine("姓名 得分"); + Console.WriteLine("{0} {1}",player.Name,pgroud); + Console.WriteLine("{0} {1}", npc.Name, ngroud); + break; + default: + Console.WriteLine("输入错误,重新开始"); + game(ref f, ref pgroud, ref ngroud, ref session,ref player); + break; + } + } + + public static void judge(string player, string npcfist, ref int pgroud, ref int ngroud,ref int session) + { + if (player.Equals("石头") && npcfist.Equals("剪刀")|| player.Equals("剪刀") && npcfist.Equals("布")|| player.Equals("布") && npcfist.Equals("石头")) + { + Console.WriteLine("你获得胜利"); + pgroud++; + session++; + } + else if (player.Equals(npcfist)) + { + Console.WriteLine("平局了"); + session++; + } + else + { + Console.WriteLine("你输了"); + ngroud++; + session++; + } + } + } +} diff --git "a/\350\222\262\346\231\223\351\252\217/Publicinfo.cs" "b/\350\222\262\346\231\223\351\252\217/Publicinfo.cs" new file mode 100644 index 0000000..aebf75e --- /dev/null +++ "b/\350\222\262\346\231\223\351\252\217/Publicinfo.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Publicinfo + { + public string Name { get; set; } + + public Publicinfo(string name) + { + Name = name; + } + public virtual int fist() + { + return 0; + } + + } +} diff --git "a/\350\222\262\346\231\223\351\252\217/player.cs" "b/\350\222\262\346\231\223\351\252\217/player.cs" new file mode 100644 index 0000000..c24f2f5 --- /dev/null +++ "b/\350\222\262\346\231\223\351\252\217/player.cs" @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class player : Publicinfo + { + public player(string name) : base(name) + { + this.Name = name; + } + public override int fist() + { + Console.WriteLine("请出拳:1、剪刀 2 、石头 3、 布 (请输入相应数字)"); + int choose2 = int.Parse(Console.ReadLine()); + return choose2; + } + + + } +} -- Gitee From 29f237bd3b6067cb0f62f4c843765ef58e47f7fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=BE=E5=A4=A7=E6=98=9F=E5=91=80?= <2454478226@qq.com> Date: Fri, 4 Jun 2021 17:20:27 +0800 Subject: [PATCH 09/74] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20?= =?UTF-8?q?=E5=88=98=E4=B8=96=E8=BE=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IJanKenPunch].cs" | 14 --- .../Judgment.cs" | 110 ------------------ "\345\210\230\344\270\226\350\276\211/NPC.cs" | 44 ------- .../Player.cs" | 30 ----- .../Program.cs" | 110 ------------------ 5 files changed, 308 deletions(-) delete mode 100644 "\345\210\230\344\270\226\350\276\211/IJanKenPunch].cs" delete mode 100644 "\345\210\230\344\270\226\350\276\211/Judgment.cs" delete mode 100644 "\345\210\230\344\270\226\350\276\211/NPC.cs" delete mode 100644 "\345\210\230\344\270\226\350\276\211/Player.cs" delete mode 100644 "\345\210\230\344\270\226\350\276\211/Program.cs" diff --git "a/\345\210\230\344\270\226\350\276\211/IJanKenPunch].cs" "b/\345\210\230\344\270\226\350\276\211/IJanKenPunch].cs" deleted file mode 100644 index ce96a62..0000000 --- "a/\345\210\230\344\270\226\350\276\211/IJanKenPunch].cs" +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace _2021_6_4 -{ - interface IJanKenPunch_ - { - janKenPunch DoJanKenPunch(); - janKenPunch DoJanKenPunch(int key); - } -} diff --git "a/\345\210\230\344\270\226\350\276\211/Judgment.cs" "b/\345\210\230\344\270\226\350\276\211/Judgment.cs" deleted file mode 100644 index cf5e0aa..0000000 --- "a/\345\210\230\344\270\226\350\276\211/Judgment.cs" +++ /dev/null @@ -1,110 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace _2021_6_4 -{ - class Judgment - { - public string playerName; - public int playerScore; - public string npcName; - public int npcScore; - public int countBattle; - - public Judgment(string Player , string Npc) - { - this.playerName = Player; - this.npcName = Npc; - } - public void Decide(janKenPunch player , janKenPunch npc) - { - //玩家出剪刀的情况 - if (player == janKenPunch.剪刀) - { - if (npc == janKenPunch.剪刀) - { - countBattle++; - Console.WriteLine("和局"); - } - else if (npc == janKenPunch.布) - { - countBattle++; - playerScore++; - Console.WriteLine($"{playerName}胜!"); - } - else - { - countBattle++; - npcScore++; - Console.WriteLine($"{npcName}胜!"); - } - } - //出石头的情况 - else if (player == janKenPunch.石头) - { - if (npc == janKenPunch.石头) - { - countBattle++; - Console.WriteLine("和局"); - } - else if (npc == janKenPunch.剪刀) - { - countBattle++; - playerScore++; - Console.WriteLine($"{playerName}胜!"); - } - else - { - countBattle++; - npcScore++; - Console.WriteLine($"{npcName}胜!"); - } - } - //出布的情况 - else - { - if (npc == janKenPunch.布) - { - countBattle++; - Console.WriteLine("和局"); - } - else if (npc == janKenPunch.石头) - { - countBattle++; - playerScore++; - Console.WriteLine($"{playerName}胜!"); - } - else - { - countBattle++; - npcScore++; - Console.WriteLine($"{npcName}胜!"); - - } - } - } - - public override string ToString() - { - string result; - - if (playerScore > npcScore) - { - result = $"{playerName}赢!"; - } - else if (playerScore < npcScore) - { - result = $"{npcName}赢!"; - } - else - { - result = "但是谁也没有赢"; - } - - return $"{playerName} VS {npcName}\n对局次数:{countBattle}\r\n姓名\t得分\n{playerName}\t{playerScore}\n{npcName}\t{npcScore}\n" + result; - } - } -} diff --git "a/\345\210\230\344\270\226\350\276\211/NPC.cs" "b/\345\210\230\344\270\226\350\276\211/NPC.cs" deleted file mode 100644 index b20a67e..0000000 --- "a/\345\210\230\344\270\226\350\276\211/NPC.cs" +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace _2021_6_4 -{ - public enum janKenPunch - { - 剪刀, - 石头, - 布 - } - //NPC类 实现石头剪刀布 - class NPC : IJanKenPunch_ - { - private string npcName; - - public string NpcName { get => npcName; set => npcName = value; } - - public NPC(string name) - { - this.NpcName = name; - } - - /// - /// 随机出拳、剪、布 - /// - /// 枚举 - public janKenPunch DoJanKenPunch() - { - Random r = new Random(); - int id = r.Next(2); - - return (janKenPunch)id; - } - - public janKenPunch DoJanKenPunch(int key) - { - throw new NotImplementedException(); - } - } -} diff --git "a/\345\210\230\344\270\226\350\276\211/Player.cs" "b/\345\210\230\344\270\226\350\276\211/Player.cs" deleted file mode 100644 index a1dc119..0000000 --- "a/\345\210\230\344\270\226\350\276\211/Player.cs" +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace _2021_6_4 -{ - class Player : IJanKenPunch_ - { - private string playerName; - - public string PlayerName { get => playerName; set => playerName = value; } - - public Player(string name) - { - PlayerName = name; - } - - public janKenPunch DoJanKenPunch(int key) - { - return (janKenPunch)key; - } - - public janKenPunch DoJanKenPunch() - { - throw new NotImplementedException(); - } - } -} diff --git "a/\345\210\230\344\270\226\350\276\211/Program.cs" "b/\345\210\230\344\270\226\350\276\211/Program.cs" deleted file mode 100644 index f339044..0000000 --- "a/\345\210\230\344\270\226\350\276\211/Program.cs" +++ /dev/null @@ -1,110 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace _2021_6_4 -{ - class Program - { - static void Main(string[] args) - { - while (true) - { - #region 开屏介绍及初始化 - Console.ForegroundColor = ConsoleColor.Green; - Console.WriteLine("——————欢迎进入游戏世界——————"); - Console.WriteLine("****************************************"); - Console.WriteLine("**************猜拳,开始****************"); - Console.WriteLine("****************************************"); - Console.WriteLine("--出拳规则:1、剪刀 2、石头 3、布"); - int key; - NPC enemy; - Player player; - Judgment jud; - #endregion - - #region 选择对手 - while (true) - { - Console.WriteLine("请选择你的对手:(1:刘备 2:孙权 3:曹操)"); - key = int.Parse(Console.ReadLine()); ; - if (key >= 1 && key <= 3) - { - enemy = RetrunNpc(key); - break; - } - else - { - Console.WriteLine("输入有误!"); - } - } - #endregion - - #region 创建玩家对象 - Console.WriteLine("请输入你的名字:"); - player = new Player(Console.ReadLine()); - jud = new Judgment(Player: player.PlayerName, Npc: enemy.NpcName); - #endregion - - #region 游戏过程 - while (true) - { - Console.WriteLine("请出拳:"); - key = int.Parse(Console.ReadLine()); - if (key >= 1 & key <= 3) - { - jud.Decide(player: player.DoJanKenPunch(key), npc: enemy.DoJanKenPunch()); - Console.WriteLine("按y开始下一局,任意键退出:"); - - if ((Console.ReadLine().Equals("y")) == false) - { - break; - } - } - else - { - Console.WriteLine("输入有误!"); - continue; - } - - } - #endregion - - #region 游戏结束 - Console.WriteLine("\n\r-----------------------------------"); - Console.WriteLine(jud); - Console.WriteLine("按y开始下一局,任意键退出"); - if ((Console.ReadLine().Equals("y")) == false) - { - break; - } - #endregion - } - - - } - /// - /// 返回一个对手对象 - /// - /// - /// NPC - public static NPC RetrunNpc(int key) - { - switch (key) - { - case 1: - return new NPC("刘备"); - case 2: - return new NPC("孙权"); - default: - return new NPC("曹操"); - } - - - } - - - } -} -- Gitee From ac8a76f8603bc76c39050fca40c400f080874e04 Mon Sep 17 00:00:00 2001 From: EoL <1179233990@qq.com> Date: Fri, 4 Jun 2021 17:27:03 +0800 Subject: [PATCH 10/74] 1 --- .../Program.cs" | 137 ++++++++++++++++++ "\350\224\241\351\233\252\345\274\272/cq.cs" | 63 ++++++++ .../play.cs" | 18 +++ "\350\224\241\351\233\252\345\274\272/rm.cs" | 22 +++ 4 files changed, 240 insertions(+) create mode 100644 "\350\224\241\351\233\252\345\274\272/Program.cs" create mode 100644 "\350\224\241\351\233\252\345\274\272/cq.cs" create mode 100644 "\350\224\241\351\233\252\345\274\272/play.cs" create mode 100644 "\350\224\241\351\233\252\345\274\272/rm.cs" diff --git "a/\350\224\241\351\233\252\345\274\272/Program.cs" "b/\350\224\241\351\233\252\345\274\272/Program.cs" new file mode 100644 index 0000000..e9c7962 --- /dev/null +++ "b/\350\224\241\351\233\252\345\274\272/Program.cs" @@ -0,0 +1,137 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Program + { + static string b; + public enum cqcq + { + 剪刀=1, + 石头, + 布 + } + static void Main(string[] args) + { + EoL1(); + } + + private static void EoL1() + { + Console.WriteLine("-----------------欢 迎 进 入 游 戏 世 界-----------------"); + Console.WriteLine("*********************************************************"); + Console.WriteLine("***********************猜 拳 开 始***********************"); + Console.WriteLine("*********************************************************"); + Console.WriteLine("猜拳规则:1、剪刀,2、石头,3、布"); + Console.WriteLine("请选择对方角色:<1、刘备,2、孙权,3、曹操>"); + int a = int.Parse(Console.ReadLine()); + switch (a) + { + case 1: + EoL2(); + rm rm1 = new rm("刘备"); + Console.WriteLine(b + "VS" + rm1.rmrm() + "对战"); + Console.WriteLine("开始游戏吗(y/n)"); + string d = Console.ReadLine(); + switch (d) + { + case "y": + Console.WriteLine("请出拳:1、剪刀,2、石头,3、布"); + int e = int.Parse(Console.ReadLine()); + cqcq cq1 = (cqcq)e; + Random r = new Random(); + int c = r.Next(3) + 1; + cqcq cq2 = (cqcq)c; + Console.WriteLine(b + ":出拳:" + cq1); + Console.WriteLine(rm1.rmrm() + " :出拳:" + cq2); + cq cq = new cq(); + play p1 = new play(b); + cq.stjdb1 = ((cqcq)e).ToString(); + cq.stjdb2 = ((cqcq)c).ToString(); + cq.EoL3(); + EoL1(); + break; + case "n": + EoL1(); + break; + default: + break; + } + break; + case 2: + EoL2(); + rm rm2 = new rm("孙权"); + Console.WriteLine(b + "VS" + rm2.rmrm() + "对战"); + Console.WriteLine("开始游戏吗(y/n)"); + d = Console.ReadLine(); + switch (d) + { + case "y": + Console.WriteLine("请出拳:1、剪刀,2、石头,3、布"); + int e = int.Parse(Console.ReadLine()); + cqcq cq1 = (cqcq)e; + Random r = new Random(); + int c = r.Next(3) + 1; + cqcq cq2 = (cqcq)c; + Console.WriteLine(b + ":出拳:" + cq1); + Console.WriteLine(rm2.rmrm() + " :出拳:" + cq2); + cq cq = new cq(); + play p2 = new play(b); + cq.stjdb1 = ((cqcq)e).ToString(); + cq.stjdb2 = ((cqcq)c).ToString(); + cq.EoL3(); + EoL1(); + break; + case "n": + EoL1(); + break; + default: + break; + } + break; + case 3: + EoL2(); + rm rm3 = new rm("曹操"); + Console.WriteLine(b + "VS" + rm3.rmrm() + "对战"); + Console.WriteLine("开始游戏吗(y/n)"); + d = Console.ReadLine(); + switch (d) + { + case "y": + Console.WriteLine("请出拳:1、剪刀,2、石头,3、布"); + int e = int.Parse(Console.ReadLine()); + cqcq cq1 = (cqcq)e; + Random r = new Random(); + int c = r.Next(3) + 1; + cqcq cq2 = (cqcq)c; + Console.WriteLine(b + ":出拳:" + cq1); + Console.WriteLine(rm3.rmrm() + " :出拳:" + cq2); + cq cq = new cq(); + play p3 = new play(b); + cq.stjdb1 = ((cqcq)e).ToString(); + cq.stjdb2 = ((cqcq)c).ToString(); + cq.EoL3(); + EoL1(); + break; + case "n": + EoL1(); + break; + default: + break; + } + break; + default: + break; + } + } + private static void EoL2() + { + Console.WriteLine("输入你的名字"); + b = Console.ReadLine(); + } + } +} diff --git "a/\350\224\241\351\233\252\345\274\272/cq.cs" "b/\350\224\241\351\233\252\345\274\272/cq.cs" new file mode 100644 index 0000000..e99e4f3 --- /dev/null +++ "b/\350\224\241\351\233\252\345\274\272/cq.cs" @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class cq:rm + { + public string stjdb1 { get; set; } + public string stjdb2 { get; set; } + + public void EoL3() + { + if (stjdb1.Equals("剪刀")) + { + if (stjdb2.Equals("剪刀")) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + if (stjdb2.Equals("石头")) + { + Console.WriteLine("笨蛋,你真菜"); + } + if (stjdb2.Equals("布")) + { + Console.WriteLine("恭喜,你真猛"); + } + } + if (stjdb1.Equals("石头")) + { + if (stjdb2.Equals("剪刀")) + { + Console.WriteLine("恭喜,你真猛"); + } + if (stjdb2.Equals("石头")) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + if (stjdb2.Equals("布")) + { + Console.WriteLine("笨蛋,你真菜"); + } + } + if (stjdb1.Equals("布")) + { + if (stjdb2.Equals("剪刀")) + { + Console.WriteLine("笨蛋,你真菜"); + } + if (stjdb2.Equals("石头")) + { + Console.WriteLine("恭喜,你真猛"); + } + if (stjdb2.Equals("布")) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + } + } + } +} diff --git "a/\350\224\241\351\233\252\345\274\272/play.cs" "b/\350\224\241\351\233\252\345\274\272/play.cs" new file mode 100644 index 0000000..836166c --- /dev/null +++ "b/\350\224\241\351\233\252\345\274\272/play.cs" @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class play + { + public string name1 { get; set; } + public play() { } + public play(string name1) + { + this.name1 = name1; + } + } +} diff --git "a/\350\224\241\351\233\252\345\274\272/rm.cs" "b/\350\224\241\351\233\252\345\274\272/rm.cs" new file mode 100644 index 0000000..c3b4ea0 --- /dev/null +++ "b/\350\224\241\351\233\252\345\274\272/rm.cs" @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class rm:play + { + public string name { get; set; } + public rm() { } + public rm(string name) + { + this.name = name; + } + public string rmrm() + { + return name; + } + } +} -- Gitee From 33799364fd2a885050d11279c75bd38887a8198b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=B7=91=E8=B7=91?= <1599857331@qq.com> Date: Fri, 4 Jun 2021 17:32:33 +0800 Subject: [PATCH 11/74] =?UTF-8?q?=E5=90=AC=E4=B8=8D=E6=87=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Father.cs" | 26 +++ .../Gamepeople.cs" | 23 ++ .../Oberpeople.cs" | 23 ++ .../Program.cs" | 206 ++++++++++++++++++ 4 files changed, 278 insertions(+) create mode 100644 "\345\274\240\347\233\212\351\243\236/Father.cs" create mode 100644 "\345\274\240\347\233\212\351\243\236/Gamepeople.cs" create mode 100644 "\345\274\240\347\233\212\351\243\236/Oberpeople.cs" create mode 100644 "\345\274\240\347\233\212\351\243\236/Program.cs" diff --git "a/\345\274\240\347\233\212\351\243\236/Father.cs" "b/\345\274\240\347\233\212\351\243\236/Father.cs" new file mode 100644 index 0000000..efee503 --- /dev/null +++ "b/\345\274\240\347\233\212\351\243\236/Father.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + + +namespace ConsoleApp1 +{ + abstract class Father + { + public static string[] fist ={ "石头","剪刀","布" }; + + + private string name; + public string Name { get => name; set => name = value; } + + + + public Father(string Name) + { + this.name = Name; + } + public abstract void Play(); + } +} diff --git "a/\345\274\240\347\233\212\351\243\236/Gamepeople.cs" "b/\345\274\240\347\233\212\351\243\236/Gamepeople.cs" new file mode 100644 index 0000000..38bb682 --- /dev/null +++ "b/\345\274\240\347\233\212\351\243\236/Gamepeople.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Gamepeople:Father + { + public string fisttype; + public static int gamescore; + public Gamepeople(string Name):base(Name) {} + + + + + public override void Play() + { + Console.WriteLine(base.Name + ":" + " 出拳:" +this.fisttype); + } + } +} diff --git "a/\345\274\240\347\233\212\351\243\236/Oberpeople.cs" "b/\345\274\240\347\233\212\351\243\236/Oberpeople.cs" new file mode 100644 index 0000000..705996f --- /dev/null +++ "b/\345\274\240\347\233\212\351\243\236/Oberpeople.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Oberpeople:Father + { + + public static string fistname; + public static int oberscore; + public Oberpeople(string Name) : base(Name) { } + + public Random random = new Random(); + public override void Play() + { + fistname = fist[random.Next(0, 3)]; + Console.WriteLine(base.Name+":"+" 出拳:"+ fistname); + } + } +} diff --git "a/\345\274\240\347\233\212\351\243\236/Program.cs" "b/\345\274\240\347\233\212\351\243\236/Program.cs" new file mode 100644 index 0000000..1459592 --- /dev/null +++ "b/\345\274\240\347\233\212\351\243\236/Program.cs" @@ -0,0 +1,206 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Program + { + + static Gamepeople gone; + static Oberpeople gtwo; + static Boolean TorF=false; + static int c = 0; + static string Gamename; + + static void Main(string[] args) + { + Game(); + } + static void ChooseOber() { + if (c == 1) + { + Gamename = "刘备"; + } + else if (c == 2) + { + Gamename = "孙权"; + } + else if (c == 3) + { + Gamename = "曹操"; + } + Console.WriteLine("请输入您的姓名:"); + string GameName = Console.ReadLine(); + gone = new Gamepeople(GameName); + gtwo = new Oberpeople(Gamename); + Console.WriteLine(gone.Name + " VS " + gtwo.Name + " 对战"); + + Console.WriteLine("开始游戏吗?"); + string numo = Console.ReadLine(); + if (numo == "y") + { + Start(); + } + else + { + Console.WriteLine("已退出!!!"); + } + } + static void Game(){ + Console.WriteLine("---------------------欢迎进入游戏世界-----------------------\n\n\n"); + Console.WriteLine("**************************\n********猜拳,开始********\n**************************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Console.WriteLine("请选择对方角色<1:刘备 2:孙权 3:曹操>"); + int num = Convert.ToInt32(Console.ReadLine()); + + switch (num) + { + case 1: + c = 1; + ChooseOber(); + break; + case 2: + c = 2; + ChooseOber(); + break; + case 3: + c = 3; + ChooseOber(); + break; + default: + Console.WriteLine("输入名字错误,请重新进入游戏!!"); + Game(); + break; + } + } + static void EndScore() { + Console.WriteLine("============================================================="); + Console.WriteLine("姓名 " + " 得分"); + Console.WriteLine(gone.Name + "\t \t"+Gamepeople.gamescore); + Console.WriteLine(gtwo.Name + "\t \t" + Oberpeople.oberscore); + if (Gamepeople.gamescore > Oberpeople.oberscore) + { + Console.WriteLine("结果:" + gone.Name + "赢," + gtwo.Name + "笨蛋"); + } + else if (Gamepeople.gamescore == Oberpeople.oberscore) + { + Console.WriteLine("平局,都不太行!!!"); + } + else + { + Console.WriteLine("结果:" + gtwo.Name + "赢," + gone.Name + "笨蛋"); + } + } + static void AgainStart() { + + if (TorF == true) + { + Console.WriteLine("要开始下一局吗?(y/n)"); + string numo = Console.ReadLine(); + if (numo == "y") + { + Game(); + } + else + { + Console.WriteLine("系统退出!"); + } + } + else { + Console.WriteLine("是否要开始下一轮?"); + string numo = Console.ReadLine(); + + if (numo == "y") + { + Start(); + } + else + { + EndScore(); + Console.WriteLine("退出!"); + + } + } + } + static void Start() { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应数字:)"); + int num2 = Convert.ToInt32(Console.ReadLine()); + switch (num2) + { + case 1: + gone.fisttype = "剪刀"; + Say(); + break; + case 2: + gone.fisttype = "石头"; + Say(); + break; + case 3: + gone.fisttype = "布"; + Say(); + break; + default: + break; + } + Win(); + AgainStart(); + + } + static void Win() { + if (gone.fisttype == "剪刀" && Oberpeople.fistname == "剪刀") + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + else if (gone.fisttype == "剪刀" && Oberpeople.fistname == "石头") + { + Console.WriteLine("笨蛋," + gone.Name + "输了"); + Oberpeople.oberscore++; + } + else if (gone.fisttype == "剪刀" && Oberpeople.fistname == "布") + { + Console.WriteLine("恭喜," + gone.Name + "赢了"); + Gamepeople.gamescore++; + } + else if (gone.fisttype == "石头" && Oberpeople.fistname == "石头") + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + else if (gone.fisttype == "石头" && Oberpeople.fistname == "布") + { + Console.WriteLine("笨蛋," + gone.Name + "输了"); + Oberpeople.oberscore++; + } + else if (gone.fisttype == "石头" && Oberpeople.fistname == "剪刀") + { + Console.WriteLine("恭喜," + gone.Name + "赢了"); + Gamepeople.gamescore++; + } + else if (gone.fisttype == "布" && Oberpeople.fistname == "布") + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + else if (gone.fisttype == "布" && Oberpeople.fistname == "剪刀") + { + Console.WriteLine("笨蛋," + gone.Name + "输了"); + Oberpeople.oberscore++; + } + else if (gone.fisttype == "布" && Oberpeople.fistname == "石头") + { + Console.WriteLine("恭喜," + gone.Name + "赢了"); + Gamepeople.gamescore++; + } + else + { + Console.WriteLine("我是谁?我在哪?"); + } + AgainStart(); + } + static void Say() { + gone.Play(); + gtwo.Play(); + } + } +} -- Gitee From daef93d2a246beaab729133e97566aa0f0ed0ea1 Mon Sep 17 00:00:00 2001 From: EoL <1179233990@qq.com> Date: Fri, 4 Jun 2021 17:34:40 +0800 Subject: [PATCH 12/74] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20?= =?UTF-8?q?=E8=94=A1=E9=9B=AA=E5=BC=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Program.cs" | 137 ------------------ "\350\224\241\351\233\252\345\274\272/cq.cs" | 63 -------- .../play.cs" | 18 --- "\350\224\241\351\233\252\345\274\272/rm.cs" | 22 --- 4 files changed, 240 deletions(-) delete mode 100644 "\350\224\241\351\233\252\345\274\272/Program.cs" delete mode 100644 "\350\224\241\351\233\252\345\274\272/cq.cs" delete mode 100644 "\350\224\241\351\233\252\345\274\272/play.cs" delete mode 100644 "\350\224\241\351\233\252\345\274\272/rm.cs" diff --git "a/\350\224\241\351\233\252\345\274\272/Program.cs" "b/\350\224\241\351\233\252\345\274\272/Program.cs" deleted file mode 100644 index e9c7962..0000000 --- "a/\350\224\241\351\233\252\345\274\272/Program.cs" +++ /dev/null @@ -1,137 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConsoleApp1 -{ - class Program - { - static string b; - public enum cqcq - { - 剪刀=1, - 石头, - 布 - } - static void Main(string[] args) - { - EoL1(); - } - - private static void EoL1() - { - Console.WriteLine("-----------------欢 迎 进 入 游 戏 世 界-----------------"); - Console.WriteLine("*********************************************************"); - Console.WriteLine("***********************猜 拳 开 始***********************"); - Console.WriteLine("*********************************************************"); - Console.WriteLine("猜拳规则:1、剪刀,2、石头,3、布"); - Console.WriteLine("请选择对方角色:<1、刘备,2、孙权,3、曹操>"); - int a = int.Parse(Console.ReadLine()); - switch (a) - { - case 1: - EoL2(); - rm rm1 = new rm("刘备"); - Console.WriteLine(b + "VS" + rm1.rmrm() + "对战"); - Console.WriteLine("开始游戏吗(y/n)"); - string d = Console.ReadLine(); - switch (d) - { - case "y": - Console.WriteLine("请出拳:1、剪刀,2、石头,3、布"); - int e = int.Parse(Console.ReadLine()); - cqcq cq1 = (cqcq)e; - Random r = new Random(); - int c = r.Next(3) + 1; - cqcq cq2 = (cqcq)c; - Console.WriteLine(b + ":出拳:" + cq1); - Console.WriteLine(rm1.rmrm() + " :出拳:" + cq2); - cq cq = new cq(); - play p1 = new play(b); - cq.stjdb1 = ((cqcq)e).ToString(); - cq.stjdb2 = ((cqcq)c).ToString(); - cq.EoL3(); - EoL1(); - break; - case "n": - EoL1(); - break; - default: - break; - } - break; - case 2: - EoL2(); - rm rm2 = new rm("孙权"); - Console.WriteLine(b + "VS" + rm2.rmrm() + "对战"); - Console.WriteLine("开始游戏吗(y/n)"); - d = Console.ReadLine(); - switch (d) - { - case "y": - Console.WriteLine("请出拳:1、剪刀,2、石头,3、布"); - int e = int.Parse(Console.ReadLine()); - cqcq cq1 = (cqcq)e; - Random r = new Random(); - int c = r.Next(3) + 1; - cqcq cq2 = (cqcq)c; - Console.WriteLine(b + ":出拳:" + cq1); - Console.WriteLine(rm2.rmrm() + " :出拳:" + cq2); - cq cq = new cq(); - play p2 = new play(b); - cq.stjdb1 = ((cqcq)e).ToString(); - cq.stjdb2 = ((cqcq)c).ToString(); - cq.EoL3(); - EoL1(); - break; - case "n": - EoL1(); - break; - default: - break; - } - break; - case 3: - EoL2(); - rm rm3 = new rm("曹操"); - Console.WriteLine(b + "VS" + rm3.rmrm() + "对战"); - Console.WriteLine("开始游戏吗(y/n)"); - d = Console.ReadLine(); - switch (d) - { - case "y": - Console.WriteLine("请出拳:1、剪刀,2、石头,3、布"); - int e = int.Parse(Console.ReadLine()); - cqcq cq1 = (cqcq)e; - Random r = new Random(); - int c = r.Next(3) + 1; - cqcq cq2 = (cqcq)c; - Console.WriteLine(b + ":出拳:" + cq1); - Console.WriteLine(rm3.rmrm() + " :出拳:" + cq2); - cq cq = new cq(); - play p3 = new play(b); - cq.stjdb1 = ((cqcq)e).ToString(); - cq.stjdb2 = ((cqcq)c).ToString(); - cq.EoL3(); - EoL1(); - break; - case "n": - EoL1(); - break; - default: - break; - } - break; - default: - break; - } - } - private static void EoL2() - { - Console.WriteLine("输入你的名字"); - b = Console.ReadLine(); - } - } -} diff --git "a/\350\224\241\351\233\252\345\274\272/cq.cs" "b/\350\224\241\351\233\252\345\274\272/cq.cs" deleted file mode 100644 index e99e4f3..0000000 --- "a/\350\224\241\351\233\252\345\274\272/cq.cs" +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConsoleApp1 -{ - class cq:rm - { - public string stjdb1 { get; set; } - public string stjdb2 { get; set; } - - public void EoL3() - { - if (stjdb1.Equals("剪刀")) - { - if (stjdb2.Equals("剪刀")) - { - Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); - } - if (stjdb2.Equals("石头")) - { - Console.WriteLine("笨蛋,你真菜"); - } - if (stjdb2.Equals("布")) - { - Console.WriteLine("恭喜,你真猛"); - } - } - if (stjdb1.Equals("石头")) - { - if (stjdb2.Equals("剪刀")) - { - Console.WriteLine("恭喜,你真猛"); - } - if (stjdb2.Equals("石头")) - { - Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); - } - if (stjdb2.Equals("布")) - { - Console.WriteLine("笨蛋,你真菜"); - } - } - if (stjdb1.Equals("布")) - { - if (stjdb2.Equals("剪刀")) - { - Console.WriteLine("笨蛋,你真菜"); - } - if (stjdb2.Equals("石头")) - { - Console.WriteLine("恭喜,你真猛"); - } - if (stjdb2.Equals("布")) - { - Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); - } - } - } - } -} diff --git "a/\350\224\241\351\233\252\345\274\272/play.cs" "b/\350\224\241\351\233\252\345\274\272/play.cs" deleted file mode 100644 index 836166c..0000000 --- "a/\350\224\241\351\233\252\345\274\272/play.cs" +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConsoleApp1 -{ - class play - { - public string name1 { get; set; } - public play() { } - public play(string name1) - { - this.name1 = name1; - } - } -} diff --git "a/\350\224\241\351\233\252\345\274\272/rm.cs" "b/\350\224\241\351\233\252\345\274\272/rm.cs" deleted file mode 100644 index c3b4ea0..0000000 --- "a/\350\224\241\351\233\252\345\274\272/rm.cs" +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConsoleApp1 -{ - class rm:play - { - public string name { get; set; } - public rm() { } - public rm(string name) - { - this.name = name; - } - public string rmrm() - { - return name; - } - } -} -- Gitee From 854bcf1fe58e491b71b2e185ca7ad0a1654cee9d Mon Sep 17 00:00:00 2001 From: EoL <1179233990@qq.com> Date: Fri, 4 Jun 2021 17:34:49 +0800 Subject: [PATCH 13/74] 1 --- .../Program.cs" | 73 +++++++++++++++++++ "\350\224\241\351\233\252\345\274\272/cq.cs" | 63 ++++++++++++++++ .../play.cs" | 18 +++++ "\350\224\241\351\233\252\345\274\272/rm.cs" | 22 ++++++ 4 files changed, 176 insertions(+) create mode 100644 "\350\224\241\351\233\252\345\274\272/Program.cs" create mode 100644 "\350\224\241\351\233\252\345\274\272/cq.cs" create mode 100644 "\350\224\241\351\233\252\345\274\272/play.cs" create mode 100644 "\350\224\241\351\233\252\345\274\272/rm.cs" diff --git "a/\350\224\241\351\233\252\345\274\272/Program.cs" "b/\350\224\241\351\233\252\345\274\272/Program.cs" new file mode 100644 index 0000000..ecf3682 --- /dev/null +++ "b/\350\224\241\351\233\252\345\274\272/Program.cs" @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Program + { + static string b; + public enum rmrm + { + 刘备=1, + 孙权, + 曹操 + } + public enum cqcq + { + 剪刀=1, + 石头, + 布 + } + static void Main(string[] args) + { + EoL1(); + } + + private static void EoL1() + { + Console.WriteLine("-----------------欢 迎 进 入 游 戏 世 界-----------------"); + Console.WriteLine("*********************************************************"); + Console.WriteLine("***********************猜 拳 开 始***********************"); + Console.WriteLine("*********************************************************"); + Console.WriteLine("猜拳规则:1、剪刀,2、石头,3、布"); + Console.WriteLine("请选择对方角色:<1、刘备,2、孙权,3、曹操>"); + int a = int.Parse(Console.ReadLine()); + rmrm rmrm1 = (rmrm)a; + Console.WriteLine("输入你的名字"); + b = Console.ReadLine(); + rm rm = new rm((rmrm1).ToString()); + Console.WriteLine(b + "VS" + rm.rmrm() + "对战"); + Console.WriteLine("开始游戏吗(y/n)"); + string d = Console.ReadLine(); + switch (d) + { + case "y": + Console.WriteLine("请出拳:1、剪刀,2、石头,3、布"); + int e = int.Parse(Console.ReadLine()); + cqcq cq1 = (cqcq)e; + Random r = new Random(); + int c = r.Next(3) + 1; + cqcq cq2 = (cqcq)c; + Console.WriteLine(b + ":出拳:" + cq1); + Console.WriteLine(rm.rmrm() + " :出拳:" + cq2); + cq cq = new cq(); + play p1 = new play(b); + cq.stjdb1 = ((cqcq)e).ToString(); + cq.stjdb2 = ((cqcq)c).ToString(); + cq.EoL3(); + EoL1(); + break; + case "n": + EoL1(); + break; + default: + Console.WriteLine("别乱按"); + EoL1(); + break; + } + } + } +} diff --git "a/\350\224\241\351\233\252\345\274\272/cq.cs" "b/\350\224\241\351\233\252\345\274\272/cq.cs" new file mode 100644 index 0000000..e99e4f3 --- /dev/null +++ "b/\350\224\241\351\233\252\345\274\272/cq.cs" @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class cq:rm + { + public string stjdb1 { get; set; } + public string stjdb2 { get; set; } + + public void EoL3() + { + if (stjdb1.Equals("剪刀")) + { + if (stjdb2.Equals("剪刀")) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + if (stjdb2.Equals("石头")) + { + Console.WriteLine("笨蛋,你真菜"); + } + if (stjdb2.Equals("布")) + { + Console.WriteLine("恭喜,你真猛"); + } + } + if (stjdb1.Equals("石头")) + { + if (stjdb2.Equals("剪刀")) + { + Console.WriteLine("恭喜,你真猛"); + } + if (stjdb2.Equals("石头")) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + if (stjdb2.Equals("布")) + { + Console.WriteLine("笨蛋,你真菜"); + } + } + if (stjdb1.Equals("布")) + { + if (stjdb2.Equals("剪刀")) + { + Console.WriteLine("笨蛋,你真菜"); + } + if (stjdb2.Equals("石头")) + { + Console.WriteLine("恭喜,你真猛"); + } + if (stjdb2.Equals("布")) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + } + } + } +} diff --git "a/\350\224\241\351\233\252\345\274\272/play.cs" "b/\350\224\241\351\233\252\345\274\272/play.cs" new file mode 100644 index 0000000..836166c --- /dev/null +++ "b/\350\224\241\351\233\252\345\274\272/play.cs" @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class play + { + public string name1 { get; set; } + public play() { } + public play(string name1) + { + this.name1 = name1; + } + } +} diff --git "a/\350\224\241\351\233\252\345\274\272/rm.cs" "b/\350\224\241\351\233\252\345\274\272/rm.cs" new file mode 100644 index 0000000..c3b4ea0 --- /dev/null +++ "b/\350\224\241\351\233\252\345\274\272/rm.cs" @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class rm:play + { + public string name { get; set; } + public rm() { } + public rm(string name) + { + this.name = name; + } + public string rmrm() + { + return name; + } + } +} -- Gitee From 9cc9e24a23f9c46ed3ff3119832f172d81f20630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=83=B3=E5=8F=98=E5=B0=8F=E7=8C=AA?= <1589953126@qq.com> Date: Fri, 4 Jun 2021 17:40:43 +0800 Subject: [PATCH 14/74] C# --- .../Program.cs" | 127 +++++++++++++++++ "\346\261\237\346\226\260\344\274\240/yx.cs" | 132 ++++++++++++++++++ 2 files changed, 259 insertions(+) create mode 100644 "\346\261\237\346\226\260\344\274\240/Program.cs" create mode 100644 "\346\261\237\346\226\260\344\274\240/yx.cs" diff --git "a/\346\261\237\346\226\260\344\274\240/Program.cs" "b/\346\261\237\346\226\260\344\274\240/Program.cs" new file mode 100644 index 0000000..4882f4f --- /dev/null +++ "b/\346\261\237\346\226\260\344\274\240/Program.cs" @@ -0,0 +1,127 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApplication6 +{ + class Program + { + public static void Main(string[] args) + { + Console.WriteLine("-------------欢迎进入游戏世界---------------"); + Console.WriteLine("************************"); + Console.WriteLine("*******猜拳,开始*******"); + Console.WriteLine("************************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + + Console.WriteLine("请选择对方角色(1.刘备 2.曹操 3.孙权)"); + int key = int.Parse(Console.ReadLine()); + yx sb = new yx(); + + switch (key) + { + case 1: + + + sb.Dsm = "刘备"; + + Console.WriteLine("请输入您的名字:"); + string myname = Console.ReadLine(); + + + Console.WriteLine("{0} VS {1} 对战",myname,sb.Dsm); + + + Console.WriteLine("开始游戏吗?(y/n)"); + char a = char.Parse(Console.ReadLine()); + + switch (a) + { + case 'y': + + yx.cq(sb.Dsm, myname); + break; + case 'n': + + Console.WriteLine("怂逼!这么怂!还打个鬼游戏,浪费表情,滚!!!"); + break; + + default: + break; + } + + break; + case 2: + + sb.Dsm = "曹操"; + + Console.WriteLine("请输入您的名字:"); + string myname1 = Console.ReadLine(); + + Console.WriteLine("{0} VS {1} 对战", myname1, sb.Dsm); + + + Console.WriteLine("开始游戏吗?(y/n)"); + char b = char.Parse(Console.ReadLine()); + + switch (b) + { + case 'y': + + yx.cq(sb.Dsm, myname1); + break; + case 'n': + + Console.WriteLine("怂逼!这么怂!还打个鬼游戏,浪费表情,滚!!!"); + break; + + default: + break; + } + break; + + case 3: + sb.Dsm = "孙权"; + + Console.WriteLine("请输入您的名字:"); + string myname2 = Console.ReadLine(); + + Console.WriteLine("{0} VS {1} 对战", myname2, sb.Dsm); + + Console.WriteLine("开始游戏吗?(y/n)"); + char c = char.Parse(Console.ReadLine()); + + + switch (c) + { + case 'y': + + yx.cq(sb.Dsm, myname2); + break; + case 'n': + + Console.WriteLine("怂逼!这么怂!还打个鬼游戏,浪费表情,滚!!!"); + break; + + default: + break; + } + + + break; + + + + default: + break; + } + + + } + + + + } +} diff --git "a/\346\261\237\346\226\260\344\274\240/yx.cs" "b/\346\261\237\346\226\260\344\274\240/yx.cs" new file mode 100644 index 0000000..5f3615a --- /dev/null +++ "b/\346\261\237\346\226\260\344\274\240/yx.cs" @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApplication6 +{ + public class yx + { + private string _dsm; + + + public string Dsm{ + + get { return _dsm; } + set { _dsm = value; } + } + + + + + + + public static void cq(string ds,string me) + { + + int dc=0 ; + int medf=0; + int dsdf=0 ; + + ll: + dc++; + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布 (输入相应数字:)"); + int q = int.Parse(Console.ReadLine()); + + string[] b = { "剪刀", "石头", "布" }; + int a; + Random sb = new Random(); + + a = sb.Next(3); + + Console.WriteLine("{0}: 出拳:{1}", me, b[q-1]); + Console.WriteLine("{0}: 出拳:{1}", ds, b[a]); + + + if ((q-1 == 0 && a == 2) || (q-1 == 1 && a == 0) || (q-1 == 2 && a == 1)) + { + Console.WriteLine("恭喜,{0}赢了",me); + + + medf++; + + + } else if (q-1==a) { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + + + } + else + { + Console.WriteLine("笨蛋,{0}输了",me); + + dsdf++; + + } + + Console.WriteLine("是否开始下一轮?(y/n)"); + char s = char.Parse(Console.ReadLine()); + + if (s == 'y') + { + + goto ll; + + } + else if (s == 'n') + { + jg(dc, ds, me, medf, dsdf); + } + + + + } + + + + public static void jg(int dc, string ds, string me, int medf, int dsdf) { + + Console.WriteLine("{0} VS {1}\n对战次数{2}\n\n姓名\t得分\n{3}\t{4}\n{5}\t{6}",ds,me,dc,me,medf,ds,dsdf); + if (dsdf>medf) + { + Console.WriteLine("结果:{0}赢,{1}笨蛋",ds,me); + } + else if(dsdf==medf) + { + Console.WriteLine("结果:和局,真不错"); + } + else + { + Console.WriteLine("结果:{0}赢,{1}笨蛋",me,ds); + } + + + + + Console.WriteLine("要开始下一轮吗?(y/n)"); + char a = char.Parse(Console.ReadLine()); + switch (a) + { + case 'y': + string []c = { "a" }; + Program.Main(c); + + break; + + + case 'n': + Console.WriteLine("已退出"); + break; + default: + break; + } + + + } + + + + } + +} -- Gitee From c1527506bd6541875f03152127f5bf7cc6aaeafe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E9=9B=A8=E6=AC=A3?= <2523868292@qq.com> Date: Fri, 4 Jun 2021 18:32:32 +0800 Subject: [PATCH 15/74] =?UTF-8?q?=E7=BD=97=E9=9B=A8=E6=AC=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\347\275\227\351\233\250\346\254\243/NPC.cs" | 22 ++++++ .../Program.cs" | 72 +++++++++++++++++++ "\347\275\227\351\233\250\346\254\243/cq.cs" | 63 ++++++++++++++++ "\347\275\227\351\233\250\346\254\243/wan.cs" | 18 +++++ 4 files changed, 175 insertions(+) create mode 100644 "\347\275\227\351\233\250\346\254\243/NPC.cs" create mode 100644 "\347\275\227\351\233\250\346\254\243/Program.cs" create mode 100644 "\347\275\227\351\233\250\346\254\243/cq.cs" create mode 100644 "\347\275\227\351\233\250\346\254\243/wan.cs" diff --git "a/\347\275\227\351\233\250\346\254\243/NPC.cs" "b/\347\275\227\351\233\250\346\254\243/NPC.cs" new file mode 100644 index 0000000..c5897a1 --- /dev/null +++ "b/\347\275\227\351\233\250\346\254\243/NPC.cs" @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class NPC + { + public string name1 { get; set; } + public NPC() { } + public NPC(string name1) + { + this.name1 = name1; + } + public string npcnpc() + { + return name1; + } + } +} diff --git "a/\347\275\227\351\233\250\346\254\243/Program.cs" "b/\347\275\227\351\233\250\346\254\243/Program.cs" new file mode 100644 index 0000000..8bae07a --- /dev/null +++ "b/\347\275\227\351\233\250\346\254\243/Program.cs" @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Program + { + enum npc + { + 刘备=1, + 孙权, + 曹操 + } + enum gz + { + 石头=1, + 剪刀, + 布 + } + static void Main(string[] args) + { + begin(); + Console.ReadKey(); + } + static void begin() + { + Console.WriteLine("---------欢 迎 进 入 游 戏 世 界------------"); + Console.WriteLine("*************************************8"); + Console.WriteLine("*************猜 拳 开 始**************"); + Console.WriteLine("***************************************"); + Console.WriteLine("猜拳规则:1、剪刀,2、石头,3、布"); + Console.WriteLine("请选择对方角色:1、刘备,2、孙权,3、曹操"); + int a = int.Parse(Console.ReadLine()); + npc npc1 = (npc)a; + Console.WriteLine("输入你的名字"); + string b = Console.ReadLine(); + NPC npc11 = new NPC((npc1).ToString()); + Console.WriteLine(b + "VS" + npc11.npcnpc() + "对战"); + Console.WriteLine("开始游戏吗(y/n)"); + string key = Console.ReadLine(); + switch (key) + { + case "y": + Console.WriteLine("请出拳:1、剪刀,2、石头,3、布"); + int e = int.Parse(Console.ReadLine()); + gz cq1 = (gz)e; + Random r = new Random(); + int c = r.Next(3) + 1; + gz cq2 = (gz)c; + Console.WriteLine(b + ":出拳:" + cq1); + Console.WriteLine(npc11.npcnpc() + " :出拳:" + cq2); + cq cq = new cq(); + wan p1 = new wan(b); + cq.cp = ((gz)e).ToString(); + cq.cp1 = ((gz)c).ToString(); + cq.chuquan(); + begin(); + break; + case "n": + begin(); + break; + default: + Console.WriteLine("按都按歪来"); + begin(); + break; + } + } + } +} diff --git "a/\347\275\227\351\233\250\346\254\243/cq.cs" "b/\347\275\227\351\233\250\346\254\243/cq.cs" new file mode 100644 index 0000000..d95a081 --- /dev/null +++ "b/\347\275\227\351\233\250\346\254\243/cq.cs" @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class cq + { + public string cp { get; set; } + public string cp1 { get; set; } + + public void chuquan() + { + if (cp.Equals("剪刀")) + { + if (cp1.Equals("剪刀")) + { + Console.WriteLine("和局,真衰"); + } + if (cp1.Equals("石头")) + { + Console.WriteLine("笨蛋,你真菜"); + } + if (cp1.Equals("布")) + { + Console.WriteLine("玩的不错"); + } + } + if (cp.Equals("石头")) + { + if (cp1.Equals("剪刀")) + { + Console.WriteLine("玩的不错"); + } + if (cp1.Equals("石头")) + { + Console.WriteLine("和局,真衰!"); + } + if (cp1.Equals("布")) + { + Console.WriteLine("笨蛋,你真菜"); + } + } + if (cp.Equals("布")) + { + if (cp1.Equals("剪刀")) + { + Console.WriteLine("笨蛋,你真菜"); + } + if (cp1.Equals("石头")) + { + Console.WriteLine("玩的不错"); + } + if (cp1.Equals("布")) + { + Console.WriteLine("和局,真衰"); + } + } + } + } +} diff --git "a/\347\275\227\351\233\250\346\254\243/wan.cs" "b/\347\275\227\351\233\250\346\254\243/wan.cs" new file mode 100644 index 0000000..5fa4849 --- /dev/null +++ "b/\347\275\227\351\233\250\346\254\243/wan.cs" @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class wan + { + public string name { get; set; } + public wan() { } + public wan(string name) + { + this.name = name; + } + } +} -- Gitee From 4e5968a7d76ac737db6384befe56ebcf484e2fb8 Mon Sep 17 00:00:00 2001 From: mao Date: Fri, 4 Jun 2021 19:00:49 +0800 Subject: [PATCH 16/74] 2021-6-4 19:00 --- .../Judgment.cs" | 1 - "\351\231\210\350\257\227\346\235\260/NPC.cs" | 17 +++++++++-------- .../Player.cs" | 10 ++++++++-- .../Program.cs" | 16 ++++++++++++---- 4 files changed, 29 insertions(+), 15 deletions(-) diff --git "a/\351\231\210\350\257\227\346\235\260/Judgment.cs" "b/\351\231\210\350\257\227\346\235\260/Judgment.cs" index cf5e0aa..b909561 100644 --- "a/\351\231\210\350\257\227\346\235\260/Judgment.cs" +++ "b/\351\231\210\350\257\227\346\235\260/Judgment.cs" @@ -82,7 +82,6 @@ namespace _2021_6_4 countBattle++; npcScore++; Console.WriteLine($"{npcName}胜!"); - } } } diff --git "a/\351\231\210\350\257\227\346\235\260/NPC.cs" "b/\351\231\210\350\257\227\346\235\260/NPC.cs" index b20a67e..c34ecea 100644 --- "a/\351\231\210\350\257\227\346\235\260/NPC.cs" +++ "b/\351\231\210\350\257\227\346\235\260/NPC.cs" @@ -6,12 +6,7 @@ using System.Threading.Tasks; namespace _2021_6_4 { - public enum janKenPunch - { - 剪刀, - 石头, - 布 - } + //NPC类 实现石头剪刀布 class NPC : IJanKenPunch_ { @@ -19,6 +14,8 @@ namespace _2021_6_4 public string NpcName { get => npcName; set => npcName = value; } + public janKenPunch npcAction; + public NPC(string name) { this.NpcName = name; @@ -31,8 +28,8 @@ namespace _2021_6_4 public janKenPunch DoJanKenPunch() { Random r = new Random(); - int id = r.Next(2); - + int id = r.Next(1,3); + npcAction = (janKenPunch)id; return (janKenPunch)id; } @@ -40,5 +37,9 @@ namespace _2021_6_4 { throw new NotImplementedException(); } + public override string ToString() + { + return $"{NpcName}:{npcAction}"; + } } } diff --git "a/\351\231\210\350\257\227\346\235\260/Player.cs" "b/\351\231\210\350\257\227\346\235\260/Player.cs" index a1dc119..79e221f 100644 --- "a/\351\231\210\350\257\227\346\235\260/Player.cs" +++ "b/\351\231\210\350\257\227\346\235\260/Player.cs" @@ -9,7 +9,7 @@ namespace _2021_6_4 class Player : IJanKenPunch_ { private string playerName; - + janKenPunch playerAction; public string PlayerName { get => playerName; set => playerName = value; } public Player(string name) @@ -19,12 +19,18 @@ namespace _2021_6_4 public janKenPunch DoJanKenPunch(int key) { - return (janKenPunch)key; + playerAction = (janKenPunch)(key); + return (janKenPunch)(key); } public janKenPunch DoJanKenPunch() { throw new NotImplementedException(); } + + public override string ToString() + { + return $"{playerName}:{playerAction}"; + } } } diff --git "a/\351\231\210\350\257\227\346\235\260/Program.cs" "b/\351\231\210\350\257\227\346\235\260/Program.cs" index f339044..bad27ab 100644 --- "a/\351\231\210\350\257\227\346\235\260/Program.cs" +++ "b/\351\231\210\350\257\227\346\235\260/Program.cs" @@ -6,6 +6,12 @@ using System.Threading.Tasks; namespace _2021_6_4 { + public enum janKenPunch + { + 剪刀 = 1, + 石头, + 布 + } class Program { static void Main(string[] args) @@ -42,9 +48,10 @@ namespace _2021_6_4 } #endregion - #region 创建玩家对象 + #region 创建玩家和裁判的对象 Console.WriteLine("请输入你的名字:"); player = new Player(Console.ReadLine()); + Console.WriteLine(); jud = new Judgment(Player: player.PlayerName, Npc: enemy.NpcName); #endregion @@ -53,16 +60,17 @@ namespace _2021_6_4 { Console.WriteLine("请出拳:"); key = int.Parse(Console.ReadLine()); - if (key >= 1 & key <= 3) - { + if (key >= 1 & key <= 3) + { jud.Decide(player: player.DoJanKenPunch(key), npc: enemy.DoJanKenPunch()); + Console.WriteLine("信息:\n" + player +"\n" + enemy); Console.WriteLine("按y开始下一局,任意键退出:"); if ((Console.ReadLine().Equals("y")) == false) { break; } - } + } else { Console.WriteLine("输入有误!"); -- Gitee From 8cf63df252942848d78b0100da3b82582b47b4eb Mon Sep 17 00:00:00 2001 From: lazy-scholar-cat <2220771866@qq.com> Date: Fri, 4 Jun 2021 19:35:44 +0800 Subject: [PATCH 17/74] cat --- .../Character.cs" | 25 ++ .../Program.cs" | 259 ++++++++++++++++++ .../actionable.cs" | 61 +++++ .../player.cs" | 48 ++++ 4 files changed, 393 insertions(+) create mode 100644 "\345\224\220\344\274\237\345\273\272/Character.cs" create mode 100644 "\345\224\220\344\274\237\345\273\272/Program.cs" create mode 100644 "\345\224\220\344\274\237\345\273\272/actionable.cs" create mode 100644 "\345\224\220\344\274\237\345\273\272/player.cs" diff --git "a/\345\224\220\344\274\237\345\273\272/Character.cs" "b/\345\224\220\344\274\237\345\273\272/Character.cs" new file mode 100644 index 0000000..8cc5b29 --- /dev/null +++ "b/\345\224\220\344\274\237\345\273\272/Character.cs" @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + public enum name + { + 刘备 = 1, + 孙权, + 曹操 + } + class Character:actionable + { + public name heroName { get; set; } + + public Character(name heroName) + { + this.heroName = heroName; + } + + } +} diff --git "a/\345\224\220\344\274\237\345\273\272/Program.cs" "b/\345\224\220\344\274\237\345\273\272/Program.cs" new file mode 100644 index 0000000..2e9815d --- /dev/null +++ "b/\345\224\220\344\274\237\345\273\272/Program.cs" @@ -0,0 +1,259 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + public enum Name + { + 刘备 = 1, + 孙权, + 曹操 + } + public enum act + { + 剪刀 = 1, + 石头, + 布 + } + class Program + { + static void Main(string[] args) + { + + + Console.WriteLine("----------welcome to game world---------"); + Console.WriteLine("**********************"); + Console.WriteLine("*****猜拳游戏开始*****"); + Console.WriteLine("**********************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Console.WriteLine("全选择对方玩家:1.刘备 2.孙权 3.曹操"); + + + //电脑玩家的命名 + int computer = int.Parse(Console.ReadLine()); + + Name name = Name.刘备; + + name = (Name)computer; + + + + + + + //游戏玩家的命名 + Console.WriteLine("输入您的名称"); + string player = Console.ReadLine(); + + player P = new player(player); + + + Console.WriteLine(player + " " + "VS" + " " + name); + + int time = 0; + + int[] Play = {0}; + int[] Computer = { 0}; + + + perpare(name, P, time, Play, Computer); + + + + + + + + + + } + + private static void perpare(Name name, player P, int time, int[] Play, int[] Computer) + { + Console.WriteLine("开始游戏吗? Y/N"); + + string key = Console.ReadLine(); + + + + switch (key) + { + case "y": + + + gamebegin(name, P, time, Play, Computer); + + break; + + case "n": + + Console.WriteLine("结束"); + + break; + default: + break; + } + } + + private static void gameover(Name name, player P, int time, int[] Play, int[] Computer) + { + + Console.WriteLine("是否开启新一轮?Y/N"); + string T = Console.ReadLine(); + switch (T) + { + case "y": + gamebegin(name, P, time, Play, Computer); + + break; + case "n": + + result(name, P, time, Play, Computer); + + gameAgain(name, P, time, Play, Computer); + + break; + + default: + break; + } + } + + private static void gameAgain(Name name, player P, int time, int[] Play, int[] Computer) + { + Console.WriteLine("是否开启下一局?Y/N"); + string T = Console.ReadLine(); + switch (T) + { + case "y": + gamebegin(name, P, time, Play, Computer); + break; + case "n": + Console.WriteLine("游戏结束了"); + break; + + default: + break; + } + } + + private static void result(Name name, player P, int time, int[] Play, int[] Computer) + { + + Console.WriteLine("=================="); + Character character = new Character((name)name); + + Console.WriteLine(P.Player + " " + "VS" + " " + name); + + Console.WriteLine("对战次数:" + time); + + judgment j = new judgment(); + + + Console.WriteLine("姓名\t得分"); + + Console.WriteLine(P.Player + " " + Play[0]); + Console.WriteLine(name + " " + Computer[0]); + + if (Play[0] > Computer[0]) + { + Console.WriteLine(P.Player + "胜利" + " | " + name + "猪一样"); + } + else + { + Console.WriteLine("结果" + name + "胜利" + " | " + P.Player + "猪一样"); + } + + + + + } + + private static void gamebegin(Name name, player P, int time, int[] Play, int[] Computer) + { + + + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应数字)"); + + //玩家 + + int p = int.Parse(Console.ReadLine()); + + + + //电脑 + Character character = new Character((name)name); + + + + //裁判 + judgment J = new judgment(); + + judge(P.fingerGuess(p), character.fingerGuess(character), Play, Computer); + // J.judge(P.fingerGuess(p), character.fingerGuess(character), Play, Computer); + + time++; + + + gameover(name, P, time, Play, Computer); + + } + public static void judge(int player, int computer, int[] Play, int[] Computer) + { + + + if (player == 1 & computer == 2) + { + Console.WriteLine("恭喜你输了,猪一样"); + Computer[0]++; + + } + else if (player == 1 & computer == 3) + { + Console.WriteLine("恭喜你赢了"); + Play[0]++; + + } + else if (player == 1 & computer == 1) + { + Console.WriteLine("平手"); + } + //石头 + else if (player == 2 & computer == 3) + { + Console.WriteLine("恭喜你输了,猪一样"); + Computer[0]++; + } + else if (player == 2 & computer == 1) + { + Console.WriteLine("恭喜你赢了"); + Play[0]++; + } + else if (player == 2 & computer == 2) + { + Console.WriteLine("平手"); + } + //布 + else if (player == 3 & computer == 1) + { + Console.WriteLine("恭喜你输了,猪一样"); + Computer[0]++; + } + else if (player == 3 & computer == 2) + { + Console.WriteLine("恭喜你赢了"); + Play[0]++; + } + else if (player == 3 & computer == 3) + { + Console.WriteLine("平手"); + } + + } + } + + +} diff --git "a/\345\224\220\344\274\237\345\273\272/actionable.cs" "b/\345\224\220\344\274\237\345\273\272/actionable.cs" new file mode 100644 index 0000000..b3f4e9b --- /dev/null +++ "b/\345\224\220\344\274\237\345\273\272/actionable.cs" @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class actionable + { + + + public virtual int fingerGuess(Character name) + { + + Random random = new Random(); + + int output = random.Next(3) + 1; + + int Result; + + switch (output) + { + case 1: + Console.WriteLine(name.heroName + ":出剪刀");//-1 + Result = 1; + break; + case 2: + Console.WriteLine(name.heroName + ":出拳头");//0 + Result = 2; + break; + case 3: + Console.WriteLine(name.heroName + ":出布");//1 + Result = 3; + break; + + + default: + Result = 1; + break; + } + + return Result; + + + + + } + + + + + + + + + + + + } +} diff --git "a/\345\224\220\344\274\237\345\273\272/player.cs" "b/\345\224\220\344\274\237\345\273\272/player.cs" new file mode 100644 index 0000000..fd01b11 --- /dev/null +++ "b/\345\224\220\344\274\237\345\273\272/player.cs" @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class player : actionable + { + public string Player { get; set; } + + public player(string Player) + { + this.Player = Player; + } + + public int fingerGuess(int p) + { + + int Result; + + switch (p) + { + case 1: + Console.WriteLine(Player + ":出剪刀");//-1 + Result = 1; + break; + case 2: + Console.WriteLine(Player + ":出拳头");//0 + Result = 2; + break; + case 3: + Console.WriteLine(Player + ":出布");//1 + Result = 3; + break; + + + default: + Result = 1; + break; + } + + return Result; + } + + } +} -- Gitee From a334b5667d6b45883e533c0c93d05b324ea60667 Mon Sep 17 00:00:00 2001 From: lazy-scholar-cat <2220771866@qq.com> Date: Fri, 4 Jun 2021 19:43:59 +0800 Subject: [PATCH 18/74] cat --- .../Program.cs" | 60 +++++++------------ 1 file changed, 22 insertions(+), 38 deletions(-) diff --git "a/\345\224\220\344\274\237\345\273\272/Program.cs" "b/\345\224\220\344\274\237\345\273\272/Program.cs" index 2e9815d..1649556 100644 --- "a/\345\224\220\344\274\237\345\273\272/Program.cs" +++ "b/\345\224\220\344\274\237\345\273\272/Program.cs" @@ -40,10 +40,6 @@ namespace ConsoleApp1 name = (Name)computer; - - - - //游戏玩家的命名 Console.WriteLine("输入您的名称"); string player = Console.ReadLine(); @@ -52,23 +48,15 @@ namespace ConsoleApp1 Console.WriteLine(player + " " + "VS" + " " + name); - + //比赛场数 int time = 0; - int[] Play = {0}; - int[] Computer = { 0}; - + int[] Play = { 0 };//玩家分数 + int[] Computer = { 0 };//电脑分数 + //游戏准备开始 perpare(name, P, time, Play, Computer); - - - - - - - - } private static void perpare(Name name, player P, int time, int[] Play, int[] Computer) @@ -78,26 +66,22 @@ namespace ConsoleApp1 string key = Console.ReadLine(); - switch (key) { case "y": - gamebegin(name, P, time, Play, Computer); - break; case "n": Console.WriteLine("结束"); - break; default: break; } } - + //游戏结束 询问是否重新再玩 private static void gameover(Name name, player P, int time, int[] Play, int[] Computer) { @@ -121,7 +105,7 @@ namespace ConsoleApp1 break; } } - + //再次游戏 private static void gameAgain(Name name, player P, int time, int[] Play, int[] Computer) { Console.WriteLine("是否开启下一局?Y/N"); @@ -139,11 +123,11 @@ namespace ConsoleApp1 break; } } - + //比赛结果 private static void result(Name name, player P, int time, int[] Play, int[] Computer) { - Console.WriteLine("=================="); + Console.WriteLine("========================"); Character character = new Character((name)name); Console.WriteLine(P.Player + " " + "VS" + " " + name); @@ -166,41 +150,41 @@ namespace ConsoleApp1 { Console.WriteLine("结果" + name + "胜利" + " | " + P.Player + "猪一样"); } - + if (Play[0] == Computer[0]) + { + Console.WriteLine("双方平手"); + } } - + //开始游戏 private static void gamebegin(Name name, player P, int time, int[] Play, int[] Computer) { Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应数字)"); - //玩家 + //玩家输入 int p = int.Parse(Console.ReadLine()); - - //电脑 + //电脑玩家 Character character = new Character((name)name); - - //裁判 - judgment J = new judgment(); - judge(P.fingerGuess(p), character.fingerGuess(character), Play, Computer); - // J.judge(P.fingerGuess(p), character.fingerGuess(character), Play, Computer); - + // J.judge(P.fingerGuess(p), character.fingerGuess(character), Play, Computer); + + //比赛次数 time++; gameover(name, P, time, Play, Computer); } + //裁判判断 public static void judge(int player, int computer, int[] Play, int[] Computer) { @@ -251,9 +235,9 @@ namespace ConsoleApp1 { Console.WriteLine("平手"); } - + } } - - + + } -- Gitee From c8f5196871d675ce74c34e15548bc95f5b22094e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=BC=E7=9D=80=E5=A5=B6=E7=93=B6=E5=8E=BB=E6=89=93?= =?UTF-8?q?=E8=99=8E?= <1348328020@qq.com> Date: Fri, 4 Jun 2021 20:04:37 +0800 Subject: [PATCH 19/74] aasdasd --- .../Father.cs" | 31 ++++ "\351\255\217\346\265\267\350\215\243/NPC.cs" | 41 +++++ .../Program.cs" | 147 ++++++++++++++++++ .../User.cs" | 38 +++++ 4 files changed, 257 insertions(+) create mode 100644 "\351\255\217\346\265\267\350\215\243/Father.cs" create mode 100644 "\351\255\217\346\265\267\350\215\243/NPC.cs" create mode 100644 "\351\255\217\346\265\267\350\215\243/Program.cs" create mode 100644 "\351\255\217\346\265\267\350\215\243/User.cs" diff --git "a/\351\255\217\346\265\267\350\215\243/Father.cs" "b/\351\255\217\346\265\267\350\215\243/Father.cs" new file mode 100644 index 0000000..d9385fb --- /dev/null +++ "b/\351\255\217\346\265\267\350\215\243/Father.cs" @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp7 +{ + class Father + { + public enum fist + { + 石头 = 1, + 剪刀, + 布 + } + public string name { get; set; } + public string name1 { get; set; } + + public Father(string name, string name1) + { + this.name = name; + this.name1 = name1; + } + public virtual fist Fist() + { + fist fist = fist.剪刀; + return fist; + } + } +} diff --git "a/\351\255\217\346\265\267\350\215\243/NPC.cs" "b/\351\255\217\346\265\267\350\215\243/NPC.cs" new file mode 100644 index 0000000..f67519b --- /dev/null +++ "b/\351\255\217\346\265\267\350\215\243/NPC.cs" @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp7 +{ + + class NPC:Father + { + + public NPC(string name, string name1):base(name,name1){ } + + public void talk1() + { + Console.WriteLine($"恭喜!{name}赢了!"); + } + + public void talk2() + { + Console.WriteLine($"太拉了!{name}输了!"); + } + public void talk3() + { + Console.WriteLine("和局,真衰!嘿嘿等着瞧吧!"); + } + public void talk4() + { + Console.Write($"{name1}: 出拳:"); + Console.WriteLine(Fist()); + } + public override fist Fist() + { + Random red = new Random(); + int key = red.Next(1, 4); + fist f = (fist)key; + return f; + } + } +} diff --git "a/\351\255\217\346\265\267\350\215\243/Program.cs" "b/\351\255\217\346\265\267\350\215\243/Program.cs" new file mode 100644 index 0000000..9092938 --- /dev/null +++ "b/\351\255\217\346\265\267\350\215\243/Program.cs" @@ -0,0 +1,147 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp7 +{ + + class Program + { + enum Fist + { + 石头 = 1, + 剪刀, + 布 + } + static string userName; + static void Main(string[] args) + { + Console.WriteLine("------------欢 迎 进 入 游 戏 世 界------------"); + Console.WriteLine(); + Console.WriteLine("************************"); + Console.WriteLine("*******猜拳·开始*******"); + Console.WriteLine("************************"); + Console.WriteLine("出拳规则:{0}", ListFist()); + Task1(); + } + + public static void Task1() + { + Console.WriteLine("请选择对方角色(1:刘备 2:孙权 3:曹操)"); + int Key = int.Parse(Console.ReadLine()); + Console.Write("请输入您的姓名:"); + userName = Console.ReadLine(); + string npcName = null; + switch (Key) + { + case 1: + npcName = "刘备"; + Go(userName,npcName); + + break; + case 2: + npcName = "孙权"; + Go(userName, npcName); + break; + case 3: + npcName = "曹操"; + Go(userName, npcName); + break; + default: + Console.WriteLine("选择出错!请重新选择!!"); + Task1(); + break; + } + } + + private static void Go(string a,string b) + { + NPC nPC = new NPC(a,b); + User user = new User(a, b); + + Console.WriteLine($"{user.name} VS {nPC.name1} 对战"); + Console.WriteLine("开始游戏吗(y/n)"); + char key = char.Parse(Console.ReadLine()); + if (key==('y'|'Y')) + { + user.talk1(); + nPC.talk4(); + int f = (int)user.Fist(); + int i = (int)nPC.Fist(); + judge(f,i, nPC); + select(nPC, user); + } + else if (key == ('n' | 'N')) + { + Environment.Exit(0); + } + else + { + Console.WriteLine("选择出错!自动退出"); + Environment.Exit(0); + } + + } + + + private static void select(NPC nPC,User user) + { + Console.WriteLine("是否开始下一轮(y/n)"); + char key = char.Parse(Console.ReadLine()); + if (key == ('y' | 'Y')) + { + user.talk1(); + nPC.talk4(); + int f = (int)user.Fist(); + int i = (int)nPC.Fist(); + judge(f, i, nPC); + select(nPC,user); + } + else if (key == ('n' | 'N')) + { + Environment.Exit(0); + } + else + { + Console.WriteLine("选择出错!自动退出"); + Environment.Exit(0); + } + } + + + static void judge(int f,int i,NPC nPC) + { + if (i==f) + { + nPC.talk3(); + } + else if((f == 1 && i == 2) || (f == 2 && i ==3)|| (f == 3 && i == 1)) + { + nPC.talk1(); + } + else + { + nPC.talk2(); + } + } + + static void bool1() + { + + } + static string ListFist() + { + string fistString = null; + int i = 1; + foreach (Fist t in Enum.GetValues(typeof(Fist))) + { + fistString += $"{i}、{t} "; + i++; + } + return fistString; + } + + } +} diff --git "a/\351\255\217\346\265\267\350\215\243/User.cs" "b/\351\255\217\346\265\267\350\215\243/User.cs" new file mode 100644 index 0000000..c83e13a --- /dev/null +++ "b/\351\255\217\346\265\267\350\215\243/User.cs" @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp7 +{ + class User:Father + { + public User(string name, string name1) : base(name, name1) { } + public int key; + public void talk1() + { + Console.WriteLine("请出拳:{0}", ListFist()); + key = int.Parse(Console.ReadLine()); + Console.Write($"{name}: 出拳:"); + Console.WriteLine(Fist()); + } + public override fist Fist() + { + + fist f = (fist)key; + return f; + } + static string ListFist() + { + string fistString = null; + int i = 1; + foreach (fist t in Enum.GetValues(typeof(fist))) + { + fistString += $"{i}、{t} "; + i++; + } + return fistString; + } + } +} -- Gitee From 3b62ebd7cf34932061edb092298aec84737441d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=86=E7=91=BE=E8=A8=80?= <2220660532@qq.com> Date: Fri, 4 Jun 2021 20:12:27 +0800 Subject: [PATCH 20/74] =?UTF-8?q?=E6=AE=B5=E5=97=A3=E5=87=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\346\256\265\345\227\243\345\207\257/NPC.cs" | 25 ++++ .../Player.cs" | 23 ++++ .../Program.cs" | 124 ++++++++++++++++++ .../publicinfo.cs" | 23 ++++ 4 files changed, 195 insertions(+) create mode 100644 "\346\256\265\345\227\243\345\207\257/NPC.cs" create mode 100644 "\346\256\265\345\227\243\345\207\257/Player.cs" create mode 100644 "\346\256\265\345\227\243\345\207\257/Program.cs" create mode 100644 "\346\256\265\345\227\243\345\207\257/publicinfo.cs" diff --git "a/\346\256\265\345\227\243\345\207\257/NPC.cs" "b/\346\256\265\345\227\243\345\207\257/NPC.cs" new file mode 100644 index 0000000..fd6d985 --- /dev/null +++ "b/\346\256\265\345\227\243\345\207\257/NPC.cs" @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Giao +{ + class NPC : publicinfo + { + public NPC(string name) : base(name) + { + this.Name = name; + } + public override int fist() + { + Random r = new Random(); + int a = r.Next(3) + 1; + + return a; + } + + + } +} diff --git "a/\346\256\265\345\227\243\345\207\257/Player.cs" "b/\346\256\265\345\227\243\345\207\257/Player.cs" new file mode 100644 index 0000000..1edc82d --- /dev/null +++ "b/\346\256\265\345\227\243\345\207\257/Player.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Giao +{ + class Player : publicinfo + { + public Player(string name) : base(name) + { + this.Name = name; + } + public override int fist() + { + Console.WriteLine("请出拳:1、剪刀 2 、石头 3、 布 (请输入相应数字)"); + int choose2 = int.Parse(Console.ReadLine()); + return choose2; + + } + } +} diff --git "a/\346\256\265\345\227\243\345\207\257/Program.cs" "b/\346\256\265\345\227\243\345\207\257/Program.cs" new file mode 100644 index 0000000..24461dc --- /dev/null +++ "b/\346\256\265\345\227\243\345\207\257/Program.cs" @@ -0,0 +1,124 @@ + + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Giao +{ + enum npcname + { + 小阿giao = 1, + 稻市老八, + 冬泳怪鸽 + } + enum fist + { + 剪刀 = 1, + 石头, + 布 + } + class Program + { + static void Main(string[] args) + { + int pgroud = 0; + int ngroud = 0; + int session = 0; + against(ref pgroud, ref ngroud, ref session); + against2(ref pgroud, ref ngroud, ref session); + } + public static void against2(ref int pgroud, ref int ngroud, ref int session) + { + Console.WriteLine("要开始下一局吗?1、要 2、 不要"); + int choose3 = int.Parse(Console.ReadLine()); + switch (choose3) + { + case 1: + against(ref pgroud, ref ngroud, ref session); + against2(ref pgroud, ref ngroud, ref session); + break; + case 2: + Console.WriteLine("拜拜"); + break; + default: + Console.WriteLine("输入错误,重新开始"); + against(ref pgroud, ref ngroud, ref session); + break; + } + } + + + public static void against(ref int pgroud, ref int ngroud, ref int session) + { + Console.WriteLine("---------欢 迎 进 入 游 戏 世 界-----------"); + Console.WriteLine("**********************"); + Console.WriteLine("******猜拳,开始******"); + Console.WriteLine("**********************"); + Console.WriteLine("出拳规则:1.剪刀 2.布 3.石头"); + Console.WriteLine("请选择对方角色名:1.小阿giao 2.稻市老八 3.冬泳怪鸽"); + int choose1 = int.Parse(Console.ReadLine()); + npcname a = (npcname)choose1; + + Console.WriteLine("请输入你的名字"); + string play = Console.ReadLine(); + Player player = new Player(play); + game(ref a, ref pgroud, ref ngroud, ref session, ref player); + } + public static void game(ref npcname f, ref int pgroud, ref int ngroud, ref int session, ref Player player) + { + NPC npc = new NPC(f.ToString()); + int a = player.fist(); + fist playfist = (fist)a; + int b = npc.fist(); + fist npcfist = (fist)b; + Console.WriteLine("{0}出的拳为{1}", player.Name, playfist); + Console.WriteLine("{0}出的拳为{1}", npc.Name, npcfist); + string a1 = playfist.ToString(); + string a2 = npcfist.ToString(); + judge(a1, a2, ref pgroud, ref ngroud, ref session); + Console.WriteLine("是否开始下一轮 1、继续 2 、停止 "); + int choose = int.Parse(Console.ReadLine()); + switch (choose) + { + case 1: + game(ref f, ref pgroud, ref ngroud, ref session, ref player); + break; + case 2: + Console.WriteLine("{0}对阵{1}", player.Name, npc.Name); + Console.WriteLine("对阵次数{0}", session); + Console.WriteLine("姓名 得分"); + Console.WriteLine("{0} {1}", player.Name, pgroud); + Console.WriteLine("{0} {1}", npc.Name, ngroud); + break; + default: + Console.WriteLine("输入错误,重新开始"); + game(ref f, ref pgroud, ref ngroud, ref session, ref player); + break; + } + } + + public static void judge(string player, string npcfist, ref int pgroud, ref int ngroud, ref int session) + { + if (player.Equals("石头") && npcfist.Equals("剪刀") || player.Equals("剪刀") && npcfist.Equals("布") || player.Equals("布") && npcfist.Equals("石头")) + { + Console.WriteLine("你获得胜利"); + pgroud++; + session++; + } + else if (player.Equals(npcfist)) + { + Console.WriteLine("平局了"); + session++; + } + else + { + Console.WriteLine("你输了"); + ngroud++; + session++; + } + } + } +} diff --git "a/\346\256\265\345\227\243\345\207\257/publicinfo.cs" "b/\346\256\265\345\227\243\345\207\257/publicinfo.cs" new file mode 100644 index 0000000..efb2e35 --- /dev/null +++ "b/\346\256\265\345\227\243\345\207\257/publicinfo.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Giao +{ + class publicinfo + { + public string Name { get; set; } + + public publicinfo(string name) + { + Name = name; + } + public virtual int fist() + { + + return 0; + } + } +} -- Gitee From ed428b2ba67542f8b0413b22d4434b90ca81a43b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=86=E7=93=9Ca?= <1991416367@qq.com> Date: Fri, 4 Jun 2021 20:15:54 +0800 Subject: [PATCH 21/74] 2021.6.6 --- .../Father.cs" | 41 +++ .../Function.cs" | 257 ++++++++++++++++++ .../Gamelobby.cs" | 25 ++ .../Program.cs" | 20 ++ 4 files changed, 343 insertions(+) create mode 100644 "\345\210\230\346\226\207\345\274\272/Father.cs" create mode 100644 "\345\210\230\346\226\207\345\274\272/Function.cs" create mode 100644 "\345\210\230\346\226\207\345\274\272/Gamelobby.cs" create mode 100644 "\345\210\230\346\226\207\345\274\272/Program.cs" diff --git "a/\345\210\230\346\226\207\345\274\272/Father.cs" "b/\345\210\230\346\226\207\345\274\272/Father.cs" new file mode 100644 index 0000000..d22a4f7 --- /dev/null +++ "b/\345\210\230\346\226\207\345\274\272/Father.cs" @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + enum Sjb + { + 石头 = 1, + 剪刀, + 布 + } + enum name + { + 刘备=1, + 孙权, + 曹操 + } + + abstract class Father + { + + public string name { get; set; } + public string playname { get; set; } + public int function { get; set; } + public Father(string name,string playname) + { + this.playname = playname; + this.name = name; + } + public Father() + { + + } + + public abstract void hello(); + + } +} diff --git "a/\345\210\230\346\226\207\345\274\272/Function.cs" "b/\345\210\230\346\226\207\345\274\272/Function.cs" new file mode 100644 index 0000000..2a0c346 --- /dev/null +++ "b/\345\210\230\346\226\207\345\274\272/Function.cs" @@ -0,0 +1,257 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Function : Father + { + public Function(string name, string playname) : base(name, playname) + { + + } + public Function() + { + + } + public override void hello() + { + + Console.WriteLine("{0}", this.name); + } + public void gamego() + { + + int playname1 = 0; + int botname1 = 0; + int pj = 0; + + Console.WriteLine("请选择对方角色<1:刘备 2:孙权 3:曹操>"); + string name = Console.ReadLine(); + if (name.Equals("1")) + { + Function function = new Function("刘备",""); + function.hello(); + name = "刘备"; + + } + else if (name.Equals("2")) + { + Function function1 = new Function("孙权",""); + function1.hello(); + name = "孙权"; + } + else if (name.Equals("3")) + { + Function function2 = new Function("曹操",""); + function2.hello(); + name = "曹操"; + + } + Console.WriteLine("请输入您的姓名:"); + string playname = Console.ReadLine(); + Console.WriteLine("{0}vs{1} 对战",name, playname); + + Console.WriteLine("开始游戏吗?《y/n》"); + string game = Console.ReadLine(); + + if (game.Equals("y")) + { + + Console.WriteLine("请出拳:1.石头,2.剪刀,3.布(输入相应的数字)"); + int i = int.Parse(Console.ReadLine()); + if (i==1) + { + Console.WriteLine("{0}:出拳:{1}",playname,Sjb.石头); + Random random = new Random(); + int a = random.Next(1,4); + switch (a) + { + case 1: + Console.WriteLine("{0}:出拳:{1}", name, Sjb.石头); + break; + case 2: + Console.WriteLine("{0}:出拳:{1}", name, Sjb.剪刀); + break; + case 3: + Console.WriteLine("{0}:出拳:{1}", name, Sjb.布); + break; + default: + break; + } + if (a==3) + { + Console.WriteLine("霉蛋{0}输了",playname); + botname1++; + } + else if(a==1) + { + Console.WriteLine("平局"); + pj++; + } + else + { + Console.WriteLine("霉蛋{0}输了",name); + playname1++; + } + + + + } + else if (i==2) + { + Console.WriteLine("{0}:出拳:{1}", playname, Sjb.剪刀); + Random random = new Random(); + int a = random.Next(1, 4); + switch (a) + { + case 1: + Console.WriteLine("{0}:出拳:{1}", name, Sjb.石头); + break; + case 2: + Console.WriteLine("{0}:出拳:{1}", name, Sjb.剪刀); + break; + case 3: + Console.WriteLine("{0}:出拳:{1}", name, Sjb.布); + break; + default: + break; + } + if (a==1) + { + Console.WriteLine("霉蛋{0}输了", playname); + botname1++; + } + else if (a == 2) + { + Console.WriteLine("平局"); + pj++; + } + else + { + Console.WriteLine("霉蛋{0}输了", name); + playname1++; + } + pd2(); + + + + + } + else if (i==3) + { + Console.WriteLine("{0}:出拳:{1}", playname, Sjb.布); + Random random = new Random(); + int a = random.Next(1, 4); + switch (a) + { + case 1: + Console.WriteLine("{0}:出拳:{1}", name, Sjb.石头); + break; + case 2: + Console.WriteLine("{0}:出拳:{1}", name, Sjb.剪刀); + break; + case 3: + Console.WriteLine("{0}:出拳:{1}", name, Sjb.布); + break; + default: + break; + } + if (a==2) + { + Console.WriteLine("霉蛋{0}输了", playname); + botname1++; + } + else if (a == 3) + { + Console.WriteLine("平局"); + pj++; + } + else + { + Console.WriteLine("霉蛋{0}输了", name); + playname1++; + } + + } + pd2(); + int sum = botname1 + playname1 + pj; + function = sum; + Console.WriteLine("-----------------------------------"); + Console.WriteLine("{0}vs{1}", this.name, this.playname); + Console.WriteLine("对战次数:{0}", base.function); + Console.WriteLine(); + Console.WriteLine("姓名 得分"); + Console.Write("{0}+\t",playname); + Console.WriteLine("{0} ",playname1); + Console.Write("{0}+\t",name); + Console.WriteLine("{0} ", botname1); + + Console.WriteLine("结果"); + if (botname1 > playname1) + { + Console.WriteLine("{0}胜利了",name); + } + else if (botname1 < playname1) + { + Console.WriteLine("{0}胜利了", playname); + } + else + { + Console.WriteLine("平局"); + } + Console.WriteLine("要开始下一局吗?《y/n》"); + string game1 = Console.ReadLine(); + if (game1 == "y") + { + gamego(); + } + else if (game1 == "n") + { + System.Environment.Exit(0); + } + else + { + pd2(); + + } + } + else if (game.Equals("n")) + { + System.Environment.Exit(0); + } + else + { + gamego(); + + } + + } + public void pd2() + { + Console.WriteLine("是否开始下一轮《y/n》"); + string game = Console.ReadLine(); + if (game.Equals("y")) + { + gamego(); + } + else if(game.Equals("n")) + { + + } + else + { + pd2(); + } + } + public void pd1() + { + + + } + + + } +} diff --git "a/\345\210\230\346\226\207\345\274\272/Gamelobby.cs" "b/\345\210\230\346\226\207\345\274\272/Gamelobby.cs" new file mode 100644 index 0000000..bdd2343 --- /dev/null +++ "b/\345\210\230\346\226\207\345\274\272/Gamelobby.cs" @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Gamelobby : Father + { + public Gamelobby(string name, string playname) : base(name, playname) + { + } + + public override void hello() + { + Console.WriteLine("-------------欢迎进入游戏世界----------------"); + Console.WriteLine("******************"); + Console.WriteLine("****猜拳,开始****"); + Console.WriteLine("******************"); + Console.WriteLine("出拳规则:1.剪刀,2.石头,3.布"); + + } + } +} diff --git "a/\345\210\230\346\226\207\345\274\272/Program.cs" "b/\345\210\230\346\226\207\345\274\272/Program.cs" new file mode 100644 index 0000000..a1554b2 --- /dev/null +++ "b/\345\210\230\346\226\207\345\274\272/Program.cs" @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Program + { + static void Main(string[] args) + { + Gamelobby gamelobby = new Gamelobby("",""); + gamelobby.hello(); + Function function = new Function(); + function.gamego(); + } + + } +} -- Gitee From b6efaeb043ff1cb57d0530b3f9135ff823213f7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E9=9B=A8=E6=AC=A3?= <2523868292@qq.com> Date: Fri, 4 Jun 2021 20:27:13 +0800 Subject: [PATCH 22/74] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20?= =?UTF-8?q?=E7=BD=97=E9=9B=A8=E6=AC=A3/NPC.cs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\347\275\227\351\233\250\346\254\243/NPC.cs" | 22 ------------------- 1 file changed, 22 deletions(-) delete mode 100644 "\347\275\227\351\233\250\346\254\243/NPC.cs" diff --git "a/\347\275\227\351\233\250\346\254\243/NPC.cs" "b/\347\275\227\351\233\250\346\254\243/NPC.cs" deleted file mode 100644 index c5897a1..0000000 --- "a/\347\275\227\351\233\250\346\254\243/NPC.cs" +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConsoleApp1 -{ - class NPC - { - public string name1 { get; set; } - public NPC() { } - public NPC(string name1) - { - this.name1 = name1; - } - public string npcnpc() - { - return name1; - } - } -} -- Gitee From 6d2c73e8e31425f70b2e083f304eb25b152f3b26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E9=9B=A8=E6=AC=A3?= <2523868292@qq.com> Date: Fri, 4 Jun 2021 20:27:19 +0800 Subject: [PATCH 23/74] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20?= =?UTF-8?q?=E7=BD=97=E9=9B=A8=E6=AC=A3/Program.cs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Program.cs" | 72 ------------------- 1 file changed, 72 deletions(-) delete mode 100644 "\347\275\227\351\233\250\346\254\243/Program.cs" diff --git "a/\347\275\227\351\233\250\346\254\243/Program.cs" "b/\347\275\227\351\233\250\346\254\243/Program.cs" deleted file mode 100644 index 8bae07a..0000000 --- "a/\347\275\227\351\233\250\346\254\243/Program.cs" +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConsoleApp1 -{ - class Program - { - enum npc - { - 刘备=1, - 孙权, - 曹操 - } - enum gz - { - 石头=1, - 剪刀, - 布 - } - static void Main(string[] args) - { - begin(); - Console.ReadKey(); - } - static void begin() - { - Console.WriteLine("---------欢 迎 进 入 游 戏 世 界------------"); - Console.WriteLine("*************************************8"); - Console.WriteLine("*************猜 拳 开 始**************"); - Console.WriteLine("***************************************"); - Console.WriteLine("猜拳规则:1、剪刀,2、石头,3、布"); - Console.WriteLine("请选择对方角色:1、刘备,2、孙权,3、曹操"); - int a = int.Parse(Console.ReadLine()); - npc npc1 = (npc)a; - Console.WriteLine("输入你的名字"); - string b = Console.ReadLine(); - NPC npc11 = new NPC((npc1).ToString()); - Console.WriteLine(b + "VS" + npc11.npcnpc() + "对战"); - Console.WriteLine("开始游戏吗(y/n)"); - string key = Console.ReadLine(); - switch (key) - { - case "y": - Console.WriteLine("请出拳:1、剪刀,2、石头,3、布"); - int e = int.Parse(Console.ReadLine()); - gz cq1 = (gz)e; - Random r = new Random(); - int c = r.Next(3) + 1; - gz cq2 = (gz)c; - Console.WriteLine(b + ":出拳:" + cq1); - Console.WriteLine(npc11.npcnpc() + " :出拳:" + cq2); - cq cq = new cq(); - wan p1 = new wan(b); - cq.cp = ((gz)e).ToString(); - cq.cp1 = ((gz)c).ToString(); - cq.chuquan(); - begin(); - break; - case "n": - begin(); - break; - default: - Console.WriteLine("按都按歪来"); - begin(); - break; - } - } - } -} -- Gitee From dbb6cdb64e39c70000c3fb22ee1a25645a53e1f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E9=9B=A8=E6=AC=A3?= <2523868292@qq.com> Date: Fri, 4 Jun 2021 20:27:26 +0800 Subject: [PATCH 24/74] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20?= =?UTF-8?q?=E7=BD=97=E9=9B=A8=E6=AC=A3/cq.cs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\347\275\227\351\233\250\346\254\243/cq.cs" | 63 -------------------- 1 file changed, 63 deletions(-) delete mode 100644 "\347\275\227\351\233\250\346\254\243/cq.cs" diff --git "a/\347\275\227\351\233\250\346\254\243/cq.cs" "b/\347\275\227\351\233\250\346\254\243/cq.cs" deleted file mode 100644 index d95a081..0000000 --- "a/\347\275\227\351\233\250\346\254\243/cq.cs" +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConsoleApp1 -{ - class cq - { - public string cp { get; set; } - public string cp1 { get; set; } - - public void chuquan() - { - if (cp.Equals("剪刀")) - { - if (cp1.Equals("剪刀")) - { - Console.WriteLine("和局,真衰"); - } - if (cp1.Equals("石头")) - { - Console.WriteLine("笨蛋,你真菜"); - } - if (cp1.Equals("布")) - { - Console.WriteLine("玩的不错"); - } - } - if (cp.Equals("石头")) - { - if (cp1.Equals("剪刀")) - { - Console.WriteLine("玩的不错"); - } - if (cp1.Equals("石头")) - { - Console.WriteLine("和局,真衰!"); - } - if (cp1.Equals("布")) - { - Console.WriteLine("笨蛋,你真菜"); - } - } - if (cp.Equals("布")) - { - if (cp1.Equals("剪刀")) - { - Console.WriteLine("笨蛋,你真菜"); - } - if (cp1.Equals("石头")) - { - Console.WriteLine("玩的不错"); - } - if (cp1.Equals("布")) - { - Console.WriteLine("和局,真衰"); - } - } - } - } -} -- Gitee From ae34b42fcbba0acbe1d4c15a008c000ef9664d2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E9=9B=A8=E6=AC=A3?= <2523868292@qq.com> Date: Fri, 4 Jun 2021 20:27:33 +0800 Subject: [PATCH 25/74] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20?= =?UTF-8?q?=E7=BD=97=E9=9B=A8=E6=AC=A3/wan.cs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\347\275\227\351\233\250\346\254\243/wan.cs" | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 "\347\275\227\351\233\250\346\254\243/wan.cs" diff --git "a/\347\275\227\351\233\250\346\254\243/wan.cs" "b/\347\275\227\351\233\250\346\254\243/wan.cs" deleted file mode 100644 index 5fa4849..0000000 --- "a/\347\275\227\351\233\250\346\254\243/wan.cs" +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConsoleApp1 -{ - class wan - { - public string name { get; set; } - public wan() { } - public wan(string name) - { - this.name = name; - } - } -} -- Gitee From 352ffde6706fd97fb1f1a514fa0f113544477e44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E9=9B=A8=E6=AC=A3?= <2523868292@qq.com> Date: Fri, 4 Jun 2021 20:28:28 +0800 Subject: [PATCH 26/74] =?UTF-8?q?=E7=BD=97=E9=9B=A8=E6=AC=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\347\275\227\351\233\250\346\254\243/NPC.cs" | 25 ++++ .../Program.cs" | 123 ++++++++++++++++++ .../Publicinfo.cs" | 23 ++++ .../player.cs" | 24 ++++ 4 files changed, 195 insertions(+) create mode 100644 "\347\275\227\351\233\250\346\254\243/NPC.cs" create mode 100644 "\347\275\227\351\233\250\346\254\243/Program.cs" create mode 100644 "\347\275\227\351\233\250\346\254\243/Publicinfo.cs" create mode 100644 "\347\275\227\351\233\250\346\254\243/player.cs" diff --git "a/\347\275\227\351\233\250\346\254\243/NPC.cs" "b/\347\275\227\351\233\250\346\254\243/NPC.cs" new file mode 100644 index 0000000..98684c7 --- /dev/null +++ "b/\347\275\227\351\233\250\346\254\243/NPC.cs" @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class NPC : Publicinfo + { + public NPC(string name) : base(name) + { + this.Name = name; + } + public override int fist() + { + Random r = new Random(); + int a = r.Next(3) + 1; + + return a; + } + + + } +} \ No newline at end of file diff --git "a/\347\275\227\351\233\250\346\254\243/Program.cs" "b/\347\275\227\351\233\250\346\254\243/Program.cs" new file mode 100644 index 0000000..bf24655 --- /dev/null +++ "b/\347\275\227\351\233\250\346\254\243/Program.cs" @@ -0,0 +1,123 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + enum npcname + { + 刘备 = 1, + 孙权, + 曹操 + } + enum fist + { + 剪刀 = 1, + 石头, + 布 + } + class Program + { + + static void Main(string[] args) + { + int pgroud = 0; + int ngroud = 0; + int session = 0; + against(ref pgroud, ref ngroud, ref session); + against2(ref pgroud, ref ngroud, ref session); + } + public static void against2(ref int pgroud, ref int ngroud, ref int session) + { + Console.WriteLine("要开始下一局吗?1、要 2、 不要"); + int choose3 = int.Parse(Console.ReadLine()); + switch (choose3) + { + case 1: + against(ref pgroud, ref ngroud, ref session); + against2(ref pgroud, ref ngroud, ref session); + break; + case 2: + Console.WriteLine("拜了个拜"); + break; + default: + Console.WriteLine("输入错误,重新开始"); + against(ref pgroud, ref ngroud, ref session); + break; + } + } + public static void against(ref int pgroud, ref int ngroud, ref int session) + { + Console.WriteLine("----游戏即将开始----"); + Console.WriteLine("--------------------"); + Console.WriteLine("-----猜拳·开始-----"); + Console.WriteLine("--------------------"); + Console.WriteLine("出拳规则:1、剪刀 2、 石头 3、 布"); + Console.WriteLine("请选择对方角色:1、刘备 2 、孙权 3、 曹操 (请输入相应数字)"); + int choose1 = int.Parse(Console.ReadLine()); + npcname f = (npcname)choose1; + + Console.WriteLine("请输入您的名字"); + string play = Console.ReadLine(); + player player = new player(play); + game(ref f, ref pgroud, ref ngroud, ref session, ref player); + + } + + public static void game(ref npcname f, ref int pgroud, ref int ngroud, ref int session, ref player player) + { + NPC npc = new NPC(f.ToString()); + int a = player.fist(); + fist playfist = (fist)a; + int b = npc.fist(); + fist npcfist = (fist)b; + Console.WriteLine("{0}出的拳为{1}", player.Name, playfist); + Console.WriteLine("{0}出的拳为{1}", npc.Name, npcfist); + string a1 = playfist.ToString(); + string a2 = npcfist.ToString(); + judge(a1, a2, ref pgroud, ref ngroud, ref session); + Console.WriteLine("是否开始下一轮 1、继续 2 、停止 "); + int choose = int.Parse(Console.ReadLine()); + switch (choose) + { + case 1: + game(ref f, ref pgroud, ref ngroud, ref session, ref player); + break; + case 2: + Console.WriteLine("{0}对阵{1}", player.Name, npc.Name); + Console.WriteLine("对阵次数{0}", session); + Console.WriteLine("姓名 得分"); + Console.WriteLine("{0} {1}", player.Name, pgroud); + Console.WriteLine("{0} {1}", npc.Name, ngroud); + break; + default: + Console.WriteLine("输入错误,重新开始"); + game(ref f, ref pgroud, ref ngroud, ref session, ref player); + break; + } + } + + public static void judge(string player, string npcfist, ref int pgroud, ref int ngroud, ref int session) + { + if (player.Equals("石头") && npcfist.Equals("剪刀") || player.Equals("剪刀") && npcfist.Equals("布") || player.Equals("布") && npcfist.Equals("石头")) + { + Console.WriteLine("你获得胜利"); + pgroud++; + session++; + } + else if (player.Equals(npcfist)) + { + Console.WriteLine("平局了"); + session++; + } + else + { + Console.WriteLine("你输了"); + ngroud++; + session++; + } + } + } +} \ No newline at end of file diff --git "a/\347\275\227\351\233\250\346\254\243/Publicinfo.cs" "b/\347\275\227\351\233\250\346\254\243/Publicinfo.cs" new file mode 100644 index 0000000..389514e --- /dev/null +++ "b/\347\275\227\351\233\250\346\254\243/Publicinfo.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Publicinfo + { + public string Name { get; set; } + + public Publicinfo(string name) + { + Name = name; + } + public virtual int fist() + { + return 0; + } + + } +} \ No newline at end of file diff --git "a/\347\275\227\351\233\250\346\254\243/player.cs" "b/\347\275\227\351\233\250\346\254\243/player.cs" new file mode 100644 index 0000000..e2291b2 --- /dev/null +++ "b/\347\275\227\351\233\250\346\254\243/player.cs" @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class player : Publicinfo + { + public player(string name) : base(name) + { + this.Name = name; + } + public override int fist() + { + Console.WriteLine("请出拳:1、剪刀 2 、石头 3、 布 (请输入相应数字)"); + int choose2 = int.Parse(Console.ReadLine()); + return choose2; + } + + + } +} \ No newline at end of file -- Gitee From 554e8abf6355c04c8dc840b951537f74160193a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E9=82=B5=E6=98=A0?= <2934277968@qq.com> Date: Sat, 5 Jun 2021 12:25:19 +0800 Subject: [PATCH 27/74] =?UTF-8?q?=E6=96=B0=E5=BB=BA=20=E9=83=91=E9=82=B5?= =?UTF-8?q?=E6=98=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\351\203\221\351\202\265\346\230\240/.keep" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "\351\203\221\351\202\265\346\230\240/.keep" diff --git "a/\351\203\221\351\202\265\346\230\240/.keep" "b/\351\203\221\351\202\265\346\230\240/.keep" new file mode 100644 index 0000000..e69de29 -- Gitee From c88c95003c34f6fdc4846c5f24b653151b02f5fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E9=82=B5=E6=98=A0?= <2934277968@qq.com> Date: Sat, 5 Jun 2021 12:25:47 +0800 Subject: [PATCH 28/74] 1 --- .../Person.cs" | 59 ++++ .../Program.cs" | 260 ++++++++++++++++++ 2 files changed, 319 insertions(+) create mode 100644 "\351\203\221\351\202\265\346\230\240/Person.cs" create mode 100644 "\351\203\221\351\202\265\346\230\240/Program.cs" diff --git "a/\351\203\221\351\202\265\346\230\240/Person.cs" "b/\351\203\221\351\202\265\346\230\240/Person.cs" new file mode 100644 index 0000000..4ae9336 --- /dev/null +++ "b/\351\203\221\351\202\265\346\230\240/Person.cs" @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp7 +{ + class Person + { + public string Name { get; set; } + + public Person(string name) + { + this.Name = name; + + } + public virtual int Hello() + { + + return 0; + } + } + class Myself : Person + { + public Myself(string name) : base(name) + { + } + public override int Hello() + { + Console.WriteLine("请出拳:1、剪刀 2 、石头 3、 布 (请输入相应数字)"); + int chose = int.Parse(Console.ReadLine()); + return chose; + + } + } + class Liubei : Person + { + + public Liubei(string name) : base(name) + { + + } + public override int Hello() + { + Random ra = new Random(); + int a = ra.Next(3) + 1; + Fist fist = (Fist)a; + Console.WriteLine("{0} 出拳:" + fist, this.Name); + return a; + + } + + } + +} + + + diff --git "a/\351\203\221\351\202\265\346\230\240/Program.cs" "b/\351\203\221\351\202\265\346\230\240/Program.cs" new file mode 100644 index 0000000..2f24dc4 --- /dev/null +++ "b/\351\203\221\351\202\265\346\230\240/Program.cs" @@ -0,0 +1,260 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp7 +{ + public enum Fist + { + 石头=1, + 剪刀=2, + 布=3 + } + public enum Man + { + 刘备 = 1, + 孙权 = 2, + 曹操 = 3 + } + class Program + { + static string name; + public static int a; + static string name1; + static int ping = 0; + static int ying = 0; + static int shu = 0; + static int ci = 0; + + static void Main(string[] args) + { + + Console.WriteLine("---------------------欢迎进入游戏世界--------------------------"); + Console.WriteLine(); + Console.WriteLine("*********************************"); + Console.WriteLine("************猜拳 开始************"); + Console.WriteLine("*********************************"); + kaishi(); + + + } + static public void kaishi() + { + Console.WriteLine("出拳规则:1、石头 2、剪刀 3、布"); + Console.WriteLine("请选择对方角色: 1、刘备 2、孙权 3、曹操"); + int key = int.Parse(Console.ReadLine()); + Console.WriteLine("请输入您的姓名:"); + name1 = Console.ReadLine(); + Myself my = new Myself(name1); + switch (key) + { + case 1: + name = "刘备"; + Console.WriteLine(name1 + "vs" + name + "对战"); + Console.WriteLine("开始游戏吗"); + Console.WriteLine("请选择1、开始游戏 2、退出"); + Panduan(); + + break; + case 2: + name = "孙权"; + Console.WriteLine(name1 + "vs" + name + "对战"); + Console.WriteLine("开始游戏吗"); + Console.WriteLine("请选择1、开始游戏 2、退出"); + Panduan(); + break; + case 3: + name = "曹操"; + Console.WriteLine(name1 + "vs" + name + "对战"); + Console.WriteLine("开始游戏吗"); + Console.WriteLine("请选择1、开始游戏 2、退出"); + Panduan(); + break; + default: + break; + } + } + static public void Panduan() + { + + + int key1 = int.Parse(Console.ReadLine()); + switch (key1) + { + case 1: + Fist stou = Fist.石头; + int num = 1; + Fist f = (Fist)num; + Fist jiandao = Fist.剪刀; + int num1 = 2; + Fist f1 = (Fist)num1; + Fist bu = Fist.布; + int num2 = 3; + Fist f2 = (Fist)num2; + Console.WriteLine("请出拳:{0}", ListFist()); + + int key2 = int.Parse(Console.ReadLine()); + if (key2 == 1) + { + Console.WriteLine(name1 + ":" + "出拳:" + f); + ListFist(); + Liubei liu = new Liubei(name); + Random ra = new Random(); + int a = ra.Next(3) + 1; + Fist fist = (Fist)a; + Console.WriteLine(name + ":出拳:" + fist); + + + if (a == 1) + { + Console.WriteLine("平局"); + ping = ping + 1; + } + else if (a == 2) + { + Console.WriteLine(name1 + "你赢了"); + ying = ying+1; + } + else + { + Console.WriteLine(name1 + "你输了"); + shu = shu + 1; + } + ci = ci + 1; + + } + else if (key2 == 2) + { + Console.WriteLine(name1 + ":" + "出拳:" + f1); + ListFist(); + Liubei liu = new Liubei(name); + Random ra = new Random(); + int a = ra.Next(3) + 1; + Fist fist = (Fist)a; + Console.WriteLine(name+":出拳:" + fist); + if (a == 1) + { + Console.WriteLine(name1 + "你输了"); + shu = shu + 1; + } + else if (a == 2) + { + Console.WriteLine("平局"); + ping = ping + 1; + } + else + { + Console.WriteLine(name1 + "你赢了"); + ying = ying + 1; + } + ci = ci + 1; + } + else if (key2 == 3) + { + Console.WriteLine(name + ":" + "出拳:" + f2); + ListFist(); + Liubei liu = new Liubei(name); + Random ra = new Random(); + int a = ra.Next(3) + 1; + Fist fist = (Fist)a; + Console.WriteLine(name1+":出拳:" + fist); + if (a == 1) + { + Console.WriteLine(name1 + "你赢了"); + ying = ying + 1; + } + else if (a == 2) + { + Console.WriteLine(name1 + "你输了"); + shu = shu + 1; + } + else + { + Console.WriteLine("平局"); + ping = ping + 1; + } + ci = ci + 1; + } + else + { + Console.WriteLine("输入错误"); + + } + Console.WriteLine("是否进行下一轮"); + Console.WriteLine("请选择1、是 2否"); + int key3 = int.Parse(Console.ReadLine()); + switch (key3) + { + case 1: + Console.WriteLine("请选择1、开始游戏 2、返回上一级"); + Panduan(); + break; + case 2: + jieguo(); + break; + default: + break; + } + break; + case 2: + Console.WriteLine("退出成功!"); + break; + default: + break; + } + } + + public static string ListFist() + { + string FistString = ""; + int i = 1; + foreach (Fist item in Enum.GetValues(typeof(Fist))) + { + FistString += i + "、" + item + ";"; + i++; + } + return FistString; + + } + public static void jieguo() + { + Console.WriteLine("**********************************************"); + Console.WriteLine(name+"vs"+name1); + Console.WriteLine("共对局"+ci); + Console.WriteLine("平局"+ping); + Console.WriteLine(name1+"得分"+ying); + Console.WriteLine(name + "得分" + shu); + if (ying>shu) + { + Console.WriteLine("笨蛋"+name+"你输了"); + } + else + { + Console.WriteLine("笨蛋" + name1+ "你输了"); + } + Console.WriteLine("是否进行下一局"); + Console.WriteLine("请选择1、是 2否"); + ping = 0; + ying = 0; + shu = 0; + ci = 0; + + int key= int.Parse(Console.ReadLine()); + switch (key) + { + case 1: + kaishi(); + break; + case 2: + Console.WriteLine("拜拜哦"); + break; + default: + break; + } + } + } + } + + -- Gitee From f0d73ee12057c83e13603a5923afb600ae0f08cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=BC=E7=9D=80=E5=A5=B6=E7=93=B6=E5=8E=BB=E6=89=93?= =?UTF-8?q?=E8=99=8E?= <1348328020@qq.com> Date: Sat, 5 Jun 2021 15:11:48 +0800 Subject: [PATCH 29/74] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20?= =?UTF-8?q?=E9=AD=8F=E6=B5=B7=E8=8D=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Father.cs" | 31 ---- "\351\255\217\346\265\267\350\215\243/NPC.cs" | 41 ----- .../Program.cs" | 147 ------------------ .../User.cs" | 38 ----- 4 files changed, 257 deletions(-) delete mode 100644 "\351\255\217\346\265\267\350\215\243/Father.cs" delete mode 100644 "\351\255\217\346\265\267\350\215\243/NPC.cs" delete mode 100644 "\351\255\217\346\265\267\350\215\243/Program.cs" delete mode 100644 "\351\255\217\346\265\267\350\215\243/User.cs" diff --git "a/\351\255\217\346\265\267\350\215\243/Father.cs" "b/\351\255\217\346\265\267\350\215\243/Father.cs" deleted file mode 100644 index d9385fb..0000000 --- "a/\351\255\217\346\265\267\350\215\243/Father.cs" +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConsoleApp7 -{ - class Father - { - public enum fist - { - 石头 = 1, - 剪刀, - 布 - } - public string name { get; set; } - public string name1 { get; set; } - - public Father(string name, string name1) - { - this.name = name; - this.name1 = name1; - } - public virtual fist Fist() - { - fist fist = fist.剪刀; - return fist; - } - } -} diff --git "a/\351\255\217\346\265\267\350\215\243/NPC.cs" "b/\351\255\217\346\265\267\350\215\243/NPC.cs" deleted file mode 100644 index f67519b..0000000 --- "a/\351\255\217\346\265\267\350\215\243/NPC.cs" +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConsoleApp7 -{ - - class NPC:Father - { - - public NPC(string name, string name1):base(name,name1){ } - - public void talk1() - { - Console.WriteLine($"恭喜!{name}赢了!"); - } - - public void talk2() - { - Console.WriteLine($"太拉了!{name}输了!"); - } - public void talk3() - { - Console.WriteLine("和局,真衰!嘿嘿等着瞧吧!"); - } - public void talk4() - { - Console.Write($"{name1}: 出拳:"); - Console.WriteLine(Fist()); - } - public override fist Fist() - { - Random red = new Random(); - int key = red.Next(1, 4); - fist f = (fist)key; - return f; - } - } -} diff --git "a/\351\255\217\346\265\267\350\215\243/Program.cs" "b/\351\255\217\346\265\267\350\215\243/Program.cs" deleted file mode 100644 index 9092938..0000000 --- "a/\351\255\217\346\265\267\350\215\243/Program.cs" +++ /dev/null @@ -1,147 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConsoleApp7 -{ - - class Program - { - enum Fist - { - 石头 = 1, - 剪刀, - 布 - } - static string userName; - static void Main(string[] args) - { - Console.WriteLine("------------欢 迎 进 入 游 戏 世 界------------"); - Console.WriteLine(); - Console.WriteLine("************************"); - Console.WriteLine("*******猜拳·开始*******"); - Console.WriteLine("************************"); - Console.WriteLine("出拳规则:{0}", ListFist()); - Task1(); - } - - public static void Task1() - { - Console.WriteLine("请选择对方角色(1:刘备 2:孙权 3:曹操)"); - int Key = int.Parse(Console.ReadLine()); - Console.Write("请输入您的姓名:"); - userName = Console.ReadLine(); - string npcName = null; - switch (Key) - { - case 1: - npcName = "刘备"; - Go(userName,npcName); - - break; - case 2: - npcName = "孙权"; - Go(userName, npcName); - break; - case 3: - npcName = "曹操"; - Go(userName, npcName); - break; - default: - Console.WriteLine("选择出错!请重新选择!!"); - Task1(); - break; - } - } - - private static void Go(string a,string b) - { - NPC nPC = new NPC(a,b); - User user = new User(a, b); - - Console.WriteLine($"{user.name} VS {nPC.name1} 对战"); - Console.WriteLine("开始游戏吗(y/n)"); - char key = char.Parse(Console.ReadLine()); - if (key==('y'|'Y')) - { - user.talk1(); - nPC.talk4(); - int f = (int)user.Fist(); - int i = (int)nPC.Fist(); - judge(f,i, nPC); - select(nPC, user); - } - else if (key == ('n' | 'N')) - { - Environment.Exit(0); - } - else - { - Console.WriteLine("选择出错!自动退出"); - Environment.Exit(0); - } - - } - - - private static void select(NPC nPC,User user) - { - Console.WriteLine("是否开始下一轮(y/n)"); - char key = char.Parse(Console.ReadLine()); - if (key == ('y' | 'Y')) - { - user.talk1(); - nPC.talk4(); - int f = (int)user.Fist(); - int i = (int)nPC.Fist(); - judge(f, i, nPC); - select(nPC,user); - } - else if (key == ('n' | 'N')) - { - Environment.Exit(0); - } - else - { - Console.WriteLine("选择出错!自动退出"); - Environment.Exit(0); - } - } - - - static void judge(int f,int i,NPC nPC) - { - if (i==f) - { - nPC.talk3(); - } - else if((f == 1 && i == 2) || (f == 2 && i ==3)|| (f == 3 && i == 1)) - { - nPC.talk1(); - } - else - { - nPC.talk2(); - } - } - - static void bool1() - { - - } - static string ListFist() - { - string fistString = null; - int i = 1; - foreach (Fist t in Enum.GetValues(typeof(Fist))) - { - fistString += $"{i}、{t} "; - i++; - } - return fistString; - } - - } -} diff --git "a/\351\255\217\346\265\267\350\215\243/User.cs" "b/\351\255\217\346\265\267\350\215\243/User.cs" deleted file mode 100644 index c83e13a..0000000 --- "a/\351\255\217\346\265\267\350\215\243/User.cs" +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConsoleApp7 -{ - class User:Father - { - public User(string name, string name1) : base(name, name1) { } - public int key; - public void talk1() - { - Console.WriteLine("请出拳:{0}", ListFist()); - key = int.Parse(Console.ReadLine()); - Console.Write($"{name}: 出拳:"); - Console.WriteLine(Fist()); - } - public override fist Fist() - { - - fist f = (fist)key; - return f; - } - static string ListFist() - { - string fistString = null; - int i = 1; - foreach (fist t in Enum.GetValues(typeof(fist))) - { - fistString += $"{i}、{t} "; - i++; - } - return fistString; - } - } -} -- Gitee From e0e25a250d5994bc1bf2a44d02b7cdec1e9bb243 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=BC=E7=9D=80=E5=A5=B6=E7=93=B6=E5=8E=BB=E6=89=93?= =?UTF-8?q?=E8=99=8E?= <1348328020@qq.com> Date: Sat, 5 Jun 2021 15:41:15 +0800 Subject: [PATCH 30/74] =?UTF-8?q?=E7=8C=9C=E6=8B=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Father.cs" | 31 +++ "\351\255\217\346\265\267\350\215\243/NPC.cs" | 41 ++++ .../Program.cs" | 192 ++++++++++++++++++ .../User.cs" | 38 ++++ 4 files changed, 302 insertions(+) create mode 100644 "\351\255\217\346\265\267\350\215\243/Father.cs" create mode 100644 "\351\255\217\346\265\267\350\215\243/NPC.cs" create mode 100644 "\351\255\217\346\265\267\350\215\243/Program.cs" create mode 100644 "\351\255\217\346\265\267\350\215\243/User.cs" diff --git "a/\351\255\217\346\265\267\350\215\243/Father.cs" "b/\351\255\217\346\265\267\350\215\243/Father.cs" new file mode 100644 index 0000000..3d52d7a --- /dev/null +++ "b/\351\255\217\346\265\267\350\215\243/Father.cs" @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp3 +{ + class Father + { + public enum fist + { + 石头 = 1, + 剪刀, + 布 + } + public string name { get; set; } + public string name1 { get; set; } + + public Father(string name, string name1) + { + this.name = name; + this.name1 = name1; + } + public virtual fist Fist() + { + fist fist = fist.剪刀; + return fist; + } + } +} diff --git "a/\351\255\217\346\265\267\350\215\243/NPC.cs" "b/\351\255\217\346\265\267\350\215\243/NPC.cs" new file mode 100644 index 0000000..0609453 --- /dev/null +++ "b/\351\255\217\346\265\267\350\215\243/NPC.cs" @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp3 +{ + + class NPC:Father + { + + public NPC(string name, string name1):base(name,name1){ } + + public void talk1() + { + Console.WriteLine($"恭喜!{name}赢了!"); + } + + public void talk2() + { + Console.WriteLine($"太拉了!{name}输了!"); + } + public void talk3() + { + Console.WriteLine("和局,真衰!嘿嘿等着瞧吧!"); + } + public void talk4() + { + Console.Write($"{name1}: 出拳:"); + Console.WriteLine(Fist()); + } + public override fist Fist() + { + Random red = new Random(); + int key = red.Next(1, 4); + fist f = (fist)key; + return f; + } + } +} diff --git "a/\351\255\217\346\265\267\350\215\243/Program.cs" "b/\351\255\217\346\265\267\350\215\243/Program.cs" new file mode 100644 index 0000000..a57d39c --- /dev/null +++ "b/\351\255\217\346\265\267\350\215\243/Program.cs" @@ -0,0 +1,192 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp3 +{ + + class Program + { + enum Fist + { + 石头 = 1, + 剪刀, + 布 + } + static string userName; + static int x = 0; + static int y = 0; + static int j = 0; + static int sum =0; + static void Main(string[] args) + { + Console.WriteLine("------------欢 迎 进 入 游 戏 世 界------------"); + Console.WriteLine(); + Console.WriteLine("************************"); + Console.WriteLine("*******猜拳·开始*******"); + Console.WriteLine("************************"); + Console.WriteLine("出拳规则:{0}", ListFist()); + Task1(); + } + + public static void Task1() + { + x = 0;y = 0;j = 0;sum = 0; + Console.WriteLine("请选择对方角色(1:刘备 2:孙权 3:曹操)"); + int Key = int.Parse(Console.ReadLine()); + Console.Write("请输入您的姓名:"); + userName = Console.ReadLine(); + string npcName = null; + switch (Key) + { + case 1: + npcName = "刘备"; + Go(userName, npcName); + + break; + case 2: + npcName = "孙权"; + Go(userName, npcName); + break; + case 3: + npcName = "曹操"; + Go(userName, npcName); + break; + default: + Console.WriteLine("选择出错!请重新选择!!"); + Task1(); + break; + } + } + + private static void Go(string a, string b) + { + NPC nPC = new NPC(a, b); + User user = new User(a, b); + + Console.WriteLine($"{user.name} VS {nPC.name1} 对战"); + Console.WriteLine("开始游戏吗(y/n)"); + char key = char.Parse(Console.ReadLine()); + if (key == ('y' | 'Y')) + { + user.talk1(); + nPC.talk4(); + int f = (int)user.Fist(); + int i = (int)nPC.Fist(); + judge(f, i, nPC); + select(nPC, user); + } + else if (key == ('n' | 'N')) + { + pan(nPC, user); + Environment.Exit(0); + + } + else + { + pan(nPC, user); + Console.WriteLine("选择出错!自动退出"); + Environment.Exit(0); + } + + } + + + private static void select(NPC nPC, User user) + { + Console.WriteLine("是否开始下一轮(y/n)"); + char key = char.Parse(Console.ReadLine()); + if (key == ('y' | 'Y')) + { + user.talk1(); + nPC.talk4(); + int f = (int)user.Fist(); + int i = (int)nPC.Fist(); + judge(f, i, nPC); + select(nPC, user); + } + else if (key == ('n' | 'N')) + { + pan(nPC, user); + Environment.Exit(0); + } + else + { + Console.WriteLine("选择出错!自动退出"); + Environment.Exit(0); + } + } + + static void pan(NPC nPC, User user) + { + Console.WriteLine("\n\n======================================="); + Console.WriteLine($"{user.name} VS {nPC.name1}"); + Console.WriteLine("对战次数:{0}\n",sum = x + y + j); + Console.WriteLine("姓名 得分"); + Console.WriteLine($"{user.name} {y}"); + Console.WriteLine($"{nPC.name1} {j}"); + Console.Write("结果:"); + if (y > j) + { + Console.WriteLine($"{user.name}赢,{nPC.name1}输。"); + } + else if (y==j) + { + Console.WriteLine("平局"); + } + else + { + Console.WriteLine($"{nPC.name1}赢,{user.name}输。"); + } + Console.WriteLine("是否开始下一局(y/n)"); + char key = char.Parse(Console.ReadLine()); + if (key == ('y' | 'Y')) + { + Task1(); + } + else if (key == ('n' | 'N')) + { + Environment.Exit(0); + } + else + { + Console.WriteLine("选择出错!自动退出"); + Environment.Exit(0); + } + + } + static void judge(int f,int i,NPC nPC) + { + if (i==f) + { + x = x+1; + nPC.talk3(); + } + else if((f == 1 && i == 2) || (f == 2 && i ==3)|| (f == 3 && i == 1)) + { + y = y +1; + nPC.talk1(); + } + else + { + j = j + 1; + nPC.talk2(); + } + } + + static string ListFist() + { + string fistString = null; + int i = 1; + foreach (Fist t in Enum.GetValues(typeof(Fist))) + { + fistString += $"{i}、{t} "; + i++; + } + return fistString; + } + + } +} diff --git "a/\351\255\217\346\265\267\350\215\243/User.cs" "b/\351\255\217\346\265\267\350\215\243/User.cs" new file mode 100644 index 0000000..6defc2b --- /dev/null +++ "b/\351\255\217\346\265\267\350\215\243/User.cs" @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp3 +{ + class User:Father + { + public User(string name, string name1) : base(name, name1) { } + public int key; + public void talk1() + { + Console.WriteLine("请出拳:{0}", ListFist()); + key = int.Parse(Console.ReadLine()); + Console.Write($"{name}: 出拳:"); + Console.WriteLine(Fist()); + } + public override fist Fist() + { + + fist f = (fist)key; + return f; + } + static string ListFist() + { + string fistString = null; + int i = 1; + foreach (fist t in Enum.GetValues(typeof(fist))) + { + fistString += $"{i}、{t} "; + i++; + } + return fistString; + } + } +} -- Gitee From 253e73506408a88eef67bf72583554bb85173080 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=BF=E6=A3=AE?= <2287431003@qq.com> Date: Sat, 5 Jun 2021 16:18:25 +0800 Subject: [PATCH 31/74] C# --- "\346\273\225\351\221\253/Program.cs" | 245 ++++++++++++++++++++++++++ 1 file changed, 245 insertions(+) create mode 100644 "\346\273\225\351\221\253/Program.cs" diff --git "a/\346\273\225\351\221\253/Program.cs" "b/\346\273\225\351\221\253/Program.cs" new file mode 100644 index 0000000..fa98e5a --- /dev/null +++ "b/\346\273\225\351\221\253/Program.cs" @@ -0,0 +1,245 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Hero + { + private string name; + public string Name + { + get { return this.name; } + set { this.name = value; } + } + public Hero(string Name) + { + this.name = Name; + } + public Hero() + { + + } + } + enum Fist + { + 石头 = 1, + 剪刀, + 布 + } + enum Yx + { + 刘备 = 1, + 孙权, + 曹操 + } + + class Program + { + //玩家姓名 + static string xm; + //对手姓名 + static Yx name; + //实例化随机数 + static Random sz = new Random(); + //计算分数 + static int playersum = 0, robotsum = 0, gamesum = 0; + static void Main(string[] args) + { + Console.WriteLine("---------------欢迎进入游戏世界---------------"); + Console.WriteLine(); + Console.WriteLine("*************************************"); + Console.WriteLine("**********猜拳··开始!!!*********"); + Console.WriteLine("*************************************"); + Console.WriteLine("出拳规则:1.剪刀2.石头3.布"); + pk(); + Console.ReadKey(); + } + static string listfist() + { + string fiststring = ""; + int i = 1; + foreach (Fist f in Enum.GetValues(typeof(Fist))) + { + fiststring += i + "、" + f + ";"; + i++; + } + return fiststring; + } + static string listyx() + { + string yxstring = ""; + int i = 1; + foreach (Yx f in Enum.GetValues(typeof(Yx))) + { + yxstring += i + "、" + f + ";"; + i++; + } + return yxstring; + } + static void pk() + { + Console.WriteLine("请选择对方角色{0}", listyx()); + int jx = int.Parse(Console.ReadLine()); + name = (Yx)jx; + Console.WriteLine("请输入你的姓名:"); + xm = Console.ReadLine(); + Console.WriteLine("{0} vs {1} 对战!", xm, name); + Console.WriteLine("开始游戏吗?(y/n)"); + string begin = Console.ReadLine(); + if (begin == "y") + { + confrontation(); + } + else if (begin == "n") + { + end(); + } + } + static void confrontation() + { + Console.WriteLine("请出拳:{0}(输入相应数字:)", listfist()); + int guess = int.Parse(Console.ReadLine()); + //我方出拳 + Fist fname = (Fist)guess; + //对手出拳 + int cq = sz.Next(1, 4); + Fist q = (Fist)cq; + int qq = (int)q; + switch (guess) + { + case 1: + Console.WriteLine("{0}:出拳:{1}", xm, fname); + Console.WriteLine("{0}:出拳:{1}", name, q); + if (qq.Equals(3)) + { + Console.WriteLine("{0}输了,不要害怕失败大不了从头来过!",xm); + robotsum++; + gamesum++; + } + else if (fname.Equals(q)) + { + Console.WriteLine("和局,真倒霉!你个王八犊子等着瞧!"); + gamesum++; + } + else + { + Console.WriteLine("芜湖!{0}赢了!",xm); + playersum++; + gamesum++; + } + circulation(); + break; + case 2: + Console.WriteLine("{0}:出拳:{1}", xm, fname); + Console.WriteLine("{0}:出拳:{1}", name, q); + if (qq.Equals(1)) + { + Console.WriteLine("{0}输了,不要害怕失败大不了从头来过!", xm); + robotsum++; + gamesum++; + } + else if (fname.Equals(q)) + { + Console.WriteLine("和局,真倒霉!你个王八犊子等着瞧!"); + gamesum++; + } + else + { + Console.WriteLine("芜湖!{0}赢了!",xm); + playersum++; + gamesum++; + } + circulation(); + break; + case 3: + Console.WriteLine("{0}:出拳:{1}", xm, fname); + Console.WriteLine("{0}:出拳:{1}", name, q); + if (qq.Equals(2)) + { + Console.WriteLine("{0}输了,不要害怕失败大不了从头来过!", xm); + robotsum++; + gamesum++; + } + else if (fname.Equals(q)) + { + Console.WriteLine("和局,真倒霉!你个王八犊子等着瞧!"); + gamesum++; + } + else + { + Console.WriteLine("芜湖!{0}赢了!",xm); + playersum++; + gamesum++; + } + circulation(); + break; + default: + Console.WriteLine("没有该选项!"); + break; + } + } + static void end() + { + Console.WriteLine(); + Console.WriteLine(); + Console.WriteLine("===================================="); + Console.WriteLine("{0} vs {1}", name, xm); + Console.WriteLine("对战次数:{0}",gamesum); + Console.WriteLine(); + Console.WriteLine("姓名\t得分"); + Console.WriteLine("{0}\t{1}", xm,playersum); + Console.WriteLine("{0}\t{1}", name,robotsum); + if (playersum>robotsum) + { + Console.WriteLine("结果:{0}赢,{1}输了", xm, name) ; + } + else if(playersum < robotsum) + { + Console.WriteLine("结果:{0}赢,{1}输了",name,xm); + } + else + { + Console.WriteLine("结果:似乎平局了哦"); + } + cx: + Console.WriteLine("要开始下一局吗?(y/n)"); + string newgame = Console.ReadLine(); + if (newgame == "y") + { + playersum = 0; robotsum = 0; gamesum = 0; + pk(); + } + else if (newgame == "n") + { + Console.WriteLine("系统退出"); + } + else + { + Console.WriteLine("没有该选项请重新选择"); + goto cx; + } + } + static void circulation() + { + cx: + Console.WriteLine("是否开启下一轮?(y/n)"); + string next = Console.ReadLine(); + if (next == "y") + { + confrontation(); + } + else if (next == "n") + { + end(); + } + else + { + Console.WriteLine("没有该选项!重新选择!"); + goto cx; + } + } + } +} -- Gitee From 33be4e15622ef9823a7d3b44af4ace5b8baf7f80 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 5 Jun 2021 21:02:50 +0800 Subject: [PATCH 32/74] 11 --- "\345\220\264\347\205\214/PlayPepole.cs" | 95 ++++++++++++++++ "\345\220\264\347\205\214/Program.cs" | 132 +++++++++++++++++++++++ 2 files changed, 227 insertions(+) create mode 100644 "\345\220\264\347\205\214/PlayPepole.cs" create mode 100644 "\345\220\264\347\205\214/Program.cs" diff --git "a/\345\220\264\347\205\214/PlayPepole.cs" "b/\345\220\264\347\205\214/PlayPepole.cs" new file mode 100644 index 0000000..389b4bd --- /dev/null +++ "b/\345\220\264\347\205\214/PlayPepole.cs" @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp9 +{ + public enum CaiQuan + { + 石头 = 1, + 剪刀, + 布 + } + + class PlayPepole + { + + public string Name; //姓名 + + public int STJDB { get; set; }//石头剪刀布 + public int FenShu { get; set; }//计算分数 + + + public PlayPepole(string name) + { + this.Name = name; + } + + public PlayPepole() + { + + } + + public virtual void ChuQuan()//出拳虚方法 + { + Console.WriteLine("请出拳: 1.石头 2.剪刀 3.布"); + + } + + + } + class NPC:PlayPepole //人机 + { + public NPC(string name):base(name) + { + this.Name = name; + } + + public static CaiQuan CaiQuan1; + + public override void ChuQuan() + { + + Random r = new Random(); + this.STJDB = r.Next(1,4); //生成随机数1-3 & 赋值到Stjdb字段 + CaiQuan caiQuan = (CaiQuan)STJDB; //stjdb字段 转换caiQuan对应的枚举值 + Console.WriteLine("{0},出拳:{1}", Name, caiQuan); + Console.WriteLine("================================="); + + + } + + } + class PlayYou:PlayPepole //玩家 + { + + public PlayYou(string name) : base(name) + { + this.Name = name; + } + public static CaiQuan caiQuan1; + + public override void ChuQuan() + { + base.ChuQuan(); //继承 + STJDB = int.Parse(Console.ReadLine()); //用stjdb字段接收输入的值 + CaiQuan caiQuan = (CaiQuan)STJDB; //将stjdb转换为相对应的枚举值 + if (STJDB==1 || STJDB == 2 || STJDB == 3 ) + { + Console.WriteLine("================================="); + Console.WriteLine("{0},出拳:{1}", Name, caiQuan); //最后输出 + } + else + { + Console.WriteLine("请输入1-3范围内!"); + ChuQuan(); + } + + + + } + } + +} diff --git "a/\345\220\264\347\205\214/Program.cs" "b/\345\220\264\347\205\214/Program.cs" new file mode 100644 index 0000000..5baf5d8 --- /dev/null +++ "b/\345\220\264\347\205\214/Program.cs" @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp9 +{ + class Program + { + static NPC nPC; + static PlayYou you; + static int CiShu = 0; //用来计算对战次数 并 赋初始值 + + enum HeroName + { + 刘备=1, + 曹操, + 孙权 + } + + + + static void Main(string[] args) + { + Game(); + } + + public static void Game() + { + Console.WriteLine("----------欢迎进入游戏世界----------"); + Console.WriteLine("*************猜拳,开始********"); + Console.WriteLine("出拳规则:1.石头 2.剪刀 3.布"); + Console.WriteLine("请选择对方角色<1.刘备 2.曹操 3.孙权>"); + int key = int.Parse(Console.ReadLine()); + if (key>0 && key<=3) //此if 用来判断是否在人机的范围内 + { + HeroName heroName = (HeroName)key; //将输入的数 转换成对应的枚举类型的枚举值 + string NPCName = heroName.ToString();//将对应的枚举值转换成 string + nPC = new NPC(NPCName); //将转换后的string 传到NPC类当中 + Console.WriteLine("请输入您的姓名:"); + string PlayFamily = Console.ReadLine(); + you = new PlayYou(PlayFamily); + Console.WriteLine("{0} VS {1}", you.Name, nPC.Name); + Console.WriteLine("开始游戏吗?"); + CxPlay: string YesORNo = Console.ReadLine(); + you.FenShu = 0; //分数初始化 + nPC.FenShu = 0;//分数初始化 + CiShu = 0; //对战次数初始化 + XunHuan: switch (YesORNo) + { + case "y": //开始游戏 + you.ChuQuan(); //输出玩家 + nPC.ChuQuan(); //输出人机 + CaiPan(); //判断 + Console.WriteLine("是否继续下一局?(y/n)"); + string yn = Console.ReadLine(); + switch (yn) + { + case "y": //开始游戏 + goto XunHuan; //循环继续游戏 + + case "n": + PrintJieGuo(); //结束游戏 并打印结果 + Console.WriteLine("亲爱的!要再玩一把吗?(y/n)"); + goto CxPlay; + + // goto XunHuan; //清掉所有数据后 继续走循环开始游戏 + break; + default: + Console.WriteLine("请睁大你的狗眼!输入:y 或者 n。即将返回游戏首页"); + Game(); + break; + } + break; + case "n": + Console.WriteLine("程序结束!拜拜!"); //结束游戏 并打印结果 + break; + default: + Console.WriteLine("请睁大你的狗眼!输入:y 或者 n。即将返回游戏首页"); + Game(); + break; + } + } + else + { + Console.WriteLine("输入错误!!"); + Game(); + } + + + } + + private static void PrintJieGuo()//打印结果 + { + Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + Console.WriteLine(" {0} VS {1}",you.Name,nPC.Name); + Console.WriteLine(" 对战次数:{0}", CiShu ); + Console.WriteLine(" "); + Console.WriteLine(" 姓名: 得分:"); + Console.WriteLine(" {0}, {1}", you.Name,you.FenShu ); + Console.WriteLine(" {0}, {1}", nPC.Name,nPC.FenShu ); + Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + } + + //裁判 判断输赢 + public static void CaiPan() + { + CiShu++; //只要进入游戏,那么对战次数就++ + + if (you.STJDB==nPC.STJDB) + { + Console.WriteLine("真晦气!和局"); + } + //1石头 2剪刀 3布 + else if (you.STJDB==1&&nPC.STJDB==2 || you.STJDB==2 && nPC.STJDB==3 || you.STJDB==3 && nPC.STJDB==1) + { + Console.WriteLine("真棒!!{0}赢了",you.Name); + you.FenShu++; + } + else + { + Console.WriteLine("笨蛋{0}!{1}输了", you.Name,you.Name); + nPC.FenShu++; + } + + } + + + + } +} -- Gitee From 4168f9d47c653b72210db338ae5444f058398e8f Mon Sep 17 00:00:00 2001 From: weilijiang <3055679233@qq.com> Date: Sat, 5 Jun 2021 23:44:17 +0800 Subject: [PATCH 33/74] weilijiang --- .../JudgeMan.cs" | 11 ++ .../NPCMan.cs" | 15 ++ .../Player.cs" | 15 ++ .../Program.cs" | 173 ++++++++++++++++++ .../Role.cs" | 16 ++ 5 files changed, 230 insertions(+) create mode 100644 "\351\237\246\344\270\275\346\261\237/JudgeMan.cs" create mode 100644 "\351\237\246\344\270\275\346\261\237/NPCMan.cs" create mode 100644 "\351\237\246\344\270\275\346\261\237/Player.cs" create mode 100644 "\351\237\246\344\270\275\346\261\237/Program.cs" create mode 100644 "\351\237\246\344\270\275\346\261\237/Role.cs" diff --git "a/\351\237\246\344\270\275\346\261\237/JudgeMan.cs" "b/\351\237\246\344\270\275\346\261\237/JudgeMan.cs" new file mode 100644 index 0000000..568d724 --- /dev/null +++ "b/\351\237\246\344\270\275\346\261\237/JudgeMan.cs" @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ConsoleApp8 +{ + class JudgeMan:Role + { + + } +} diff --git "a/\351\237\246\344\270\275\346\261\237/NPCMan.cs" "b/\351\237\246\344\270\275\346\261\237/NPCMan.cs" new file mode 100644 index 0000000..67ce634 --- /dev/null +++ "b/\351\237\246\344\270\275\346\261\237/NPCMan.cs" @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ConsoleApp8 +{ + class NPCMan:Role + { + Random ran = new Random(); + public override int ShowFist() + { + return ran .Next (1,4); + } + } +} diff --git "a/\351\237\246\344\270\275\346\261\237/Player.cs" "b/\351\237\246\344\270\275\346\261\237/Player.cs" new file mode 100644 index 0000000..56e351c --- /dev/null +++ "b/\351\237\246\344\270\275\346\261\237/Player.cs" @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ConsoleApp8 +{ + class Player:Role + { + public override int ShowFist() + { + int num = int.Parse(Console .ReadLine ()); + return num; + } + } +} diff --git "a/\351\237\246\344\270\275\346\261\237/Program.cs" "b/\351\237\246\344\270\275\346\261\237/Program.cs" new file mode 100644 index 0000000..93a269f --- /dev/null +++ "b/\351\237\246\344\270\275\346\261\237/Program.cs" @@ -0,0 +1,173 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static System.Net.Mime.MediaTypeNames; + +namespace ConsoleApp3 +{ + public enum NPCRole + { + 刘备 = 1, + 孙权 , + 曹操 + } + public enum Fist + { + 石头 = 1, + 剪刀 , + 布 + } + class Program + { + static JudgeMan jm = new JudgeMan(); + static Player p = new Player(); + static NPCMan npc = new NPCMan(); + static int count = 0; + static int pCount = 0; + static int nCount = 0; + + static void Main(string[] args) + { + PlayFistGame(); + } + + private static void PlayFistGame() + { + Welcome(); + Prepare(); + Battle(); + ShowResult(); + } + + Console.WriteLine("....................................................................."); + private static void Welcome() + { + Console.WriteLine("====================......欢 迎 进 入 游 戏的 世 界...........====================\r\n"); + Console.WriteLine("************************************"); + Console.WriteLine("*************猜拳,开始啦啦啦!!!*************"); + Console.WriteLine("************************************\r\n"); + } + + private static void Prepare() + { + while (true) + { + Console.WriteLine("出拳规则:{0}", ListFist()); ; + Console.WriteLine("请选择对方角色:{0}", ListNPC()); + int num = int.Parse(Console.ReadLine()); + npc.Name = ((NPCRole)num).ToString(); + + Console.WriteLine("请输入您的姓名:"); + p.Name = Console.ReadLine(); + + Console.WriteLine("{0} VS {1} 对战", p.Name, npc.Name); + Console.WriteLine("开始游戏吗?(y/n)"); + string key = Console.ReadLine(); + if (key == "y") + { + break; + } + } + } + Console.WriteLine("....................................................................."); + + private static void Battle() + { + while (true) + { + Console.WriteLine("\n\r请出拳:{0}", ListFist()); + int pf = p.ShowFist(); + int nf = npc.ShowFist(); + Console.WriteLine("\r\n{0} 出: {1}", p.Name, (Fist)pf); + Console.WriteLine("{0} 出: {1}", npc.Name, (Fist)nf); + int result = IsWin(pf, nf); + + Console.WriteLine(); + Console.WriteLine(result == 0 ? "不可思议鸭,平局啦!!!" : result == 1 ? $"恭喜恭喜恭喜!!!{p.Name}赢了!" : $"太不好意思了!{p.Name}输了!"); + + count++; + if (result == 1) + { + pCount++; + } + else if (result == -1) + { + nCount++; + } + + Console.WriteLine("是否开始下一轮的猜拳活动呢?(y/n)"); + string key = Console.ReadLine(); + if (key != "y") + { + break; + } + } + } + + static void ShowResult() + { + Console.WriteLine("===================================================="); + Console.WriteLine("{0} VS {1}", p.Name, npc.Name); + Console.WriteLine("对战次数:{0}", count); + Console.WriteLine("姓名\t得分"); + Console.WriteLine("{0}\t{1}", p.Name, pCount); + Console.WriteLine("{0}\t{1}", npc.Name, nCount); + Console.WriteLine("平局\t{0}", count-nCount-pCount); + Console.WriteLine("总结果:" + (pCount > nCount ? p.Name : npc.Name) + "吼吼!!!赢了鸭鸭鸭!"); + Console.WriteLine("是否开始下一局的游戏呢?(y/n)"); + string key = Console.ReadLine(); + if (key == "y") + { + count = 0; + pCount = 0; + nCount = 0; + PlayFistGame(); + } + else + { + Console.WriteLine("系统要退出了!!!"); + } + } + Console.WriteLine("....................................................................."); + + + private static int IsWin(int pf, int nf) + { + if (pf == nf) + { + return 0; + } + else if (pf == 1 && nf == 2 || pf == 2 && nf == 3 || pf == 3 && nf == 1) + { + return 1; + } + else + { + return -1; + } + } + + static string ListFist() + { + string fistStr = ""; + foreach (Fist f in Enum.GetValues(typeof(Fist))) + { + fistStr += (int)f + "、" + f + ";"; + } + return fistStr; + } + Console.WriteLine("....................................................................."); + static string ListNPC() + { + string roleStr = ""; + foreach (NPCRole n in Enum.GetValues(typeof(NPCRole))) + { + roleStr += (int)n + "、" + n + ";"; + } + return roleStr; + } + + } +} diff --git "a/\351\237\246\344\270\275\346\261\237/Role.cs" "b/\351\237\246\344\270\275\346\261\237/Role.cs" new file mode 100644 index 0000000..ec224e2 --- /dev/null +++ "b/\351\237\246\344\270\275\346\261\237/Role.cs" @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ConsoleApp8 +{ + class Role + { + public string Name { get; set; } + public virtual int ShowFist() + { + + return 0; + } + } +} -- Gitee From f2ce7dcff3681a5c3ebbb0650c4b09578c83f718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=84=E4=B8=BA?= <2608359793@qq.com> Date: Sun, 6 Jun 2021 12:21:22 +0800 Subject: [PATCH 34/74] =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Judgment.cs" | 77 +++++++++++++++++++ .../Player.cs" | 55 +++++++++++++ .../Program.cs" | 32 ++++++++ .../Robot.cs" | 54 +++++++++++++ 4 files changed, 218 insertions(+) create mode 100644 "\345\210\230\345\230\211\344\277\212/Judgment.cs" create mode 100644 "\345\210\230\345\230\211\344\277\212/Player.cs" create mode 100644 "\345\210\230\345\230\211\344\277\212/Program.cs" create mode 100644 "\345\210\230\345\230\211\344\277\212/Robot.cs" diff --git "a/\345\210\230\345\230\211\344\277\212/Judgment.cs" "b/\345\210\230\345\230\211\344\277\212/Judgment.cs" new file mode 100644 index 0000000..a14fb6b --- /dev/null +++ "b/\345\210\230\345\230\211\344\277\212/Judgment.cs" @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo14 +{ + class Judgment + { + private Player players; + private Robot robot; + + public Judgment() { + Console.WriteLine("请选择对方角色<1:刘备 2:孙权 3:曹操>"); + int a = int.Parse(Console.ReadLine()); + Console.WriteLine("请输入您的名字:"); + string b = Console.ReadLine(); + players = new Player(b); + } + + public void Play() { + int count=0; + while (count < 5) ; + { + int pFist = players.player(); + int rFist = robot.listFist(); + if (pFist == 1 && rFist == 3 || pFist == 2 && rFist == 1 || pFist == 3 || rFist == 2) + { + Console.WriteLine(players.playerName() + ":此局获胜"); + players.addScore(); + } + else if (pFist == rFist) + { + Console.WriteLine("这局平局。"); + } + else + { + Console.WriteLine(robot.RobotName() + ":此局获胜。"); + robot.addScore(); + } + } + count++; + } + public void getResult() { + int pScore = players.Score(); + int rScore = robot.Score(); + if (pScore > rScore) + { + Console.WriteLine(players.playerName() + ":最终胜利"); + } + else if (pScore == rScore) + { + Console.WriteLine("平局"); + } + else { + Console.WriteLine(robot.RobotName()+":最终胜利"); + } + } + public void Start() { + while (true) + { + Play(); + getResult(); + Console.WriteLine("是否继续?(y/n)"); + string a = Console.ReadLine(); + if (a == "y") + { + continue; + } + else if (a=="n") { + break; + } + } + } + } +} diff --git "a/\345\210\230\345\230\211\344\277\212/Player.cs" "b/\345\210\230\345\230\211\344\277\212/Player.cs" new file mode 100644 index 0000000..a5bd2e0 --- /dev/null +++ "b/\345\210\230\345\230\211\344\277\212/Player.cs" @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo14 +{ + + enum Fist{ + 剪刀=1, + 石头, + 布 + } + class Player + { + private string name; + private int score; + + public Player(string name) { + this.name = name; + this.score = 0; + } + + public int player() { + Console.WriteLine("请出拳:{0}",ListFist()); + return player(); + } + + public static string ListFist() { + string firstString = ""; + int i = 1; + foreach (Fist f in Enum.GetValues(typeof(Fist))) + { + firstString += i + "、" + f + ";"; + Console.WriteLine(f); + i++; + } + return firstString; + } + + public void addScore() { + score += 1; + } + public int Score() { + return score; + } + + public string playerName() { + return name; + } + + + } +} diff --git "a/\345\210\230\345\230\211\344\277\212/Program.cs" "b/\345\210\230\345\230\211\344\277\212/Program.cs" new file mode 100644 index 0000000..c1d623a --- /dev/null +++ "b/\345\210\230\345\230\211\344\277\212/Program.cs" @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo14 +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("------------------------------欢迎进入游戏世界------------------------------"); + Console.WriteLine("*****************"); + Console.WriteLine("******猜拳,开始******"); + Console.WriteLine("*****************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Judgment jud = new Judgment(); + jud.Start(); + + + + + + + + + + } + + } +} diff --git "a/\345\210\230\345\230\211\344\277\212/Robot.cs" "b/\345\210\230\345\230\211\344\277\212/Robot.cs" new file mode 100644 index 0000000..cbf8c0f --- /dev/null +++ "b/\345\210\230\345\230\211\344\277\212/Robot.cs" @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo14 +{ + class Robot + { + private string name { get; set; } + private int score; + + public Robot(string name,int score) { + this.name = name; + this.score = 0; + } + + public int listFist() { + Random ra = new Random(); + int a = ra.Next(1, 4); + switch (a) + { + case 1: + Console.WriteLine(name + ":出拳: 剪刀"); + break; + case 2: + Console.WriteLine(name + ":出拳: 石头"); + break; + case 3: + Console.WriteLine(name + ":出拳: 布"); + break; + + default: + break; + } + return a; + } + + + public void addScore(){ + score += 1; + } + + public int Score() { + return score; + } + + public string RobotName() { + return name; + } + + } +} -- Gitee From 15b4e52e334d469fa2d72c1180d66c106e7584f3 Mon Sep 17 00:00:00 2001 From: zyq520lcx <2642587822@qq.com> Date: Sun, 6 Jun 2021 13:01:50 +0800 Subject: [PATCH 35/74] =?UTF-8?q?=E5=95=8A=E5=95=8A=E5=95=8A=E5=95=8A?= =?UTF-8?q?=E5=95=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Game.cs" | 42 ++++++ .../Gameplayer.cs" | 16 ++ .../Judgment.cs" | 42 ++++++ .../ManMachine.cs" | 22 +++ .../Program.cs" | 140 ++++++++++++++++++ 5 files changed, 262 insertions(+) create mode 100644 "\351\273\216\346\231\250\351\234\236/Game.cs" create mode 100644 "\351\273\216\346\231\250\351\234\236/Gameplayer.cs" create mode 100644 "\351\273\216\346\231\250\351\234\236/Judgment.cs" create mode 100644 "\351\273\216\346\231\250\351\234\236/ManMachine.cs" create mode 100644 "\351\273\216\346\231\250\351\234\236/Program.cs" diff --git "a/\351\273\216\346\231\250\351\234\236/Game.cs" "b/\351\273\216\346\231\250\351\234\236/Game.cs" new file mode 100644 index 0000000..6d8673d --- /dev/null +++ "b/\351\273\216\346\231\250\351\234\236/Game.cs" @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Demo0604 +{ + //父类 + enum Fist + { + 石头=1, + 剪刀, + 布 + } + enum Man + { + 刘备 = 1, + 孙权, + 曹操 + } + + class Game + { + private string name; + private Fist fist; + private Man Man; + internal Man man { get => Man; set => Man = value; } + public string Name { get => name; set => name = value; } + internal Fist Fist { get => fist; set => fist = value; } + + public Game() { } + public Game(string name, Man man) + { + this.Name = name; + this.Fist = fist; + this.Man = man; + } + public virtual int ShowFist()//玩家人机出拳 + { + return 0; + } + } +} diff --git "a/\351\273\216\346\231\250\351\234\236/Gameplayer.cs" "b/\351\273\216\346\231\250\351\234\236/Gameplayer.cs" new file mode 100644 index 0000000..c3b71ad --- /dev/null +++ "b/\351\273\216\346\231\250\351\234\236/Gameplayer.cs" @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Demo0604 +{ + //玩家 + class Gameplayer : Game + { + public override int ShowFist() + { + int num = int.Parse(Console.ReadLine()); + return num; + } + } +} diff --git "a/\351\273\216\346\231\250\351\234\236/Judgment.cs" "b/\351\273\216\346\231\250\351\234\236/Judgment.cs" new file mode 100644 index 0000000..03140ce --- /dev/null +++ "b/\351\273\216\346\231\250\351\234\236/Judgment.cs" @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Demo0604 +{ + //裁判 + + class Judgment : Game + { + private int judg; + private int judg2; + public int Judg { get => judg; set => judg = value; } + public int Judg2 { get => judg2; set => judg2 = value; } + + public Judgment(int judg, int judg2) + { + this.Judg = judg; + this.Judg2 = judg2; + } + public Judgment() { } + //写“嘻嘻嘻,玩家输了” + public int Port(int gnum,int mannum) + { + if (gnum==mannum) + { + return 0; + } + else if (gnum == 1 && mannum == 2 || gnum == 2 && mannum == 3 || gnum == 3 && mannum == 1 ) + { + return 1; + } + else + { + return -1; + } + } + + + + } +} diff --git "a/\351\273\216\346\231\250\351\234\236/ManMachine.cs" "b/\351\273\216\346\231\250\351\234\236/ManMachine.cs" new file mode 100644 index 0000000..7eb49d2 --- /dev/null +++ "b/\351\273\216\346\231\250\351\234\236/ManMachine.cs" @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Demo0604 +{ + //人机 + + + class ManMachine:Game + { + //随机数 + public override int ShowFist() + { + Random ran = new Random(); + int a = ran.Next(1, 4); + return a; + } + + + } +} diff --git "a/\351\273\216\346\231\250\351\234\236/Program.cs" "b/\351\273\216\346\231\250\351\234\236/Program.cs" new file mode 100644 index 0000000..28afb1a --- /dev/null +++ "b/\351\273\216\346\231\250\351\234\236/Program.cs" @@ -0,0 +1,140 @@ +using System; + +namespace Demo0604 +{ + class Program + { + static void Main(string[] args) + { + //变量&引用 + Gameplayer g = new Gameplayer();//玩家 + ManMachine man = new ManMachine();//人机 + Judgment jud = new Judgment();//裁判 + int time = 0;//总次数 + int r=0;//人机 + int w = 0;//玩家 + string flag = null; + logio: + Front();//开头 + + Console.WriteLine("出拳规则:{0}",ListFist()); + Console.WriteLine("请选择对方角色<{0}>",Machinename()); + int key = int.Parse(Console.ReadLine()); + man.Name = ((Man)key).ToString();//人机姓名 + Console.WriteLine("请输入您的姓名:"); + g.Name= Console.ReadLine();//玩家姓名 + //循环1 + while (true) + { + Console.WriteLine("{0}vs{1}\t对战",g.Name,man.Name); + Console.WriteLine("开始游戏吗?(y/n)"); + flag = Console.ReadLine(); + if (flag.Equals("y")) + { + break; + } + } + while (true) + { + Console.WriteLine("\n\r请出拳:{0}(输入相应数字:)",ListFist()); + int gnum = g.ShowFist();//玩家出拳 + int mannum = man.ShowFist();//人机出拳 + Console.WriteLine("{0}:出拳:{1}",g.Name,(Fist)gnum); + Console.WriteLine("{0}:出拳:{1}",man.Name,(Fist)mannum);//随机数 + int a = jud.Port(gnum,mannum); + User(a,g.Name); + if (a==1) + { + w++; + } + if (a==-1) + { + r++; + } + time++; + Console.WriteLine("是否开始进行下一轮?(y/n)"); + flag = Console.ReadLine(); + if (flag.Equals("n")) + { + break; + } + } + Console.WriteLine("==========================="); + Console.WriteLine("{0}\tvs\t{1}",man.Name,g.Name); + Console.WriteLine("对战次数:{0}",time); + Console.WriteLine("姓名\t得分"); + Console.WriteLine("{0}\t{1}",g.Name,w); + Console.WriteLine("{0}\t{1}",man.Name,r); + if (w>r) + { + Console.WriteLine("哟,不错哦!居然你赢了,是我低估你了。"); + } + else + { + Console.WriteLine("切,就这。你个菜逼!"); + } + Console.WriteLine("要开始进行下一轮?(y/n)"); + flag = Console.ReadLine(); + if (flag.Equals("y")) + { + time = 0; + r = 0; + w = 0; + goto logio; + } + else + { + Console.WriteLine("系统退出!"); + } + } + + private static void Front() + { + //开头 + Console.WriteLine("-------------欢迎进入游戏世界---------------"); + Console.WriteLine("***************************"); + Console.WriteLine("*********猜拳,开始********"); + Console.WriteLine("***************************"); + } + + private static void User(int a,string name) + { + if (a == 0) + { + Console.WriteLine("和局,真衰!呵呵,等着瞧吧!"); + } + else if (a == 1) + { + Console.WriteLine("恭喜,{0}赢了",name); + } + else + { + Console.WriteLine("嘿,笨蛋,你输了!"); + } + } + //剪刀石头布 + static string ListFist() + { + string fistString = ""; + int i = 1; + foreach (Fist f in Enum.GetValues(typeof(Fist)) ) + { + fistString += i + "、" + f + ";"; + i++; + } + return fistString; + } + //人机名字 + static string Machinename() + { + string fistString = ""; + int i = 1; + foreach (Man m in Enum.GetValues(typeof(Man))) + { + fistString += i + ":" + m + ";"; + i++; + } + return fistString; + } + } +} -- Gitee From 3ba4788836b9e64bf96d4e18f9e1a5f7fd50a4ab Mon Sep 17 00:00:00 2001 From: wang-jiawen-rjjs <2903977615@qq.com> Date: Sun, 6 Jun 2021 13:42:43 +0800 Subject: [PATCH 36/74] =?UTF-8?q?=E7=8E=8B=E4=BD=B3=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Gamename.cs" | 23 +++ .../Judgement.cs" | 42 +++++ "\347\216\213\344\275\263\346\226\207/NPC.cs" | 33 ++++ .../Player.cs" | 18 +++ .../Program.cs" | 143 ++++++++++++++++++ 5 files changed, 259 insertions(+) create mode 100644 "\347\216\213\344\275\263\346\226\207/Gamename.cs" create mode 100644 "\347\216\213\344\275\263\346\226\207/Judgement.cs" create mode 100644 "\347\216\213\344\275\263\346\226\207/NPC.cs" create mode 100644 "\347\216\213\344\275\263\346\226\207/Player.cs" create mode 100644 "\347\216\213\344\275\263\346\226\207/Program.cs" diff --git "a/\347\216\213\344\275\263\346\226\207/Gamename.cs" "b/\347\216\213\344\275\263\346\226\207/Gamename.cs" new file mode 100644 index 0000000..df1ca6d --- /dev/null +++ "b/\347\216\213\344\275\263\346\226\207/Gamename.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DEMO +{ + class Gamename + { + private string name; + public string Name { get => name; set => name = value; } + + public Gamename() + { + + } + public virtual int ShowFist() + { + return 0; + } + } +} diff --git "a/\347\216\213\344\275\263\346\226\207/Judgement.cs" "b/\347\216\213\344\275\263\346\226\207/Judgement.cs" new file mode 100644 index 0000000..e99b4e5 --- /dev/null +++ "b/\347\216\213\344\275\263\346\226\207/Judgement.cs" @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DEMO +{ + class Judgement:Gamename + { + private int score; + private int score1; + + public Judgement(int score,int score1) + { + this.score = score; + this.score1 = score1; + } + + public int Score { get => score; set => score = value; } + public int Score1 { get => score1; set => score1 = value; } + + public Judgement() + { + } + public int Judge(int num,int y) + { + if (num == y) + { + return 0; + } + else if (num == 1 && y == 3 || num == 2 && y == 1 || num == 3 && y == 2) + { + return 1; + } + else + { + return -1; + } + } + } +} diff --git "a/\347\216\213\344\275\263\346\226\207/NPC.cs" "b/\347\216\213\344\275\263\346\226\207/NPC.cs" new file mode 100644 index 0000000..6c43ff5 --- /dev/null +++ "b/\347\216\213\344\275\263\346\226\207/NPC.cs" @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DEMO +{ + public enum NPCname + { + 刘备 = 1, + 孙权, + 曹操 + + } + class NPC : Gamename + { + + + + public NPC() : base() + { + + } + + public override int ShowFist() + { + Random r = new Random(); + return r.Next(1, 4); + } + } + } + diff --git "a/\347\216\213\344\275\263\346\226\207/Player.cs" "b/\347\216\213\344\275\263\346\226\207/Player.cs" new file mode 100644 index 0000000..73afa49 --- /dev/null +++ "b/\347\216\213\344\275\263\346\226\207/Player.cs" @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DEMO +{ + class Player : Gamename + { + + public Player() : base() + { + + } + + } +} diff --git "a/\347\216\213\344\275\263\346\226\207/Program.cs" "b/\347\216\213\344\275\263\346\226\207/Program.cs" new file mode 100644 index 0000000..305a566 --- /dev/null +++ "b/\347\216\213\344\275\263\346\226\207/Program.cs" @@ -0,0 +1,143 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DEMO +{ + public enum Fist + { + 剪刀 = 1, + 石头, + 布 + } + class Program + { + static void Main(string[] args) + { + int count = 0; + int pnum = 0; + int nnum = 0; + string b = null; + login: + Console.WriteLine("--------------------欢迎进入游戏世界----------------"); + Console.WriteLine("*********************"); + Console.WriteLine("****猜拳,开始*******"); + Console.WriteLine("*********************"); + Console.WriteLine("出拳规则:{0}", Fistlist()); + + Console.WriteLine("请选择对方角色:<1:刘备 2:孙权 3:曹操>"); + int a = int.Parse(Console.ReadLine()); + NPCname n = (NPCname)a; + NPC npc = new NPC(); + npc.Name = n.ToString(); + int nfist = npc.ShowFist(); + Console.WriteLine("请输入你的姓名:"); + Player p = new Player(); + p.Name = Console.ReadLine(); + while (true) + { + + Console.WriteLine("{0} VS {1} 对战", p.Name, npc.Name); + Console.WriteLine("开始游戏吗?(y/n)"); + + b = Console.ReadLine(); + if (b.Equals("y")) + { + break; + } + } + while (true) + { + Console.WriteLine("请出拳:{0},输入对应数字", Fistlist()); + int num = int.Parse(Console.ReadLine()); + Fist f = (Fist)num; + Console.WriteLine("{0},出拳:{1}", p.Name, f); + int y = npc.ShowFist(); + Fist j = (Fist)y; + Console.WriteLine("{0},出拳:{1}", npc.Name, j); + Judgement jud = new Judgement(); + int gamenum = jud.Judge(num, y); + Test(gamenum, p.Name); + + if (gamenum == 1) + { + pnum++; + } + else if (gamenum == -1) + { + nnum++; + } + count++; + Console.WriteLine("是否开始下一轮?(y/n)"); + b = Console.ReadLine(); + if (b.Equals("n")) + { + break; + } + } + + Console.WriteLine("==============================="); + Console.WriteLine("{0} VS {1} 对战", p.Name, npc.Name); + Console.WriteLine("对战次数:{0}", count); + Console.WriteLine("姓名 得分"); + Console.WriteLine("{0} {1}", p.Name, pnum); + Console.WriteLine("{0} {1}", npc.Name, nnum); + if (pnum > nnum) + { + Console.WriteLine("结果:{0}赢,{1}笨蛋", p.Name, npc.Name); + } + else if (pnum < nnum) + { + Console.WriteLine("结果:{0}赢,{1}笨蛋", npc.Name, p.Name); + + } + Console.WriteLine("是否要进行下一局(y/n)"); + b = Console.ReadLine(); + if (b.Equals("y")) + { + pnum = 0; + nnum = 0; + count = 0; + goto login; + } + else + { + Console.WriteLine("退出程序"); + } + + } + + private static void Test(int gamenum, string name) + { + if (gamenum == 0) + { + Console.WriteLine("和局,真衰!呵呵,等着瞧吧!"); + } + else if (gamenum == 1) + { + Console.WriteLine("恭喜,{0}赢了", name); + } + else + { + Console.WriteLine("嘿,笨蛋,你输了!"); + } + + + } + + private static string Fistlist() + { + string Fiststring = ""; + int i = 1; + foreach (Fist f in Enum.GetValues(typeof(Fist))) + { + Fiststring += i + "," + f + ";"; + //Console.WriteLine(f); + i++; + } + return Fiststring; + } + } +} -- Gitee From 7e67ea2cdbef765adfbca4b3c84310d1dc7598ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=87=E7=A8=8B=E7=A5=A5?= <842143662@qq.com> Date: Sun, 6 Jun 2021 14:10:54 +0800 Subject: [PATCH 37/74] C# --- .../Father.cs" | 26 ++++ .../Machine.cs" | 32 +++++ .../Player.cs" | 45 ++++++ .../Program.cs" | 132 ++++++++++++++++++ 4 files changed, 235 insertions(+) create mode 100644 "\344\270\207\347\250\213\347\245\245/Father.cs" create mode 100644 "\344\270\207\347\250\213\347\245\245/Machine.cs" create mode 100644 "\344\270\207\347\250\213\347\245\245/Player.cs" create mode 100644 "\344\270\207\347\250\213\347\245\245/Program.cs" diff --git "a/\344\270\207\347\250\213\347\245\245/Father.cs" "b/\344\270\207\347\250\213\347\245\245/Father.cs" new file mode 100644 index 0000000..285bfe8 --- /dev/null +++ "b/\344\270\207\347\250\213\347\245\245/Father.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Father + { + private string name; + + public string Name { get => name; set => name = value; } + + public Father(string name) + { + this.name = name; + } + + public virtual void punch() + { + + } + + } +} diff --git "a/\344\270\207\347\250\213\347\245\245/Machine.cs" "b/\344\270\207\347\250\213\347\245\245/Machine.cs" new file mode 100644 index 0000000..09c9800 --- /dev/null +++ "b/\344\270\207\347\250\213\347\245\245/Machine.cs" @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + enum Fist + { + 石头 = 1, + 剪刀, + 布, + } + class Machine : Father + { + + public Machine(string name) : base(name) + { + this.Name = name; + } + public int punch() + { + Random random = new Random(); + int num = random.Next(1, 4); + Fist f = (Fist)num; + Console.WriteLine("{0},出拳:{1}", base.Name, f); + return num; + } + + } +} diff --git "a/\344\270\207\347\250\213\347\245\245/Player.cs" "b/\344\270\207\347\250\213\347\245\245/Player.cs" new file mode 100644 index 0000000..d8bd8f9 --- /dev/null +++ "b/\344\270\207\347\250\213\347\245\245/Player.cs" @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Player : Father + { + enum Fist + { + 石头 = 1, + 剪刀, + 布, + } + + + public Player(string name) : base(name) + { + this.Name = name; + } + + + public int punch() + { + Console.WriteLine("请出拳:{0}(请输入相应的数字)", ListFist()); + int choose = int.Parse(Console.ReadLine()); + Fist f = (Fist)choose; + Console.WriteLine("{0},出拳:{1}", base.Name, f); + return choose; + } + static string ListFist() + { + string fistString = " "; + int i = 1; + foreach (Fist f in Enum.GetValues(typeof(Fist))) + { + fistString += i + "、" + f + ";"; + i++; + } + return fistString; + } + } +} diff --git "a/\344\270\207\347\250\213\347\245\245/Program.cs" "b/\344\270\207\347\250\213\347\245\245/Program.cs" new file mode 100644 index 0000000..2378ae5 --- /dev/null +++ "b/\344\270\207\347\250\213\347\245\245/Program.cs" @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + enum MachineName + { + 刘备 = 1, + 孙权, + 曹操 + } + + class Program + { + + static void Main(string[] args) + + { + Console.WriteLine("-------------------欢迎进入游戏世界!---------------------"); + Console.WriteLine(); + Console.WriteLine(); + Console.WriteLine("=========================================================="); + Console.WriteLine("=====================猜拳!开始!========================="); + Console.WriteLine("=========================================================="); + + Console.WriteLine("出拳规则:1.石头 2.剪刀 3.布"); + Console.WriteLine(); + + Console.WriteLine("请输入您的姓名:"); + string playName = Console.ReadLine(); + Console.WriteLine("请选择对方角色 <1.刘备 2.孙权 3.曹操>"); + int choose1 = int.Parse(Console.ReadLine()); + MachineName f = (MachineName)choose1; + Machine machine = new Machine(f.ToString()); + + Player player = new Player(playName); + Console.WriteLine("{0} vs {1} 对战 !", playName, f); + Console.WriteLine("开始游戏吗?(y/n)"); + string YN = Console.ReadLine(); + + + if (YN.Equals("y")) + { + + int choose = player.punch(); + int num = machine.punch(); + int score=0; + int scoreM = 0; + int count=0; + judge(choose, num,ref score ,ref scoreM,ref count); + next(choose, num, player, machine,playName,f,score,count,scoreM); + Console.WriteLine(); + Console.WriteLine("============================================"); + Console.WriteLine("{0} vs {1} 对战 !", playName, f); + Console.WriteLine(); + } + else + { + Console.WriteLine("游戏已关闭!"); + } + + } + + private static void next(int choose, int num, Player player, Machine machine,string playName, MachineName f,int score,int count, int scoreM) + { + while (true) + { + + Console.WriteLine("是否要进行下一轮(y/n)"); + string YN2 = Console.ReadLine(); + if (YN2.Equals("y")) + { + choose = player.punch(); + num = machine.punch(); + judge(choose, num,ref score ,ref count,ref scoreM); + } + else + { + Console.WriteLine("============================================"); + Console.WriteLine("{0} vs {1} 对战 !", playName, f); + Console.WriteLine("对战次数{0}",count); + Console.WriteLine(); + Console.WriteLine("姓名 得分"); + Console.WriteLine("{0} {1}",playName, score); + Console.WriteLine("{0} {1}",f, scoreM); + if (score>scoreM) + { + Console.WriteLine("{0}赢,{1}笨蛋", playName, f); + } + if (score < scoreM) + { + Console.WriteLine("{0}赢,{1}笨蛋", f,playName); + } + if (score < scoreM) + { + Console.WriteLine("居然是平局!!!"); + } + // Console.WriteLine("要进行下一局吗(y/n)"); + next(choose, num, player, machine, playName, f, score, count, scoreM); + break; + } + } + } + + private static int judge(int choose, int num, ref int score, ref int count, ref int scoreM) + { + + + if (choose == 1 && num == 2 || choose == 2 && num == 3 || choose == 3 && num == 1) + { + Console.WriteLine("恭喜您,获胜了!"); + score++; + count++; + } + if (choose == 1 && num == 1 || choose == 2 && num == 2 || choose == 3 && num == 3) + { + Console.WriteLine("真可惜,平局!"); + count++; + } + if (choose == 2 && num == 1 || choose == 3 && num == 2 || choose == 1 && num == 3) + { + Console.WriteLine("哎哎哎,您输了!"); + scoreM++; + count++; + } + return score; + } + } +} -- Gitee From 1eb336ea9eefb9015a6eba9b9d6eaf67820c4a3c Mon Sep 17 00:00:00 2001 From: PilRio <2535341085@qq.com> Date: Sun, 6 Jun 2021 15:13:23 +0800 Subject: [PATCH 38/74] =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\346\236\227\346\265\267\346\266\233/Jse.cs" | 76 +++++++++++ .../Program.cs" | 119 ++++++++++++++++++ 2 files changed, 195 insertions(+) create mode 100644 "\346\236\227\346\265\267\346\266\233/Jse.cs" create mode 100644 "\346\236\227\346\265\267\346\266\233/Program.cs" diff --git "a/\346\236\227\346\265\267\346\266\233/Jse.cs" "b/\346\236\227\346\265\267\346\266\233/Jse.cs" new file mode 100644 index 0000000..0c0c5eb --- /dev/null +++ "b/\346\236\227\346\265\267\346\266\233/Jse.cs" @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + public enum Qun + { + 剪刀 = 1, + 石头, + 布 + } + abstract class Jse + { + public Jse(string name) + { + this.name = name; + } + public int grade { get; set; }//分数 + public int FGG { get; set; }//猜拳 + public Jse() + { + + } + + public string name { get; set; } + + public abstract void Cun(); + + } + class Figure : Jse + { + public Figure(string name) : base(name) + { + + } + public override void Cun() + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布"); + this.FGG = int.Parse(Console.ReadLine()); + Qun qun = (Qun)FGG; + Console.WriteLine("{0}:出拳:{1}", this.name, qun); + } + } + class Npc : Jse + { + public Npc(string name) : base(name) + { + + } + + public override void Cun() + { + Random ran = new Random(); + this.FGG = ran.Next(3) + 1; + Qun qun = (Qun)FGG; + Console.WriteLine("{0}:出拳:{1}", this.name, qun); + } + } + class judge : Jse + { + public judge() + { + + } + public override void Cun() + { + + } + } + + + +} diff --git "a/\346\236\227\346\265\267\346\266\233/Program.cs" "b/\346\236\227\346\265\267\346\266\233/Program.cs" new file mode 100644 index 0000000..4283f28 --- /dev/null +++ "b/\346\236\227\346\265\267\346\266\233/Program.cs" @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Program + { + public enum Qun { + 剪刀=1, + 石头, + 布 + } + + static void Main(string[] args) + { + + Console.WriteLine("------欢 迎 来 到 游 戏 世 界------"); + Console.WriteLine("***********************************"); + Console.WriteLine("***********猜拳,开始**************"); + Console.WriteLine("***********************************"); + text1(); + } + + static void text1() + { + int i = 1; + Npc npc; + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Console.WriteLine("请选择对面角色(1.刘备 2.孙权 3.曹操)"); + int key = int.Parse(Console.ReadLine()); + switch (key) + { + case 1: + npc = new Npc("刘备"); + break; + case 2: + npc = new Npc("孙权"); + break; + case 3: + npc = new Npc("曹操"); + break; + default: + Console.WriteLine("输入不规范,默认对战刘备"); + npc = new Npc("刘备"); + break; + } + Console.WriteLine("请输入你的名字"); + string name = Console.ReadLine(); + Figure figure = new Figure(name); + longin: + Console.WriteLine("{0} vs {1} 对战",figure.name,npc.name); + figure.Cun(); + npc.Cun(); + text2(figure, npc); + Console.WriteLine("要不要下一轮(y/n)"); + string y = Console.ReadLine(); + switch (y) + { + case "y": + i++; + goto longin; + break; + case "n": + Console.WriteLine("{0} vs {1} 对战", figure.name, npc.name); + Console.WriteLine("对战次数"+i); + Console.WriteLine("名字\t得分"); + Console.WriteLine("{0}\t{1}",figure.name,figure.grade); + Console.WriteLine("{0}\t{1}",npc.name,npc.grade); + if (figure.grade >= npc.grade) + { + Console.WriteLine("结果,{0}赢了,{1}傻逼",figure.name, npc.name); + } + else + { + Console.WriteLine("结果,{0}赢了,{1}傻逼", npc.name, figure.name); + } + Console.WriteLine(); + Console.WriteLine("要开始下一局吗(y/n)"); + string n = Console.ReadLine(); + switch (n) + { + case "y": + + text1(); + break; + + default: + break; + } + break; + default: + break; + } + } + static void text2(Figure figure, Npc npc) + { + if (figure.FGG==npc.FGG) + { + Console.WriteLine("和局,真哀! 嘿嘿,等着瞧吧!"); + + } + else if (figure.FGG+1== npc.FGG || (figure.FGG==3 && npc.FGG==1)) + { + Console.WriteLine("傻逼,{0}输了",figure.name); + npc.grade++; + } + else + { + Console.WriteLine("牛逼,{0}赢了", figure.name); + figure.grade++; + } + } + + + } +} -- Gitee From c19a6be66b5f82a3cb3f7606647d1fb052aa21ee Mon Sep 17 00:00:00 2001 From: PilRio <2535341085@qq.com> Date: Sun, 6 Jun 2021 16:32:58 +0800 Subject: [PATCH 39/74] =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Figure.cs" | 20 ++++ "\346\236\227\346\265\267\346\266\233/Jse.cs" | 62 ++--------- .../Judge.cs" | 16 +++ "\346\236\227\346\265\267\346\266\233/NPC.cs" | 20 ++++ .../Program.cs" | 102 +++++++++--------- 5 files changed, 112 insertions(+), 108 deletions(-) create mode 100644 "\346\236\227\346\265\267\346\266\233/Figure.cs" create mode 100644 "\346\236\227\346\265\267\346\266\233/Judge.cs" create mode 100644 "\346\236\227\346\265\267\346\266\233/NPC.cs" diff --git "a/\346\236\227\346\265\267\346\266\233/Figure.cs" "b/\346\236\227\346\265\267\346\266\233/Figure.cs" new file mode 100644 index 0000000..e4b8d6e --- /dev/null +++ "b/\346\236\227\346\265\267\346\266\233/Figure.cs" @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp3 +{ + class Figure:Jse + { + public Figure(string name) : base(name) { } + public override void print() + { + Console.WriteLine("请出拳:1.石头 2.剪刀 3.布"); + this.FGG = int.Parse(Console.ReadLine()); + cq cq = (cq)FGG; + Console.WriteLine("{0}:出拳:{1}",this.name,cq); + } + } +} diff --git "a/\346\236\227\346\265\267\346\266\233/Jse.cs" "b/\346\236\227\346\265\267\346\266\233/Jse.cs" index 0c0c5eb..aaf2e43 100644 --- "a/\346\236\227\346\265\267\346\266\233/Jse.cs" +++ "b/\346\236\227\346\265\267\346\266\233/Jse.cs" @@ -4,12 +4,12 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace ConsoleApp1 +namespace ConsoleApp3 { - public enum Qun + enum cq { - 剪刀 = 1, 石头, + 剪刀, 布 } abstract class Jse @@ -18,59 +18,11 @@ namespace ConsoleApp1 { this.name = name; } - public int grade { get; set; }//分数 - public int FGG { get; set; }//猜拳 - public Jse() - { - - } + public int score { get; set; } + public int FGG { get; set; } + public Jse() { } public string name { get; set; } - - public abstract void Cun(); - - } - class Figure : Jse - { - public Figure(string name) : base(name) - { - - } - public override void Cun() - { - Console.WriteLine("请出拳:1.剪刀 2.石头 3.布"); - this.FGG = int.Parse(Console.ReadLine()); - Qun qun = (Qun)FGG; - Console.WriteLine("{0}:出拳:{1}", this.name, qun); - } - } - class Npc : Jse - { - public Npc(string name) : base(name) - { - - } - - public override void Cun() - { - Random ran = new Random(); - this.FGG = ran.Next(3) + 1; - Qun qun = (Qun)FGG; - Console.WriteLine("{0}:出拳:{1}", this.name, qun); - } + public abstract void print(); } - class judge : Jse - { - public judge() - { - - } - public override void Cun() - { - - } - } - - - } diff --git "a/\346\236\227\346\265\267\346\266\233/Judge.cs" "b/\346\236\227\346\265\267\346\266\233/Judge.cs" new file mode 100644 index 0000000..386379f --- /dev/null +++ "b/\346\236\227\346\265\267\346\266\233/Judge.cs" @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp3 +{ + class Judge:Jse + { + public Judge() { } + public override void print() + { + } + } +} diff --git "a/\346\236\227\346\265\267\346\266\233/NPC.cs" "b/\346\236\227\346\265\267\346\266\233/NPC.cs" new file mode 100644 index 0000000..bf83f50 --- /dev/null +++ "b/\346\236\227\346\265\267\346\266\233/NPC.cs" @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp3 +{ + class NPC:Jse + { + public NPC(string name) : base(name) { } + public override void print() + { + Random ran = new Random(); + this.FGG = ran.Next(3) + 1; + cq cq = (cq)FGG; + Console.WriteLine("{0}:出拳:{1}",this.name,cq); + } + } +} diff --git "a/\346\236\227\346\265\267\346\266\233/Program.cs" "b/\346\236\227\346\265\267\346\266\233/Program.cs" index 4283f28..182f38f 100644 --- "a/\346\236\227\346\265\267\346\266\233/Program.cs" +++ "b/\346\236\227\346\265\267\346\266\233/Program.cs" @@ -4,89 +4,87 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace ConsoleApp1 +namespace ConsoleApp3 { class Program { - public enum Qun { - 剪刀=1, - 石头, + enum cq + { + 石头=1, + 剪刀, 布 - } - + } static void Main(string[] args) { - - Console.WriteLine("------欢 迎 来 到 游 戏 世 界------"); - Console.WriteLine("***********************************"); - Console.WriteLine("***********猜拳,开始**************"); - Console.WriteLine("***********************************"); - text1(); + Console.WriteLine("----- 欢 迎 进 入 游 戏 世 界 ----- "); + Console.WriteLine("********************"); + Console.WriteLine("*****猜拳,开始*****"); + Console.WriteLine("********************"); + t1(); } - - static void text1() + static void t1() { int i = 1; - Npc npc; - Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); - Console.WriteLine("请选择对面角色(1.刘备 2.孙权 3.曹操)"); + NPC npc; + Console.WriteLine("出拳规则:1、石头 2、剪刀 3、布"); + Console.WriteLine("请输入你的对手:1.刘备 2.孙权 3.曹操"); int key = int.Parse(Console.ReadLine()); switch (key) { case 1: - npc = new Npc("刘备"); + npc = new NPC("刘备"); break; case 2: - npc = new Npc("孙权"); + npc = new NPC("孙权"); break; case 3: - npc = new Npc("曹操"); + npc = new NPC("曹操"); break; default: - Console.WriteLine("输入不规范,默认对战刘备"); - npc = new Npc("刘备"); + Console.WriteLine("输入不规范,重新输入!!"); + t1(); break; } - Console.WriteLine("请输入你的名字"); + Console.WriteLine("请输入你的名字:"); string name = Console.ReadLine(); Figure figure = new Figure(name); - longin: - Console.WriteLine("{0} vs {1} 对战",figure.name,npc.name); - figure.Cun(); - npc.Cun(); - text2(figure, npc); - Console.WriteLine("要不要下一轮(y/n)"); - string y = Console.ReadLine(); - switch (y) + + login: + Console.WriteLine("{0} vs {1} 对战", figure.name, npc.name); + figure.print(); + npc.print(); + t2(figure, npc); + Console.WriteLine("是否下一轮:y/n"); + string key2 = Console.ReadLine(); + switch (key2) { case "y": i++; - goto longin; + goto login; break; case "n": - Console.WriteLine("{0} vs {1} 对战", figure.name, npc.name); - Console.WriteLine("对战次数"+i); + Console.WriteLine("{0} vs {1} 对战", figure.name,npc.name); + Console.WriteLine("对战次数" + i); Console.WriteLine("名字\t得分"); - Console.WriteLine("{0}\t{1}",figure.name,figure.grade); - Console.WriteLine("{0}\t{1}",npc.name,npc.grade); - if (figure.grade >= npc.grade) + Console.WriteLine("{0}\t{1}", figure.name, figure.score); + Console.WriteLine("{0}\t{1}", npc.name, npc.score); + if (figure.score >= npc.score) { - Console.WriteLine("结果,{0}赢了,{1}傻逼",figure.name, npc.name); + Console.WriteLine("结果,{0}赢了", figure.name); } else { - Console.WriteLine("结果,{0}赢了,{1}傻逼", npc.name, figure.name); + Console.WriteLine("结果,{0}赢了", npc.name); } Console.WriteLine(); - Console.WriteLine("要开始下一局吗(y/n)"); - string n = Console.ReadLine(); - switch (n) + + Console.WriteLine("要开始下一局吗?"); + string key3 = Console.ReadLine(); + switch (key3) { case "y": - - text1(); + t1(); break; - default: break; } @@ -95,25 +93,23 @@ namespace ConsoleApp1 break; } } - static void text2(Figure figure, Npc npc) + + private static void t2(Figure figure, NPC npc) { if (figure.FGG==npc.FGG) { Console.WriteLine("和局,真哀! 嘿嘿,等着瞧吧!"); - } - else if (figure.FGG+1== npc.FGG || (figure.FGG==3 && npc.FGG==1)) + else if (figure.FGG + 1 == npc.FGG || (figure.FGG == 3 && npc.FGG == 1)) { - Console.WriteLine("傻逼,{0}输了",figure.name); - npc.grade++; + Console.WriteLine("傻逼,{0}输了", figure.name); + npc.score++; } else { Console.WriteLine("牛逼,{0}赢了", figure.name); - figure.grade++; + figure.score++; } } - - } } -- Gitee From 43a0d0a60acda814ce0beb60fd8502f03a03f71d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=BB=BA=E5=B3=B0?= <357616491@qq.com> Date: Sun, 6 Jun 2021 18:20:30 +0800 Subject: [PATCH 40/74] zy --- "\345\210\230\345\273\272\345\263\260/NPC.cs" | 25 ++++ .../Program.cs" | 123 ++++++++++++++++++ .../Publicinfo.cs" | 23 ++++ .../player.cs" | 24 ++++ 4 files changed, 195 insertions(+) create mode 100644 "\345\210\230\345\273\272\345\263\260/NPC.cs" create mode 100644 "\345\210\230\345\273\272\345\263\260/Program.cs" create mode 100644 "\345\210\230\345\273\272\345\263\260/Publicinfo.cs" create mode 100644 "\345\210\230\345\273\272\345\263\260/player.cs" diff --git "a/\345\210\230\345\273\272\345\263\260/NPC.cs" "b/\345\210\230\345\273\272\345\263\260/NPC.cs" new file mode 100644 index 0000000..4d2762d --- /dev/null +++ "b/\345\210\230\345\273\272\345\263\260/NPC.cs" @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class NPC : Publicinfo + { + public NPC(string name) : base(name) + { + this.Name = name; + } + public override int fist() + { + Random r = new Random(); + int a = r.Next(3) + 1; + + return a; + } + + + } +} diff --git "a/\345\210\230\345\273\272\345\263\260/Program.cs" "b/\345\210\230\345\273\272\345\263\260/Program.cs" new file mode 100644 index 0000000..e4094f3 --- /dev/null +++ "b/\345\210\230\345\273\272\345\263\260/Program.cs" @@ -0,0 +1,123 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + enum npcname + { + 刘备 = 1, + 孙权, + 曹操 + } + enum fist + { + 剪刀 = 1, + 石头, + 布 + } + class Program + { + + static void Main(string[] args) + { + int pgroud = 0; + int ngroud = 0; + int session = 0; + against(ref pgroud, ref ngroud, ref session); + against2(ref pgroud, ref ngroud, ref session); + } + public static void against2(ref int pgroud, ref int ngroud, ref int session) + { + Console.WriteLine("要开始下一局吗?1、要 2、 不要"); + int choose3 = int.Parse(Console.ReadLine()); + switch (choose3) + { + case 1: + against(ref pgroud, ref ngroud, ref session); + against2(ref pgroud, ref ngroud, ref session); + break; + case 2: + Console.WriteLine("拜了个拜"); + break; + default: + Console.WriteLine("输入错误,重新开始"); + against(ref pgroud, ref ngroud, ref session); + break; + } + } + public static void against(ref int pgroud, ref int ngroud, ref int session) + { + Console.WriteLine("----游戏即将开始----"); + Console.WriteLine("--------------------"); + Console.WriteLine("-----猜拳·开始-----"); + Console.WriteLine("--------------------"); + Console.WriteLine("出拳规则:1、剪刀 2、 石头 3、 布"); + Console.WriteLine("请选择对方角色:1、刘备 2 、孙权 3、 曹操 (请输入相应数字)"); + int choose1 = int.Parse(Console.ReadLine()); + npcname f = (npcname)choose1; + + Console.WriteLine("请输入您的名字"); + string play = Console.ReadLine(); + player player = new player(play); + game(ref f, ref pgroud, ref ngroud, ref session, ref player); + + } + + public static void game(ref npcname f, ref int pgroud, ref int ngroud, ref int session, ref player player) + { + NPC npc = new NPC(f.ToString()); + int a = player.fist(); + fist playfist = (fist)a; + int b = npc.fist(); + fist npcfist = (fist)b; + Console.WriteLine("{0}出的拳为{1}", player.Name, playfist); + Console.WriteLine("{0}出的拳为{1}", npc.Name, npcfist); + string a1 = playfist.ToString(); + string a2 = npcfist.ToString(); + judge(a1, a2, ref pgroud, ref ngroud, ref session); + Console.WriteLine("是否开始下一轮 1、继续 2 、停止 "); + int choose = int.Parse(Console.ReadLine()); + switch (choose) + { + case 1: + game(ref f, ref pgroud, ref ngroud, ref session, ref player); + break; + case 2: + Console.WriteLine("{0}对阵{1}", player.Name, npc.Name); + Console.WriteLine("对阵次数{0}", session); + Console.WriteLine("姓名 得分"); + Console.WriteLine("{0} {1}", player.Name, pgroud); + Console.WriteLine("{0} {1}", npc.Name, ngroud); + break; + default: + Console.WriteLine("输入错误,重新开始"); + game(ref f, ref pgroud, ref ngroud, ref session, ref player); + break; + } + } + + public static void judge(string player, string npcfist, ref int pgroud, ref int ngroud, ref int session) + { + if (player.Equals("石头") && npcfist.Equals("剪刀") || player.Equals("剪刀") && npcfist.Equals("布") || player.Equals("布") && npcfist.Equals("石头")) + { + Console.WriteLine("你赢了"); + pgroud++; + session++; + } + else if (player.Equals(npcfist)) + { + Console.WriteLine("平局"); + session++; + } + else + { + Console.WriteLine("你输了"); + ngroud++; + session++; + } + } + } +} diff --git "a/\345\210\230\345\273\272\345\263\260/Publicinfo.cs" "b/\345\210\230\345\273\272\345\263\260/Publicinfo.cs" new file mode 100644 index 0000000..3f9fb41 --- /dev/null +++ "b/\345\210\230\345\273\272\345\263\260/Publicinfo.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Publicinfo + { + public string Name { get; set; } + + public Publicinfo(string name) + { + Name = name; + } + public virtual int fist() + { + return 0; + } + + } +} diff --git "a/\345\210\230\345\273\272\345\263\260/player.cs" "b/\345\210\230\345\273\272\345\263\260/player.cs" new file mode 100644 index 0000000..5f2ac31 --- /dev/null +++ "b/\345\210\230\345\273\272\345\263\260/player.cs" @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class player : Publicinfo + { + public player(string name) : base(name) + { + this.Name = name; + } + public override int fist() + { + Console.WriteLine("请出拳:1、剪刀 2 、石头 3、 布 (请输入相应数字)"); + int choose2 = int.Parse(Console.ReadLine()); + return choose2; + } + + + } +} -- Gitee From 2f26890df55f40475a0c99d8e4069698da385327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85=E8=BE=89?= <1926162199@qq.com> Date: Sun, 6 Jun 2021 18:41:53 +0800 Subject: [PATCH 41/74] 6.6 --- "\351\231\210\345\270\205\350\276\211/Cq.cs" | 216 ++++++++++++++++++ .../Father.cs" | 38 +++ .../Player.cs" | 23 ++ .../Program.cs" | 19 ++ 4 files changed, 296 insertions(+) create mode 100644 "\351\231\210\345\270\205\350\276\211/Cq.cs" create mode 100644 "\351\231\210\345\270\205\350\276\211/Father.cs" create mode 100644 "\351\231\210\345\270\205\350\276\211/Player.cs" create mode 100644 "\351\231\210\345\270\205\350\276\211/Program.cs" diff --git "a/\351\231\210\345\270\205\350\276\211/Cq.cs" "b/\351\231\210\345\270\205\350\276\211/Cq.cs" new file mode 100644 index 0000000..25f1300 --- /dev/null +++ "b/\351\231\210\345\270\205\350\276\211/Cq.cs" @@ -0,0 +1,216 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp8 +{ + + class Cq : Father + { + public Cq(string name, string playname) : base(name, playname) + { + + } + public Cq() + { } + public override void hello() + { + Console.WriteLine($"{this.name}"); + } + public void gogame() + { + int platname1 = 0;// + int botname1 = 0; + int pj = 0; + Console.WriteLine("请选择对方角色<1:刘备 2:孙权 3:曹操>"); + string name =Console.ReadLine();// + if (name.Equals("1")) + { + Cq cq = new Cq("刘备",""); + cq.hello(); + name = "刘备"; + } + else if (name.Equals("2")) + { + Cq cq1 = new Cq("孙权", ""); + cq1.hello(); + name = "孙权"; + } + else if (name.Equals("3")) + { + Cq cq2 = new Cq("曹操", ""); + cq2.hello(); + name = "曹操"; + + } + Console.WriteLine("请输入您的姓名"); + string playname = Console.ReadLine(); + Console.WriteLine($"{playname} VS {name}"); + Console.WriteLine("开始游戏吗?《y/n》"); + string game = Console.ReadLine(); + if (game.Equals("y")) + { + Console.WriteLine("请出拳:1.石头,2.剪刀,3.布(输入相应的数字)"); + int i = int.Parse(Console.ReadLine()); + if (i==1) + { + Console.WriteLine($"{playname} :出拳 {sjb.石头}"); + Random random = new Random(); + int a = random.Next(1, 4); + switch (a) + { + case 1: + Console.WriteLine( $"{name} 出拳 {sjb.石头}" ); + break; + case 2: + Console.WriteLine($"{name} 出拳 {sjb.剪刀}"); + break; + case 3: + Console.WriteLine($"{name} 出拳 {sjb.布}"); + break; + default: + break; + } + if (a==3) + { + Console.WriteLine($"笨蛋 {playname}你输了"); + botname1++; + } + if (a==2) + { + Console.WriteLine($"不错 {playname} 你赢了"); + pj++; + } + if (a==1) + { + Console.WriteLine("平局 走着瞧"); + platname1++; + } + } + if (i==2) + { + Console.WriteLine($"{playname} 出拳 {sjb.剪刀}"); + Random random = new Random(); + int a = random.Next(1, 4); + switch (a) + { + case 1: + Console.WriteLine($"{name} 出拳 {sjb.石头}"); + break; + case 2: + Console.WriteLine($"{name} 出拳 {sjb.剪刀}"); + break; + case 3: + Console.WriteLine($"{name} 出拳 {sjb.布}"); + break; + default: + break; + } + if (a==1) + { + Console.WriteLine($"笨蛋 {playname} 你输了"); + botname1++; + } + else if (a==2) + { + Console.WriteLine("平局 "); + pj++; + } + else + { + Console.WriteLine($"不错 {playname} 你赢了"); + } + } + if (i==3) + { + Console.WriteLine($"{playname} 出拳 {sjb.布}"); + Random random = new Random(); + int a = random.Next(1, 4); + switch (a) + { + case 1: + Console.WriteLine($"{name} 出拳 {sjb.石头}"); + break; + case 2: + Console.WriteLine($"{name} 出拳 {sjb.剪刀}"); + break; + case 3: + Console.WriteLine($"{name} 出拳 {sjb.布}"); + break; + } + if (a==1) + { + Console.WriteLine($"不错{playname} 你赢了"); + platname1++; + + } + else if (a==2) + { + Console.WriteLine($"笨蛋{playname} 你输了"); + botname1++; + } + else + { + Console.WriteLine("平局"); + pj++; + } + } + + + int sum = platname1 + botname1 + pj; + cq = sum; + Console.WriteLine("============================================="); + Console.WriteLine($"{playname} VS {name}"); + Console.WriteLine($"对战次数 {cq}"); + Console.WriteLine("姓名 得分"); + Console.WriteLine($"{playname } {platname1}"); + Console.WriteLine($"{name} {botname1}"); + Console.WriteLine("结果"); + if (platname1>botname1) + { + Console.WriteLine("你胜利了!!!"); + } + else if (platname1 Date: Sun, 6 Jun 2021 18:51:27 +0800 Subject: [PATCH 42/74] =?UTF-8?q?=E6=96=B0=E5=BB=BA=20=E9=BB=84=E9=94=9F?= =?UTF-8?q?=E5=AE=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\351\273\204\351\224\237\345\256\207/.keep" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "\351\273\204\351\224\237\345\256\207/.keep" diff --git "a/\351\273\204\351\224\237\345\256\207/.keep" "b/\351\273\204\351\224\237\345\256\207/.keep" new file mode 100644 index 0000000..e69de29 -- Gitee From 9c23badb7ea20b36f14527f40ae59a6c39cb489a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=96=E7=BA=B7?= <8332024+o2444091281@user.noreply.gitee.com> Date: Sun, 6 Jun 2021 18:52:02 +0800 Subject: [PATCH 43/74] 1 --- .../Father.cs" | 26 ++++ .../Machine.cs" | 32 +++++ .../Player.cs" | 45 ++++++ .../Program.cs" | 132 ++++++++++++++++++ 4 files changed, 235 insertions(+) create mode 100644 "\351\273\204\351\224\237\345\256\207/Father.cs" create mode 100644 "\351\273\204\351\224\237\345\256\207/Machine.cs" create mode 100644 "\351\273\204\351\224\237\345\256\207/Player.cs" create mode 100644 "\351\273\204\351\224\237\345\256\207/Program.cs" diff --git "a/\351\273\204\351\224\237\345\256\207/Father.cs" "b/\351\273\204\351\224\237\345\256\207/Father.cs" new file mode 100644 index 0000000..285bfe8 --- /dev/null +++ "b/\351\273\204\351\224\237\345\256\207/Father.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Father + { + private string name; + + public string Name { get => name; set => name = value; } + + public Father(string name) + { + this.name = name; + } + + public virtual void punch() + { + + } + + } +} diff --git "a/\351\273\204\351\224\237\345\256\207/Machine.cs" "b/\351\273\204\351\224\237\345\256\207/Machine.cs" new file mode 100644 index 0000000..09c9800 --- /dev/null +++ "b/\351\273\204\351\224\237\345\256\207/Machine.cs" @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + enum Fist + { + 石头 = 1, + 剪刀, + 布, + } + class Machine : Father + { + + public Machine(string name) : base(name) + { + this.Name = name; + } + public int punch() + { + Random random = new Random(); + int num = random.Next(1, 4); + Fist f = (Fist)num; + Console.WriteLine("{0},出拳:{1}", base.Name, f); + return num; + } + + } +} diff --git "a/\351\273\204\351\224\237\345\256\207/Player.cs" "b/\351\273\204\351\224\237\345\256\207/Player.cs" new file mode 100644 index 0000000..d8bd8f9 --- /dev/null +++ "b/\351\273\204\351\224\237\345\256\207/Player.cs" @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Player : Father + { + enum Fist + { + 石头 = 1, + 剪刀, + 布, + } + + + public Player(string name) : base(name) + { + this.Name = name; + } + + + public int punch() + { + Console.WriteLine("请出拳:{0}(请输入相应的数字)", ListFist()); + int choose = int.Parse(Console.ReadLine()); + Fist f = (Fist)choose; + Console.WriteLine("{0},出拳:{1}", base.Name, f); + return choose; + } + static string ListFist() + { + string fistString = " "; + int i = 1; + foreach (Fist f in Enum.GetValues(typeof(Fist))) + { + fistString += i + "、" + f + ";"; + i++; + } + return fistString; + } + } +} diff --git "a/\351\273\204\351\224\237\345\256\207/Program.cs" "b/\351\273\204\351\224\237\345\256\207/Program.cs" new file mode 100644 index 0000000..2378ae5 --- /dev/null +++ "b/\351\273\204\351\224\237\345\256\207/Program.cs" @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + enum MachineName + { + 刘备 = 1, + 孙权, + 曹操 + } + + class Program + { + + static void Main(string[] args) + + { + Console.WriteLine("-------------------欢迎进入游戏世界!---------------------"); + Console.WriteLine(); + Console.WriteLine(); + Console.WriteLine("=========================================================="); + Console.WriteLine("=====================猜拳!开始!========================="); + Console.WriteLine("=========================================================="); + + Console.WriteLine("出拳规则:1.石头 2.剪刀 3.布"); + Console.WriteLine(); + + Console.WriteLine("请输入您的姓名:"); + string playName = Console.ReadLine(); + Console.WriteLine("请选择对方角色 <1.刘备 2.孙权 3.曹操>"); + int choose1 = int.Parse(Console.ReadLine()); + MachineName f = (MachineName)choose1; + Machine machine = new Machine(f.ToString()); + + Player player = new Player(playName); + Console.WriteLine("{0} vs {1} 对战 !", playName, f); + Console.WriteLine("开始游戏吗?(y/n)"); + string YN = Console.ReadLine(); + + + if (YN.Equals("y")) + { + + int choose = player.punch(); + int num = machine.punch(); + int score=0; + int scoreM = 0; + int count=0; + judge(choose, num,ref score ,ref scoreM,ref count); + next(choose, num, player, machine,playName,f,score,count,scoreM); + Console.WriteLine(); + Console.WriteLine("============================================"); + Console.WriteLine("{0} vs {1} 对战 !", playName, f); + Console.WriteLine(); + } + else + { + Console.WriteLine("游戏已关闭!"); + } + + } + + private static void next(int choose, int num, Player player, Machine machine,string playName, MachineName f,int score,int count, int scoreM) + { + while (true) + { + + Console.WriteLine("是否要进行下一轮(y/n)"); + string YN2 = Console.ReadLine(); + if (YN2.Equals("y")) + { + choose = player.punch(); + num = machine.punch(); + judge(choose, num,ref score ,ref count,ref scoreM); + } + else + { + Console.WriteLine("============================================"); + Console.WriteLine("{0} vs {1} 对战 !", playName, f); + Console.WriteLine("对战次数{0}",count); + Console.WriteLine(); + Console.WriteLine("姓名 得分"); + Console.WriteLine("{0} {1}",playName, score); + Console.WriteLine("{0} {1}",f, scoreM); + if (score>scoreM) + { + Console.WriteLine("{0}赢,{1}笨蛋", playName, f); + } + if (score < scoreM) + { + Console.WriteLine("{0}赢,{1}笨蛋", f,playName); + } + if (score < scoreM) + { + Console.WriteLine("居然是平局!!!"); + } + // Console.WriteLine("要进行下一局吗(y/n)"); + next(choose, num, player, machine, playName, f, score, count, scoreM); + break; + } + } + } + + private static int judge(int choose, int num, ref int score, ref int count, ref int scoreM) + { + + + if (choose == 1 && num == 2 || choose == 2 && num == 3 || choose == 3 && num == 1) + { + Console.WriteLine("恭喜您,获胜了!"); + score++; + count++; + } + if (choose == 1 && num == 1 || choose == 2 && num == 2 || choose == 3 && num == 3) + { + Console.WriteLine("真可惜,平局!"); + count++; + } + if (choose == 2 && num == 1 || choose == 3 && num == 2 || choose == 1 && num == 3) + { + Console.WriteLine("哎哎哎,您输了!"); + scoreM++; + count++; + } + return score; + } + } +} -- Gitee From 539979db278c40518ff7135708e93ec0a78dbdaf Mon Sep 17 00:00:00 2001 From: Xtreme Date: Sun, 6 Jun 2021 20:28:23 +0800 Subject: [PATCH 44/74] =?UTF-8?q?=E9=BB=84=E6=9D=B0=E7=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\351\273\204\346\235\260\347\203\250/NPC.cs" | 22 ++++++ .../Play.cs" | 18 +++++ .../Program.cs" | 73 +++++++++++++++++++ .../caiquan.cs" | 63 ++++++++++++++++ 4 files changed, 176 insertions(+) create mode 100644 "\351\273\204\346\235\260\347\203\250/NPC.cs" create mode 100644 "\351\273\204\346\235\260\347\203\250/Play.cs" create mode 100644 "\351\273\204\346\235\260\347\203\250/Program.cs" create mode 100644 "\351\273\204\346\235\260\347\203\250/caiquan.cs" diff --git "a/\351\273\204\346\235\260\347\203\250/NPC.cs" "b/\351\273\204\346\235\260\347\203\250/NPC.cs" new file mode 100644 index 0000000..8419bdf --- /dev/null +++ "b/\351\273\204\346\235\260\347\203\250/NPC.cs" @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class NPC:Play + { + public string name { get; set; } + public NPC() { } + public NPC(string name) + { + this.name = name; + } + public string npcname() + { + return name; + } + } +} diff --git "a/\351\273\204\346\235\260\347\203\250/Play.cs" "b/\351\273\204\346\235\260\347\203\250/Play.cs" new file mode 100644 index 0000000..2d4a864 --- /dev/null +++ "b/\351\273\204\346\235\260\347\203\250/Play.cs" @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Play + { + public string Name { get; set; } + public Play() { } + public Play(string Name) + { + this.Name = Name; + } + } +} diff --git "a/\351\273\204\346\235\260\347\203\250/Program.cs" "b/\351\273\204\346\235\260\347\203\250/Program.cs" new file mode 100644 index 0000000..d431679 --- /dev/null +++ "b/\351\273\204\346\235\260\347\203\250/Program.cs" @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Program + { + static string b; + public enum Npc + { + 刘备 = 1, + 关羽, + 张飞 + } + public enum CQ + { + 剪刀 = 1, + 石头, + 布 + } + static void Main(string[] args) + { + one(); + } + + private static void one() + { + Console.WriteLine("-------------欢 迎 进 入 游 戏 世 界-------------"); + Console.WriteLine("*************************************************"); + Console.WriteLine("*******************猜 拳 开 始*******************"); + Console.WriteLine("*************************************************"); + Console.WriteLine("猜拳规则:1、剪刀,2、石头,3、布"); + Console.WriteLine("请选择对方角色:<1、刘备,2、关羽,3、张飞>"); + int a = int.Parse(Console.ReadLine()); + Npc n = (Npc)a; + Console.WriteLine("输入你的名字"); + b = Console.ReadLine(); + NPC npc = new NPC((n).ToString()); + Console.WriteLine(b + "VS" + npc.npcname() + "对战"); + Console.WriteLine("开始游戏吗(y/n)"); + string d = Console.ReadLine(); + switch (d) + { + case "y": + Console.WriteLine("请出拳:1、剪刀,2、石头,3、布"); + int e = int.Parse(Console.ReadLine()); + CQ CQ1 = (CQ)e; + Random r = new Random(); + int c = r.Next(3) + 1; + CQ CQ2 = (CQ)c; + Console.WriteLine(b + ":出拳:" + CQ1); + Console.WriteLine(npc.npcname () + " :出拳:" + CQ2); + caiquan cq = new caiquan(); + Play p = new Play(b); + cq.stjdb1 = ((CQ)e).ToString(); + cq.stjdb2 = ((CQ)c).ToString(); + cq.cq(); + one(); + break; + case "n": + one(); + break; + default: + Console.WriteLine("按错了!八嘎!"); + one(); + break; + } + } + } +} \ No newline at end of file diff --git "a/\351\273\204\346\235\260\347\203\250/caiquan.cs" "b/\351\273\204\346\235\260\347\203\250/caiquan.cs" new file mode 100644 index 0000000..526c533 --- /dev/null +++ "b/\351\273\204\346\235\260\347\203\250/caiquan.cs" @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class caiquan :NPC + { + public string stjdb1 { get; set; } + public string stjdb2 { get; set; } + + public void cq() + { + if (stjdb1.Equals("剪刀")) + { + if (stjdb2.Equals("剪刀")) + { + Console.WriteLine("和局,Again!"); + } + if (stjdb2.Equals("石头")) + { + Console.WriteLine("八嘎,你滴,输啦!"); + } + if (stjdb2.Equals("布")) + { + Console.WriteLine("呦西,良民大大滴!"); + } + } + if (stjdb1.Equals("石头")) + { + if (stjdb2.Equals("剪刀")) + { + Console.WriteLine("呦西,良民大大滴!"); + } + if (stjdb2.Equals("石头")) + { + Console.WriteLine("和局,Again!"); + } + if (stjdb2.Equals("布")) + { + Console.WriteLine("八嘎,你滴,输啦!"); + } + } + if (stjdb1.Equals("布")) + { + if (stjdb2.Equals("剪刀")) + { + Console.WriteLine("八嘎,你滴,输啦!"); + } + if (stjdb2.Equals("石头")) + { + Console.WriteLine("呦西,良民大大滴!"); + } + if (stjdb2.Equals("布")) + { + Console.WriteLine("和局,Again!"); + } + } + } + } +} -- Gitee From 8a990f7028a6831e9a25fbbe0abc51f71d6eabee Mon Sep 17 00:00:00 2001 From: meng-lingkun <1725116698@qq.com> Date: Sun, 6 Jun 2021 20:38:26 +0800 Subject: [PATCH 45/74] asads --- .../Judgment.cs" | 12 ++ .../NPCName.cs" | 19 ++ .../Player.cs" | 18 ++ .../Program.cs" | 169 ++++++++++++++++++ .../Role.cs" | 17 ++ 5 files changed, 235 insertions(+) create mode 100644 "\345\255\237\344\273\244\345\235\244/Judgment.cs" create mode 100644 "\345\255\237\344\273\244\345\235\244/NPCName.cs" create mode 100644 "\345\255\237\344\273\244\345\235\244/Player.cs" create mode 100644 "\345\255\237\344\273\244\345\235\244/Program.cs" create mode 100644 "\345\255\237\344\273\244\345\235\244/Role.cs" diff --git "a/\345\255\237\344\273\244\345\235\244/Judgment.cs" "b/\345\255\237\344\273\244\345\235\244/Judgment.cs" new file mode 100644 index 0000000..b277855 --- /dev/null +++ "b/\345\255\237\344\273\244\345\235\244/Judgment.cs" @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Judgment: Role + { + } +} diff --git "a/\345\255\237\344\273\244\345\235\244/NPCName.cs" "b/\345\255\237\344\273\244\345\235\244/NPCName.cs" new file mode 100644 index 0000000..eb9f442 --- /dev/null +++ "b/\345\255\237\344\273\244\345\235\244/NPCName.cs" @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class NPCName:Role + { + Random ran = new Random(); + public override int PrintFrist() + { + + return ran.Next(1, 4); + + } + } +} diff --git "a/\345\255\237\344\273\244\345\235\244/Player.cs" "b/\345\255\237\344\273\244\345\235\244/Player.cs" new file mode 100644 index 0000000..d23a1de --- /dev/null +++ "b/\345\255\237\344\273\244\345\235\244/Player.cs" @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Player: Role + { + public override int PrintFrist() + { + int num = int.Parse(Console.ReadLine()); + return num; + } + + } +} diff --git "a/\345\255\237\344\273\244\345\235\244/Program.cs" "b/\345\255\237\344\273\244\345\235\244/Program.cs" new file mode 100644 index 0000000..8fc8c17 --- /dev/null +++ "b/\345\255\237\344\273\244\345\235\244/Program.cs" @@ -0,0 +1,169 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + + public enum Nameenum + { + 刘备 = 1, + 孙权, + 曹操 + } + public enum Punch + { + 石头 = 1, + 剪刀, + 布 + } + class Program + { + static int count = 0; + static int pCount = 0; + static int nCount = 0; + static Player p = new Player(); + static NPCName nPC = new NPCName(); + static Judgment jd = new Judgment(); + static void Main(string[] args) + { + Totalmethod(); + + } + + private static void Totalmethod() + { + Welcome(); + Spanme(); + Batlle(); + Result(); + } + + static void Spanme() + { + while (true) + { + Console.WriteLine("出拳规则:{0}", ListPunch()); + Console.WriteLine("请选择对方角色:{0}",ListNPC()); + string cname = Console.ReadLine(); + Console.WriteLine("请输入您的姓名:"); + string bname = Console.ReadLine(); + Console.WriteLine("{0}VS{1} 对战"); + Console.WriteLine("是否开始游戏(y/n)"); + string a = Console.ReadLine(); + if (a == "y") + { + break; + } + } + } + static void Batlle() + { + while (true) + { + Console.WriteLine("请出拳:{0}(输入相对应得数字)", ListPunch()); + int pf = p.PrintFrist(); + int nf = nPC.PrintFrist(); + Console.WriteLine("{0}出:{1}", p.Name, (Punch)pf); + Console.WriteLine("{0}出:{1}", nPC.Name, (Punch)nf); + int result = IsWin(pf, nf); + + Console.WriteLine(); + Console.WriteLine(result == 0 ? "和局!" : result == 1 ? $"恭喜!{p.Name}赢了!" : $"呃呃!{p.Name}输了!"); + + count++; + if (result == 1) + { + pCount++; + } + else if (result == -1) + { + nCount++; + } + + Console.WriteLine("\r\n是否开始下一轮?(y/n)"); + string key = Console.ReadLine(); + if (key != "y") + { + break; + } + } + + } + static void Result() + { + Console.WriteLine("\r\n==============================================="); + Console.WriteLine("{0}VS{1}",p.Name,nPC.Name); + Console.WriteLine("对战次数:{0}",count); + Console.WriteLine("姓名\t得分"); + Console.WriteLine("{0}\t{1}",p.Name,pCount); + Console.WriteLine("{0}\t{1}",nPC.Name,nCount); + Console.WriteLine("平局\t{0}",count-pCount-nCount); + Console.WriteLine("结果:"+(pCount >nCount ? p.Name:nPC.Name)+"赢了!!!!"); + Console.WriteLine("要开始下一句吗(y/n)"); + string key = Console.ReadLine(); + if (key == "y") + { + count = 0; + pCount = 0; + nCount = 0; + Totalmethod(); + } + else + { + Console.WriteLine("系统退出"); + } + } + + private static int IsWin(int pf, int nf) + { + if (pf == nf) + { + return 0; + } + else if (pf == 1 && nf == 2||pf == 2 && nf ==3||pf == 3 && nf == 1) + { + return 1; + } + else + { + return -1; + } + } + + static string ListPunch() + { + string punchString = " "; + int i = 1; + foreach (Punch n in Enum.GetValues(typeof(Punch))) + { + punchString += i + "、" + n + ";"; + i++; + + } + return punchString; + } + + static void Welcome() + { + Console.WriteLine("---------欢迎进入游戏世界----------------------\r\n"); + Console.WriteLine("**********************************************"); + Console.WriteLine("*****************猜拳,开始*******************"); + Console.WriteLine("**********************************************"); + } + + static string ListNPC() + { + string roleStr = ""; + foreach (Nameenum n in Enum.GetValues(typeof(Nameenum))) + { + roleStr += (int)n + "、" + n + ";"; + } + return roleStr; + } + + } +} + diff --git "a/\345\255\237\344\273\244\345\235\244/Role.cs" "b/\345\255\237\344\273\244\345\235\244/Role.cs" new file mode 100644 index 0000000..5d3cdb1 --- /dev/null +++ "b/\345\255\237\344\273\244\345\235\244/Role.cs" @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Role + { + public string Name { get; set; } + public virtual int PrintFrist() + { + return 0; + } + } +} -- Gitee From e30629c2e8660c69d9551a676505f2176aa61307 Mon Sep 17 00:00:00 2001 From: li <2811189126@qq.com> Date: Sun, 6 Jun 2021 20:59:32 +0800 Subject: [PATCH 46/74] 6.6 --- .../Father.cs" | 25 ++ .../Gamepeople.cs" | 23 ++ .../Oberpeople.cs" | 23 ++ .../Program.cs" | 214 ++++++++++++++++++ 4 files changed, 285 insertions(+) create mode 100644 "\346\235\216\345\272\206\346\211\215/Father.cs" create mode 100644 "\346\235\216\345\272\206\346\211\215/Gamepeople.cs" create mode 100644 "\346\235\216\345\272\206\346\211\215/Oberpeople.cs" create mode 100644 "\346\235\216\345\272\206\346\211\215/Program.cs" diff --git "a/\346\235\216\345\272\206\346\211\215/Father.cs" "b/\346\235\216\345\272\206\346\211\215/Father.cs" new file mode 100644 index 0000000..49096fa --- /dev/null +++ "b/\346\235\216\345\272\206\346\211\215/Father.cs" @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp23 +{ + abstract class Father + { + public static string[] fist = { "石头", "剪刀", "布" }; + + + private string name; + public string Name { get => name; set => name = value; } + + + + public Father(string Name) + { + this.name = Name; + } + public abstract void Play(); + } +} diff --git "a/\346\235\216\345\272\206\346\211\215/Gamepeople.cs" "b/\346\235\216\345\272\206\346\211\215/Gamepeople.cs" new file mode 100644 index 0000000..0223b7a --- /dev/null +++ "b/\346\235\216\345\272\206\346\211\215/Gamepeople.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp23 +{ + class Gamepeople : Father + { + public string fisttype; + public static int gamescore; + public Gamepeople(string Name) : base(Name) { } + + + + + public override void Play() + { + Console.WriteLine(base.Name + ":" + " 出拳:" + this.fisttype); + } + } +} diff --git "a/\346\235\216\345\272\206\346\211\215/Oberpeople.cs" "b/\346\235\216\345\272\206\346\211\215/Oberpeople.cs" new file mode 100644 index 0000000..44710c0 --- /dev/null +++ "b/\346\235\216\345\272\206\346\211\215/Oberpeople.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp23 +{ + class Oberpeople : Father + { + + public static string fistname; + public static int oberscore; + public Oberpeople(string Name) : base(Name) { } + + public Random random = new Random(); + public override void Play() + { + fistname = fist[random.Next(0, 3)]; + Console.WriteLine(base.Name + ":" + " 出拳:" + fistname); + } + } +} diff --git "a/\346\235\216\345\272\206\346\211\215/Program.cs" "b/\346\235\216\345\272\206\346\211\215/Program.cs" new file mode 100644 index 0000000..eb669ff --- /dev/null +++ "b/\346\235\216\345\272\206\346\211\215/Program.cs" @@ -0,0 +1,214 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp23 +{ + class Program + { + + static Gamepeople gone; + static Oberpeople gtwo; + static Boolean TorF = false; + static int c = 0; + static string Gamename; + + static void Main(string[] args) + { + Game(); + } + static void ChooseOber() + { + if (c == 1) + { + Gamename = "刘备"; + } + else if (c == 2) + { + Gamename = "孙权"; + } + else if (c == 3) + { + Gamename = "曹操"; + } + Console.WriteLine("请输入您的姓名:"); + string GameName = Console.ReadLine(); + gone = new Gamepeople(GameName); + gtwo = new Oberpeople(Gamename); + Console.WriteLine(gone.Name + " VS " + gtwo.Name + " 对战"); + + Console.WriteLine("开始游戏吗?"); + string numo = Console.ReadLine(); + if (numo == "y") + { + Start(); + } + else + { + Console.WriteLine("已退出!!!"); + } + } + static void Game() + { + Console.WriteLine("---------------------欢迎进入游戏世界-----------------------\n\n\n"); + Console.WriteLine("**************************\n********猜拳,开始********\n**************************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Console.WriteLine("请选择对方角色<1:刘备 2:孙权 3:曹操>"); + int num = Convert.ToInt32(Console.ReadLine()); + + switch (num) + { + case 1: + c = 1; + ChooseOber(); + break; + case 2: + c = 2; + ChooseOber(); + break; + case 3: + c = 3; + ChooseOber(); + break; + default: + Console.WriteLine("输入名字错误,请重新进入游戏!!"); + Game(); + break; + } + } + static void EndScore() + { + Console.WriteLine("============================================================="); + Console.WriteLine("姓名 " + " 得分"); + Console.WriteLine(gone.Name + "\t \t" + Gamepeople.gamescore); + Console.WriteLine(gtwo.Name + "\t \t" + Oberpeople.oberscore); + if (Gamepeople.gamescore > Oberpeople.oberscore) + { + Console.WriteLine("结果:" + gone.Name + "赢," + gtwo.Name + "笨蛋"); + } + else if (Gamepeople.gamescore == Oberpeople.oberscore) + { + Console.WriteLine("平局了!!!"); + } + else + { + Console.WriteLine("结果:" + gtwo.Name + "赢," + gone.Name + "笨蛋"); + } + } + static void AgainStart() + { + + if (TorF == true) + { + Console.WriteLine("要开始下一局吗?(y/n)"); + string numo = Console.ReadLine(); + if (numo == "y") + { + Game(); + } + else + { + Console.WriteLine("系统退出!"); + } + } + else + { + Console.WriteLine("是否要开始下一轮?"); + string numo = Console.ReadLine(); + + if (numo == "y") + { + Start(); + } + else + { + EndScore(); + Console.WriteLine("退出!"); + + } + } + } + static void Start() + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应数字:)"); + int num2 = Convert.ToInt32(Console.ReadLine()); + switch (num2) + { + case 1: + gone.fisttype = "剪刀"; + Say(); + break; + case 2: + gone.fisttype = "石头"; + Say(); + break; + case 3: + gone.fisttype = "布"; + Say(); + break; + default: + break; + } + Win(); + AgainStart(); + + } + static void Win() + { + if (gone.fisttype == "剪刀" && Oberpeople.fistname == "剪刀") + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + else if (gone.fisttype == "剪刀" && Oberpeople.fistname == "石头") + { + Console.WriteLine("笨蛋," + gone.Name + "输了"); + Oberpeople.oberscore++; + } + else if (gone.fisttype == "剪刀" && Oberpeople.fistname == "布") + { + Console.WriteLine("恭喜," + gone.Name + "赢了"); + Gamepeople.gamescore++; + } + else if (gone.fisttype == "石头" && Oberpeople.fistname == "石头") + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + else if (gone.fisttype == "石头" && Oberpeople.fistname == "布") + { + Console.WriteLine("笨蛋," + gone.Name + "输了"); + Oberpeople.oberscore++; + } + else if (gone.fisttype == "石头" && Oberpeople.fistname == "剪刀") + { + Console.WriteLine("恭喜," + gone.Name + "赢了"); + Gamepeople.gamescore++; + } + else if (gone.fisttype == "布" && Oberpeople.fistname == "布") + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + else if (gone.fisttype == "布" && Oberpeople.fistname == "剪刀") + { + Console.WriteLine("笨蛋," + gone.Name + "输了"); + Oberpeople.oberscore++; + } + else if (gone.fisttype == "布" && Oberpeople.fistname == "石头") + { + Console.WriteLine("恭喜," + gone.Name + "赢了"); + Gamepeople.gamescore++; + } + else + { + Console.WriteLine(" "); + } + AgainStart(); + } + static void Say() + { + gone.Play(); + gtwo.Play(); + } + } +} -- Gitee From 6c6dcdd1c47083a9bca9ab25d344f3c0377aaae0 Mon Sep 17 00:00:00 2001 From: Chenxuqing <8332101+W1902774261@user.noreply.gitee.com> Date: Sun, 6 Jun 2021 21:37:39 +0800 Subject: [PATCH 47/74] =?UTF-8?q?=E9=99=88=E6=97=AD=E6=B8=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../JudgeMan.cs" | 12 ++ .../NPCMan.cs" | 17 ++ .../Player.cs" | 18 ++ .../Program.cs" | 170 ++++++++++++++++++ .../Role.cs" | 17 ++ 5 files changed, 234 insertions(+) create mode 100644 "\351\231\210\346\227\255\346\270\205/JudgeMan.cs" create mode 100644 "\351\231\210\346\227\255\346\270\205/NPCMan.cs" create mode 100644 "\351\231\210\346\227\255\346\270\205/Player.cs" create mode 100644 "\351\231\210\346\227\255\346\270\205/Program.cs" create mode 100644 "\351\231\210\346\227\255\346\270\205/Role.cs" diff --git "a/\351\231\210\346\227\255\346\270\205/JudgeMan.cs" "b/\351\231\210\346\227\255\346\270\205/JudgeMan.cs" new file mode 100644 index 0000000..f1079dd --- /dev/null +++ "b/\351\231\210\346\227\255\346\270\205/JudgeMan.cs" @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Class +{ + class JudgeMan : Role + { + } +} diff --git "a/\351\231\210\346\227\255\346\270\205/NPCMan.cs" "b/\351\231\210\346\227\255\346\270\205/NPCMan.cs" new file mode 100644 index 0000000..6e95007 --- /dev/null +++ "b/\351\231\210\346\227\255\346\270\205/NPCMan.cs" @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Class +{ + class NPCMan:Role + { + Random ran = new Random(); + public override int ShowFist() + { + return ran.Next(1, 4); + } + } +} diff --git "a/\351\231\210\346\227\255\346\270\205/Player.cs" "b/\351\231\210\346\227\255\346\270\205/Player.cs" new file mode 100644 index 0000000..e0ad0d0 --- /dev/null +++ "b/\351\231\210\346\227\255\346\270\205/Player.cs" @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Class +{ + class Player:Role + { + public override int ShowFist() + { + int num = int.Parse(Console.ReadLine()); + + return num; + } + } +} diff --git "a/\351\231\210\346\227\255\346\270\205/Program.cs" "b/\351\231\210\346\227\255\346\270\205/Program.cs" new file mode 100644 index 0000000..f6e8e88 --- /dev/null +++ "b/\351\231\210\346\227\255\346\270\205/Program.cs" @@ -0,0 +1,170 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Class +{ + public enum NPCRole + { + 刘备 = 1, + 孙权 = 2, + 曹操 = 3 + } + public enum Fist + { + 石头 = 1, + 剪刀 = 2, + 布 = 3 + } + class Program + { + static JudgeMan jm = new JudgeMan(); + static Player p = new Player(); + static NPCMan npc = new NPCMan(); + static int count = 0; + static int pCount = 0; + static int nCount = 0; + + static void Main(string[] args) + { + PlayFistGame(); + } + + private static void PlayFistGame() + { + Welcome(); + Prepare(); + Battle(); + ShowResult(); + } + + private static void Welcome() + { + Console.WriteLine("====================欢 迎 进 入 游 戏 世 界====================\r\n"); + Console.WriteLine("************************************"); + Console.WriteLine("*************猜拳,开始*************"); + Console.WriteLine("************************************\r\n"); + } + + private static void Prepare() + { + while (true) + { + Console.WriteLine("出拳规则:{0}", ListFist()); ; + Console.WriteLine("请选择对方角色:{0}", ListNPC()); + int num = int.Parse(Console.ReadLine()); + npc.Name = ((NPCRole)num).ToString(); + + Console.WriteLine("请输入您的姓名:"); + p.Name = Console.ReadLine(); + + Console.WriteLine("{0} VS {1} 对战", p.Name, npc.Name); + Console.WriteLine("开始游戏吗?(y/n)"); + string key = Console.ReadLine(); + if (key == "y") + { + break; + } + } + } + + private static void Battle() + { + while (true) + { + Console.WriteLine("\n\r请出拳:{0}", ListFist()); + int pf = p.ShowFist(); + int nf = npc.ShowFist(); + Console.WriteLine("\r\n{0} 出: {1}", p.Name, (Fist)pf); + Console.WriteLine("{0} 出: {1}", npc.Name, (Fist)nf); + int result = IsWin(pf, nf); + + Console.WriteLine(); + Console.WriteLine(result == 0 ? "和局!" : result == 1 ? $"恭喜!{p.Name}赢了!" : $"呃呃!{p.Name}输了!"); + + count++; + if (result == 1) + { + pCount++; + } + else if (result == -1) + { + nCount++; + } + + Console.WriteLine("\r\n是否开始下一轮?(y/n)"); + string key = Console.ReadLine(); + if (key != "y") + { + break; + } + } + } + + static void ShowResult() + { + Console.WriteLine("\r\n\r\n\r\n\r\n\r\n\r\n===================================================="); + Console.WriteLine("{0} VS {1}", p.Name, npc.Name); + Console.WriteLine("对战次数:{0}", count); + Console.WriteLine("姓名\t得分"); + Console.WriteLine("{0}\t{1}", p.Name, pCount); + Console.WriteLine("{0}\t{1}", npc.Name, nCount); + Console.WriteLine("和局\t{0}", count - nCount - pCount); + Console.WriteLine("总结果:" + (pCount > nCount ? p.Name : npc.Name) + "赢了!"); + Console.WriteLine("是否开始下一局?(y/n)"); + string key = Console.ReadLine(); + if (key == "y") + { + count = 0; + pCount = 0; + nCount = 0; + PlayFistGame(); + } + else + { + Console.WriteLine("系统退出!"); + } + } + + + + private static int IsWin(int pf, int nf) + { + if (pf == nf) + { + return 0; + } + else if (pf == 1 && nf == 2 || pf == 2 && nf == 3 || pf == 3 && nf == 1) + { + return 1; + } + else + { + return -1; + } + } + + static string ListFist() + { + string fistStr = ""; + foreach (Fist f in Enum.GetValues(typeof(Fist))) + { + fistStr += (int)f + "、" + f + ";"; + } + return fistStr; + } + + static string ListNPC() + { + string roleStr = ""; + foreach (NPCRole n in Enum.GetValues(typeof(NPCRole))) + { + roleStr += (int)n + "、" + n + ";"; + } + return roleStr; + } + + } +} diff --git "a/\351\231\210\346\227\255\346\270\205/Role.cs" "b/\351\231\210\346\227\255\346\270\205/Role.cs" new file mode 100644 index 0000000..a8f41e4 --- /dev/null +++ "b/\351\231\210\346\227\255\346\270\205/Role.cs" @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Class +{ + class Role + { + public string Name { get; set; } + public virtual int ShowFist() + { + return 0; + } + } +} -- Gitee From 56f8de645fd396fc2920527ddcbcc0136b7078e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B5=A9=E5=AE=87?= <1130029615@qq.com> Date: Sun, 6 Jun 2021 21:44:12 +0800 Subject: [PATCH 48/74] =?UTF-8?q?=E6=96=B0=E5=BB=BA=20=E9=99=88=E6=B5=A9?= =?UTF-8?q?=E5=AE=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\351\231\210\346\265\251\345\256\207/.keep" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "\351\231\210\346\265\251\345\256\207/.keep" diff --git "a/\351\231\210\346\265\251\345\256\207/.keep" "b/\351\231\210\346\265\251\345\256\207/.keep" new file mode 100644 index 0000000..e69de29 -- Gitee From 58d0cbe55f7ae6277c5493d68213ec42a38ffef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B5=A9=E5=AE=87?= <1130029615@qq.com> Date: Sun, 6 Jun 2021 21:44:51 +0800 Subject: [PATCH 49/74] 1 --- .../NPCman.cs" | 17 ++ .../Player.cs" | 17 ++ .../Program.cs" | 148 ++++++++++++++++++ .../Role.cs" | 18 +++ 4 files changed, 200 insertions(+) create mode 100644 "\351\231\210\346\265\251\345\256\207/NPCman.cs" create mode 100644 "\351\231\210\346\265\251\345\256\207/Player.cs" create mode 100644 "\351\231\210\346\265\251\345\256\207/Program.cs" create mode 100644 "\351\231\210\346\265\251\345\256\207/Role.cs" diff --git "a/\351\231\210\346\265\251\345\256\207/NPCman.cs" "b/\351\231\210\346\265\251\345\256\207/NPCman.cs" new file mode 100644 index 0000000..7ddbc8d --- /dev/null +++ "b/\351\231\210\346\265\251\345\256\207/NPCman.cs" @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp7 +{ + class NPCman:Role + { + Random ran = new Random(); + public override int ShowFist() + { + return ran.Next(1, 4); + } + } +} diff --git "a/\351\231\210\346\265\251\345\256\207/Player.cs" "b/\351\231\210\346\265\251\345\256\207/Player.cs" new file mode 100644 index 0000000..5ae6872 --- /dev/null +++ "b/\351\231\210\346\265\251\345\256\207/Player.cs" @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp7 +{ + class Player:Role + { + public override int ShowFist() + { + int num = int.Parse(Console.ReadLine()); + return num; + } + } +} diff --git "a/\351\231\210\346\265\251\345\256\207/Program.cs" "b/\351\231\210\346\265\251\345\256\207/Program.cs" new file mode 100644 index 0000000..42c0066 --- /dev/null +++ "b/\351\231\210\346\265\251\345\256\207/Program.cs" @@ -0,0 +1,148 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp7 +{ + public enum Fist + { + 石头=1, + 剪刀=2, + 布=3 + } + public enum NPCRole + { + 刘备=1, + 孙权=2, + 曹操=3 + } + + class Program + { + static NPCman npc = new NPCman(); + static Player p = new Player(); + static int count = 0; + static int pCount = 0; + static int nCount = 0; + + static void Main(string[] args) + { + PlayGame(); + } + + private static void PlayGame() + { + Welcome(); + Prepare(); + Battle(); + ShowResult(); + } + + private static void Welcome() + { + Console.WriteLine("====================欢 迎 进 入 游 戏 世 界====================\r\n"); + Console.WriteLine("************************************"); + Console.WriteLine("*************猜拳,开始*************"); + Console.WriteLine("************************************\r\n"); + } + private static void Prepare() + { + while (true) + { + Console.WriteLine("出拳规则:{0}", ListFist()); ; + Console.WriteLine("请选择对方角色:{0}", ListNPC()); + int num = int.Parse(Console.ReadLine()); + npc.Name = ((NPCRole)num).ToString(); + Console.WriteLine("请输入您的姓名:"); + p.Name = Console.ReadLine(); + Console.WriteLine("{0} VS {1} 对战", p.Name, npc.Name); + Console.WriteLine("开始游戏吗?(y/n)"); + string key = Console.ReadLine(); + if (key == "y") + { + break; + } + } + + } + private static void Battle() + { + while (true) + { + Console.WriteLine("\n\r请出拳:{0}", ListFist()); + int pf = p.ShowFist(); + int nf = npc.ShowFist(); + Console.WriteLine("\r\n{0} 出: {1}", p.Name, (Fist)pf); + Console.WriteLine("{0} 出: {1}", npc.Name, (Fist)nf); + int result = IsWin(pf, nf); + Console.WriteLine(); + + Console.WriteLine(result == 0 ? "和局!" : result == 1 ? $"恭喜!{p.Name}赢了!" : $"hhh!{p.Name}输了!"); + + } + } + + private static void ShowResult() + { + Console.WriteLine("\r\n\r\n\r\n\r\n\r\n\r\n===================================================="); + Console.WriteLine("{0} VS {1}", p.Name, npc.Name); + Console.WriteLine("对战次数:{0}", count); + Console.WriteLine("姓名\t得分"); + Console.WriteLine("{0}\t{1}", p.Name, pCount); + Console.WriteLine("{0}\t{1}", npc.Name, nCount); + Console.WriteLine("和局\t{0}", count - nCount - pCount); + Console.WriteLine("总结果:" + (pCount > nCount ? p.Name : npc.Name) + "赢了!"); + Console.WriteLine("是否开始下一局?(y/n)"); + string key = Console.ReadLine(); + if (key == "y") + { + count = 0; + pCount = 0; + nCount = 0; + PlayGame(); + } + else + { + Console.WriteLine("系统退出!"); + } + } + + private static int IsWin(int pf, int nf) + { + if (pf == nf) + { + return 0; + } + else if (pf == 1 && nf == 2 || pf == 2 && nf == 3 || pf == 3 && nf == 1) + { + return 1; + } + else + { + return -1; + } + } + static string ListNPC() + { + string roleStr = ""; + foreach (NPCRole n in Enum.GetValues(typeof(NPCRole))) + { + roleStr += (int)n + "、" + n + ";"; + } + return roleStr; + } + + static string ListFist() + { + string fiststr = " "; + foreach (Fist f in Enum.GetValues(typeof(Fist))) + { + fiststr += (int)f + "、" + f + ";"; + } + return fiststr; + + } + } +} diff --git "a/\351\231\210\346\265\251\345\256\207/Role.cs" "b/\351\231\210\346\265\251\345\256\207/Role.cs" new file mode 100644 index 0000000..370de23 --- /dev/null +++ "b/\351\231\210\346\265\251\345\256\207/Role.cs" @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp7 +{ + class Role + { + public string Name { get; set; } + + public virtual int ShowFist() + { + return 0; + } + } +} -- Gitee From 93de28824a71042953209d47353c1152e1192acb Mon Sep 17 00:00:00 2001 From: ling <1271919148@qq.com> Date: Sun, 6 Jun 2021 21:58:54 +0800 Subject: [PATCH 50/74] first commit --- .../Father.cs" | 26 +++ .../Gamepeople.cs" | 23 ++ .../Oberpeople.cs" | 23 ++ .../Program.cs" | 206 ++++++++++++++++++ 4 files changed, 278 insertions(+) create mode 100644 "\345\207\214\347\204\225\344\270\232/Father.cs" create mode 100644 "\345\207\214\347\204\225\344\270\232/Gamepeople.cs" create mode 100644 "\345\207\214\347\204\225\344\270\232/Oberpeople.cs" create mode 100644 "\345\207\214\347\204\225\344\270\232/Program.cs" diff --git "a/\345\207\214\347\204\225\344\270\232/Father.cs" "b/\345\207\214\347\204\225\344\270\232/Father.cs" new file mode 100644 index 0000000..efee503 --- /dev/null +++ "b/\345\207\214\347\204\225\344\270\232/Father.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + + +namespace ConsoleApp1 +{ + abstract class Father + { + public static string[] fist ={ "石头","剪刀","布" }; + + + private string name; + public string Name { get => name; set => name = value; } + + + + public Father(string Name) + { + this.name = Name; + } + public abstract void Play(); + } +} diff --git "a/\345\207\214\347\204\225\344\270\232/Gamepeople.cs" "b/\345\207\214\347\204\225\344\270\232/Gamepeople.cs" new file mode 100644 index 0000000..38bb682 --- /dev/null +++ "b/\345\207\214\347\204\225\344\270\232/Gamepeople.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Gamepeople:Father + { + public string fisttype; + public static int gamescore; + public Gamepeople(string Name):base(Name) {} + + + + + public override void Play() + { + Console.WriteLine(base.Name + ":" + " 出拳:" +this.fisttype); + } + } +} diff --git "a/\345\207\214\347\204\225\344\270\232/Oberpeople.cs" "b/\345\207\214\347\204\225\344\270\232/Oberpeople.cs" new file mode 100644 index 0000000..705996f --- /dev/null +++ "b/\345\207\214\347\204\225\344\270\232/Oberpeople.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Oberpeople:Father + { + + public static string fistname; + public static int oberscore; + public Oberpeople(string Name) : base(Name) { } + + public Random random = new Random(); + public override void Play() + { + fistname = fist[random.Next(0, 3)]; + Console.WriteLine(base.Name+":"+" 出拳:"+ fistname); + } + } +} diff --git "a/\345\207\214\347\204\225\344\270\232/Program.cs" "b/\345\207\214\347\204\225\344\270\232/Program.cs" new file mode 100644 index 0000000..1459592 --- /dev/null +++ "b/\345\207\214\347\204\225\344\270\232/Program.cs" @@ -0,0 +1,206 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Program + { + + static Gamepeople gone; + static Oberpeople gtwo; + static Boolean TorF=false; + static int c = 0; + static string Gamename; + + static void Main(string[] args) + { + Game(); + } + static void ChooseOber() { + if (c == 1) + { + Gamename = "刘备"; + } + else if (c == 2) + { + Gamename = "孙权"; + } + else if (c == 3) + { + Gamename = "曹操"; + } + Console.WriteLine("请输入您的姓名:"); + string GameName = Console.ReadLine(); + gone = new Gamepeople(GameName); + gtwo = new Oberpeople(Gamename); + Console.WriteLine(gone.Name + " VS " + gtwo.Name + " 对战"); + + Console.WriteLine("开始游戏吗?"); + string numo = Console.ReadLine(); + if (numo == "y") + { + Start(); + } + else + { + Console.WriteLine("已退出!!!"); + } + } + static void Game(){ + Console.WriteLine("---------------------欢迎进入游戏世界-----------------------\n\n\n"); + Console.WriteLine("**************************\n********猜拳,开始********\n**************************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Console.WriteLine("请选择对方角色<1:刘备 2:孙权 3:曹操>"); + int num = Convert.ToInt32(Console.ReadLine()); + + switch (num) + { + case 1: + c = 1; + ChooseOber(); + break; + case 2: + c = 2; + ChooseOber(); + break; + case 3: + c = 3; + ChooseOber(); + break; + default: + Console.WriteLine("输入名字错误,请重新进入游戏!!"); + Game(); + break; + } + } + static void EndScore() { + Console.WriteLine("============================================================="); + Console.WriteLine("姓名 " + " 得分"); + Console.WriteLine(gone.Name + "\t \t"+Gamepeople.gamescore); + Console.WriteLine(gtwo.Name + "\t \t" + Oberpeople.oberscore); + if (Gamepeople.gamescore > Oberpeople.oberscore) + { + Console.WriteLine("结果:" + gone.Name + "赢," + gtwo.Name + "笨蛋"); + } + else if (Gamepeople.gamescore == Oberpeople.oberscore) + { + Console.WriteLine("平局,都不太行!!!"); + } + else + { + Console.WriteLine("结果:" + gtwo.Name + "赢," + gone.Name + "笨蛋"); + } + } + static void AgainStart() { + + if (TorF == true) + { + Console.WriteLine("要开始下一局吗?(y/n)"); + string numo = Console.ReadLine(); + if (numo == "y") + { + Game(); + } + else + { + Console.WriteLine("系统退出!"); + } + } + else { + Console.WriteLine("是否要开始下一轮?"); + string numo = Console.ReadLine(); + + if (numo == "y") + { + Start(); + } + else + { + EndScore(); + Console.WriteLine("退出!"); + + } + } + } + static void Start() { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应数字:)"); + int num2 = Convert.ToInt32(Console.ReadLine()); + switch (num2) + { + case 1: + gone.fisttype = "剪刀"; + Say(); + break; + case 2: + gone.fisttype = "石头"; + Say(); + break; + case 3: + gone.fisttype = "布"; + Say(); + break; + default: + break; + } + Win(); + AgainStart(); + + } + static void Win() { + if (gone.fisttype == "剪刀" && Oberpeople.fistname == "剪刀") + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + else if (gone.fisttype == "剪刀" && Oberpeople.fistname == "石头") + { + Console.WriteLine("笨蛋," + gone.Name + "输了"); + Oberpeople.oberscore++; + } + else if (gone.fisttype == "剪刀" && Oberpeople.fistname == "布") + { + Console.WriteLine("恭喜," + gone.Name + "赢了"); + Gamepeople.gamescore++; + } + else if (gone.fisttype == "石头" && Oberpeople.fistname == "石头") + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + else if (gone.fisttype == "石头" && Oberpeople.fistname == "布") + { + Console.WriteLine("笨蛋," + gone.Name + "输了"); + Oberpeople.oberscore++; + } + else if (gone.fisttype == "石头" && Oberpeople.fistname == "剪刀") + { + Console.WriteLine("恭喜," + gone.Name + "赢了"); + Gamepeople.gamescore++; + } + else if (gone.fisttype == "布" && Oberpeople.fistname == "布") + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + else if (gone.fisttype == "布" && Oberpeople.fistname == "剪刀") + { + Console.WriteLine("笨蛋," + gone.Name + "输了"); + Oberpeople.oberscore++; + } + else if (gone.fisttype == "布" && Oberpeople.fistname == "石头") + { + Console.WriteLine("恭喜," + gone.Name + "赢了"); + Gamepeople.gamescore++; + } + else + { + Console.WriteLine("我是谁?我在哪?"); + } + AgainStart(); + } + static void Say() { + gone.Play(); + gtwo.Play(); + } + } +} -- Gitee From 3675a30b8ee552e84298079353a5dc0434bfecca Mon Sep 17 00:00:00 2001 From: yu-sijie <1609873552@qq.com> Date: Sun, 6 Jun 2021 21:59:40 +0800 Subject: [PATCH 51/74] =?UTF-8?q?VS-14--6.6(=E7=8C=9C=E6=8B=B3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Player.cs" | 173 ++++++++++++++++++ .../Program.cs" | 26 +++ .../Robot.cs" | 43 +++++ .../Solo.cs" | 63 +++++++ 4 files changed, 305 insertions(+) create mode 100644 "\344\275\231\346\200\235\346\235\260/Player.cs" create mode 100644 "\344\275\231\346\200\235\346\235\260/Program.cs" create mode 100644 "\344\275\231\346\200\235\346\235\260/Robot.cs" create mode 100644 "\344\275\231\346\200\235\346\235\260/Solo.cs" diff --git "a/\344\275\231\346\200\235\346\235\260/Player.cs" "b/\344\275\231\346\200\235\346\235\260/Player.cs" new file mode 100644 index 0000000..b7f8bf4 --- /dev/null +++ "b/\344\275\231\346\200\235\346\235\260/Player.cs" @@ -0,0 +1,173 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace June_6_2021 +{ + enum Guess + { + 剪刀 = 1, + 石头, + 布 + } + class Player + { + public string PName { get; set; } + + public Player() { } + public Player(string pname) + { + this.PName = pname; + } + + Robot r = new Robot(); + Random sj = new Random(); + int count = 0; + int PWin = 0; + int RWin = 0; + public void Game() + { + r.ChooseRival(); + Console.WriteLine("请输入您的姓名:"); + PName = Console.ReadLine(); + Console.WriteLine($"{PName} VS {r.RName} 对战"); + + Console.WriteLine("开始游戏吗?(y/n)"); + string key = Console.ReadLine(); + if (key == "y") + { + count++; + } + switch (key) + { + case "y": + start(); + break; + case "n": + Console.WriteLine("游戏结束"); + break; + default: + break; + } + } + + public void start() //开始游戏 + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应数字:)"); + Solo sl = new Solo(); + sl.PIn(); + Console.WriteLine($"{PName}:出拳:{sl.PInput}"); + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应数字:)"); + sl.RIn(); + Console.WriteLine($"{r.RName}:出拳:{sl.RInput}"); + + if (sl.PInput == "剪刀") + { + if (sl.RInput == "剪刀") + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + else if (sl.RInput == "石头") + { + Console.WriteLine($"笨蛋,{PName}输了"); + RWin++; + } + else if (sl.RInput == "布") + { + Console.WriteLine($"恭喜,{PName}赢了"); + PWin++; + } + } + + if (sl.PInput == "石头") + { + if (sl.RInput == "石头") + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + else if (sl.RInput == "布") + { + Console.WriteLine($"笨蛋,{PName}输了"); + RWin++; + } + else if (sl.RInput == "剪刀") + { + Console.WriteLine($"恭喜,{PName}赢了"); + PWin++; + } + } + + if (sl.PInput == "布") + { + if (sl.RInput == "布") + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + else if (sl.RInput == "剪刀") + { + Console.WriteLine($"笨蛋,{PName}输了"); + RWin++; + } + else if (sl.RInput == "石头") + { + Console.WriteLine($"恭喜,{PName}赢了"); + PWin++; + } + } + + Console.WriteLine("是否开启下一轮?"); + string key = Console.ReadLine(); + if (key == "y") + { + count++; + } + switch (key) + { + case "y": + start(); + break; + case "n": + break; + default: + Console.WriteLine("输入错误,请认真查看规则!"); + break; + } + Console.WriteLine("=========================="); + Console.WriteLine($"{r.RName} VS {PName}"); + Console.WriteLine("对战次数:" + count); + Console.WriteLine(); + Console.WriteLine("姓名 得分"); + Console.WriteLine($"{PName} {PWin}"); + Console.WriteLine($"{r.RName} {RWin}"); + if (RWin > PWin) + { + Console.WriteLine($"结果:{r.RName}赢,{PName}笨蛋"); + } + else if (RWin == PWin) + { + Console.WriteLine($"结果:{PName}和{r.RName}打成平手"); + } + else + { + Console.WriteLine($"结果:{PName}赢,{r.RName}笨蛋"); + } + + Console.WriteLine("要开始下一局吗?"); + string input = Console.ReadLine(); + switch (input) + { + case "y": + start(); + break; + case "n": + Console.WriteLine("系统退出"); + break; + default: + Console.WriteLine("输入有误!!!"); + break; + } + } + } +} diff --git "a/\344\275\231\346\200\235\346\235\260/Program.cs" "b/\344\275\231\346\200\235\346\235\260/Program.cs" new file mode 100644 index 0000000..2e1e2a6 --- /dev/null +++ "b/\344\275\231\346\200\235\346\235\260/Program.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace June_6_2021 +{ + + class Program + { + static void Main(string[] args) + { + Console.WriteLine("-----欢 迎 进 入 游 戏 世 界-----"); + Console.WriteLine(); + Console.WriteLine("********************************"); + Console.WriteLine("***********猜拳,开始***********"); + Console.WriteLine("********************************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + + Player p = new Player(); + p.Game(); + + } + } +} diff --git "a/\344\275\231\346\200\235\346\235\260/Robot.cs" "b/\344\275\231\346\200\235\346\235\260/Robot.cs" new file mode 100644 index 0000000..9179c5b --- /dev/null +++ "b/\344\275\231\346\200\235\346\235\260/Robot.cs" @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace June_6_2021 +{ + class Robot + { + public string RName { get; set; } + + public Robot() { } + public Robot(string rname) + { + this.RName = rname; + } + + public void ChooseRival() + { + Console.WriteLine("请选择对方角色<1:刘备 2:孙权 3:曹操>"); + int key = int.Parse(Console.ReadLine()); + + switch (key) + { + case 1: + RName = "刘备"; + break; + case 2: + RName = "孙权"; + break; + case 3: + RName = "曹操"; + break; + default: + Console.WriteLine("暂未添加此角色,请输入【1,2,3】选择对手"); + ChooseRival(); + break; + } + + } + } +} diff --git "a/\344\275\231\346\200\235\346\235\260/Solo.cs" "b/\344\275\231\346\200\235\346\235\260/Solo.cs" new file mode 100644 index 0000000..b0d9432 --- /dev/null +++ "b/\344\275\231\346\200\235\346\235\260/Solo.cs" @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace June_6_2021 +{ + class Solo + { + public string PInput { get; set; } + public string RInput { get; set; } + + public Solo() { } + public Solo(string pinput, string rinput) + { + this.PInput = pinput; + this.RInput = rinput; + } + + public void PIn() + { + int key = int.Parse(Console.ReadLine()); + switch (key) + { + case 1: + PInput = "剪刀"; + break; + case 2: + PInput = "石头"; + break; + case 3: + PInput = "布"; + break; + default: + Console.WriteLine("输入有误,请输入【1,2,3】"); + PIn(); + break; + } + } + + public void RIn() + { + int key = int.Parse(Console.ReadLine()); + switch (key) + { + case 1: + RInput = "剪刀"; + break; + case 2: + RInput = "石头"; + break; + case 3: + RInput = "布"; + break; + default: + Console.WriteLine("输入有误,请输入【1,2,3】"); + RIn(); + break; + } + } + } +} -- Gitee From 47e2a218eec1a6a03dd5c6274bd464b0c981eef1 Mon Sep 17 00:00:00 2001 From: cowlong <1220590642@qq.com> Date: Sun, 6 Jun 2021 22:01:11 +0800 Subject: [PATCH 52/74] 6.4 --- "\346\237\257\346\226\207\351\276\231/Npc.cs" | 38 ++++++++++ .../Player.cs" | 72 +++++++++++++++++++ .../Program.cs" | 37 ++++++++++ .../Refer.cs" | 31 ++++++++ 4 files changed, 178 insertions(+) create mode 100644 "\346\237\257\346\226\207\351\276\231/Npc.cs" create mode 100644 "\346\237\257\346\226\207\351\276\231/Player.cs" create mode 100644 "\346\237\257\346\226\207\351\276\231/Program.cs" create mode 100644 "\346\237\257\346\226\207\351\276\231/Refer.cs" diff --git "a/\346\237\257\346\226\207\351\276\231/Npc.cs" "b/\346\237\257\346\226\207\351\276\231/Npc.cs" new file mode 100644 index 0000000..f9f32cf --- /dev/null +++ "b/\346\237\257\346\226\207\351\276\231/Npc.cs" @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Npc + { + Random ran = new Random(); + public int SF() + { + int result = ran.Next(1, 4); + Console.WriteLine("计算机出了:{0}", ITF(result)); + return result; + } + + private string ITF(int input) + { + string result = string.Empty; + + switch (input) + { + case 1: + result = "剪刀"; + break; + case 2: + result = "石头"; + break; + case 3: + result = "布"; + break; + } + return result; + } + } +} diff --git "a/\346\237\257\346\226\207\351\276\231/Player.cs" "b/\346\237\257\346\226\207\351\276\231/Player.cs" new file mode 100644 index 0000000..bca2faa --- /dev/null +++ "b/\346\237\257\346\226\207\351\276\231/Player.cs" @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Player + { + string name; + public string Name { get => name; set => name = value; } + + public int SF() + { + Console.WriteLine("请问,你要出什么拳? 1.剪刀 2.石头 3.布"); + int result = ReadInt(1, 3); + string fist = ITF(result); + Console.WriteLine("玩家:{0}出了1个{1}", name, fist); + return result; + } + + //转换 + + private string ITF(int input) + { + string result = string.Empty; + switch (input) + { + case 1: + result = "剪刀"; + break; + case 2: + result = "石头"; + break; + case 3: + result = "布"; + break; + + } + return result; + } + private int ReadInt(int min, int max) + { + while (true) + { + //从控制台获取用户输入的数据 + string str = Console.ReadLine(); + + //将用户输入的字符串转换成Int类型 + int result; + if (int.TryParse(str, out result)) + { + //判断输入的范围 + if (result >= min && result <= max) + { + return result; + } + else + { + Console.WriteLine("请输入1个{0}-{1}范围的数", min, max); + continue; + } + } + else + { + Console.WriteLine("请输入整数"); + } + } + } + } +} diff --git "a/\346\237\257\346\226\207\351\276\231/Program.cs" "b/\346\237\257\346\226\207\351\276\231/Program.cs" new file mode 100644 index 0000000..62f00e3 --- /dev/null +++ "b/\346\237\257\346\226\207\351\276\231/Program.cs" @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("***************************"); + Console.WriteLine("*********猜拳,开始********"); + Console.WriteLine("***************************"); + + //Console.WriteLine("请选择对方角色 <1:刘备 2:孙权 3:曹操>"); + //int a = int.Parse(Console.ReadLine()); + + Console.WriteLine("请输入您的姓名:"); + string name = Console.ReadLine(); + + Player p1 = new Player() { Name = name }; + Npc c1 = new Npc(); + Refer j1 = new Refer(); + + + while (true) + { + int res1 = p1.SF(); + int res2 = c1.SF(); + j1.Determine(res1, res2); + Console.ReadKey(); + } + } + } +} diff --git "a/\346\237\257\346\226\207\351\276\231/Refer.cs" "b/\346\237\257\346\226\207\351\276\231/Refer.cs" new file mode 100644 index 0000000..0302fe8 --- /dev/null +++ "b/\346\237\257\346\226\207\351\276\231/Refer.cs" @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Refer + { + public void Determine(int k1, int k2) + { + //1剪刀 2石头 3布 + //1 3 1-3=-2 在玩家出1剪刀的情况下,计算机出3布,玩家赢 + //2 1 2-1=1 在玩家出2石头的情况下,计算机出1剪刀,玩家赢 + //3 2 3-2=1 在玩家出3布的情况下,计算机出2石头,玩家赢 + if (k1 - k2 == -2 || k1 - k2 == 1) + { + Console.WriteLine("玩家胜利!"); + } + else if (k1 == 2) + { + Console.WriteLine("平局"); + } + else + { + Console.WriteLine("玩家失败!"); + } + } + } +} -- Gitee From 6c7d5a7814f52f15e34f7368a5f148eb829d1f9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=93=A6=E7=89=B9=E5=8F=91?= <3144531710@qq.com> Date: Sun, 6 Jun 2021 22:06:15 +0800 Subject: [PATCH 53/74] =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\346\275\230\345\256\207/NPC.cs" | 25 +++++ "\346\275\230\345\256\207/Program.cs" | 123 +++++++++++++++++++++++ "\346\275\230\345\256\207/Publicinfo.cs" | 23 +++++ "\346\275\230\345\256\207/player.cs" | 24 +++++ 4 files changed, 195 insertions(+) create mode 100644 "\346\275\230\345\256\207/NPC.cs" create mode 100644 "\346\275\230\345\256\207/Program.cs" create mode 100644 "\346\275\230\345\256\207/Publicinfo.cs" create mode 100644 "\346\275\230\345\256\207/player.cs" diff --git "a/\346\275\230\345\256\207/NPC.cs" "b/\346\275\230\345\256\207/NPC.cs" new file mode 100644 index 0000000..4d2762d --- /dev/null +++ "b/\346\275\230\345\256\207/NPC.cs" @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class NPC : Publicinfo + { + public NPC(string name) : base(name) + { + this.Name = name; + } + public override int fist() + { + Random r = new Random(); + int a = r.Next(3) + 1; + + return a; + } + + + } +} diff --git "a/\346\275\230\345\256\207/Program.cs" "b/\346\275\230\345\256\207/Program.cs" new file mode 100644 index 0000000..6468714 --- /dev/null +++ "b/\346\275\230\345\256\207/Program.cs" @@ -0,0 +1,123 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + enum npcname + { + 刘备 = 1, + 孙权, + 曹操 + } + enum fist + { + 剪刀 = 1, + 石头, + 布 + } + class Program + { + + static void Main(string[] args) + { + int pgroud = 0; + int ngroud = 0; + int session = 0; + against(ref pgroud, ref ngroud, ref session); + against2(ref pgroud, ref ngroud, ref session); + } + public static void against2(ref int pgroud, ref int ngroud, ref int session) + { + Console.WriteLine("要开始下一局吗?1、要 2、 不要"); + int choose3 = int.Parse(Console.ReadLine()); + switch (choose3) + { + case 1: + against(ref pgroud, ref ngroud, ref session); + against2(ref pgroud, ref ngroud, ref session); + break; + case 2: + Console.WriteLine("拜了个拜"); + break; + default: + Console.WriteLine("输入错误,重新开始"); + against(ref pgroud, ref ngroud, ref session); + break; + } + } + public static void against(ref int pgroud, ref int ngroud, ref int session) + { + Console.WriteLine("----游戏即将开始----"); + Console.WriteLine("--------------------"); + Console.WriteLine("-----猜拳·开始-----"); + Console.WriteLine("--------------------"); + Console.WriteLine("出拳规则:1、剪刀 2、 石头 3、 布"); + Console.WriteLine("请选择对方角色:1、刘备 2 、孙权 3、 曹操 (请输入相应数字)"); + int choose1 = int.Parse(Console.ReadLine()); + npcname f = (npcname)choose1; + + Console.WriteLine("请输入您的名字"); + string play = Console.ReadLine(); + player player = new player(play); + game(ref f, ref pgroud, ref ngroud, ref session, ref player); + + } + + public static void game(ref npcname f, ref int pgroud, ref int ngroud, ref int session, ref player player) + { + NPC npc = new NPC(f.ToString()); + int a = player.fist(); + fist playfist = (fist)a; + int b = npc.fist(); + fist npcfist = (fist)b; + Console.WriteLine("{0}出的拳为{1}", player.Name, playfist); + Console.WriteLine("{0}出的拳为{1}", npc.Name, npcfist); + string a1 = playfist.ToString(); + string a2 = npcfist.ToString(); + judge(a1, a2, ref pgroud, ref ngroud, ref session); + Console.WriteLine("是否开始下一轮 1、继续 2 、停止 "); + int choose = int.Parse(Console.ReadLine()); + switch (choose) + { + case 1: + game(ref f, ref pgroud, ref ngroud, ref session, ref player); + break; + case 2: + Console.WriteLine("{0}对阵{1}", player.Name, npc.Name); + Console.WriteLine("对阵次数{0}", session); + Console.WriteLine("姓名 得分"); + Console.WriteLine("{0} {1}", player.Name, pgroud); + Console.WriteLine("{0} {1}", npc.Name, ngroud); + break; + default: + Console.WriteLine("输入错误,重新开始"); + game(ref f, ref pgroud, ref ngroud, ref session, ref player); + break; + } + } + + public static void judge(string player, string npcfist, ref int pgroud, ref int ngroud, ref int session) + { + if (player.Equals("石头") && npcfist.Equals("剪刀") || player.Equals("剪刀") && npcfist.Equals("布") || player.Equals("布") && npcfist.Equals("石头")) + { + Console.WriteLine("你获得胜利"); + pgroud++; + session++; + } + else if (player.Equals(npcfist)) + { + Console.WriteLine("平局了"); + session++; + } + else + { + Console.WriteLine("你输了"); + ngroud++; + session++; + } + } + } +} diff --git "a/\346\275\230\345\256\207/Publicinfo.cs" "b/\346\275\230\345\256\207/Publicinfo.cs" new file mode 100644 index 0000000..389514e --- /dev/null +++ "b/\346\275\230\345\256\207/Publicinfo.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Publicinfo + { + public string Name { get; set; } + + public Publicinfo(string name) + { + Name = name; + } + public virtual int fist() + { + return 0; + } + + } +} \ No newline at end of file diff --git "a/\346\275\230\345\256\207/player.cs" "b/\346\275\230\345\256\207/player.cs" new file mode 100644 index 0000000..e2291b2 --- /dev/null +++ "b/\346\275\230\345\256\207/player.cs" @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class player : Publicinfo + { + public player(string name) : base(name) + { + this.Name = name; + } + public override int fist() + { + Console.WriteLine("请出拳:1、剪刀 2 、石头 3、 布 (请输入相应数字)"); + int choose2 = int.Parse(Console.ReadLine()); + return choose2; + } + + + } +} \ No newline at end of file -- Gitee From 7f0f0d936c768ec1fcd04c5196cc388c527ab61e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E4=B8=80?= <8332095+Xone-by-one@user.noreply.gitee.com> Date: Sun, 6 Jun 2021 22:06:27 +0800 Subject: [PATCH 54/74] 123 --- .../CQGZ.cs" | 23 ++ .../DFJS.cs" | 20 ++ "\345\276\220\346\261\237\346\273\250/PB.cs" | 22 ++ .../Program.cs" | 214 ++++++++++++++++++ 4 files changed, 279 insertions(+) create mode 100644 "\345\276\220\346\261\237\346\273\250/CQGZ.cs" create mode 100644 "\345\276\220\346\261\237\346\273\250/DFJS.cs" create mode 100644 "\345\276\220\346\261\237\346\273\250/PB.cs" create mode 100644 "\345\276\220\346\261\237\346\273\250/Program.cs" diff --git "a/\345\276\220\346\261\237\346\273\250/CQGZ.cs" "b/\345\276\220\346\261\237\346\273\250/CQGZ.cs" new file mode 100644 index 0000000..9521a2d --- /dev/null +++ "b/\345\276\220\346\261\237\346\273\250/CQGZ.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + abstract class CQGZ + { + public static string[] fist = {"石头","剪刀","布" }; + + private string name; + public string Name { get => name; set => name = value; } + + public CQGZ(string Name) + { + this.name = Name; + } + public abstract void play(); + + } +} diff --git "a/\345\276\220\346\261\237\346\273\250/DFJS.cs" "b/\345\276\220\346\261\237\346\273\250/DFJS.cs" new file mode 100644 index 0000000..493dadb --- /dev/null +++ "b/\345\276\220\346\261\237\346\273\250/DFJS.cs" @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class DFJS:CQGZ + { + public string fisttype; + public static int gamercore; + public DFJS(string Name) : base(Name){ } + + public override void play() + { + Console.WriteLine(base.Name+":"+"出拳"+this.fisttype); + } + } +} diff --git "a/\345\276\220\346\261\237\346\273\250/PB.cs" "b/\345\276\220\346\261\237\346\273\250/PB.cs" new file mode 100644 index 0000000..f2f9cfb --- /dev/null +++ "b/\345\276\220\346\261\237\346\273\250/PB.cs" @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class PB:CQGZ + { + public static string fistname; + public static int oberscore; + public PB(string Name) : base(Name) { } + public Random random = new Random(); + public override void play() + { + fistname = fist[random.Next(0, 3)]; + Console.WriteLine(base.Name + ":" + "出拳:" + fistname); + } + + } +} diff --git "a/\345\276\220\346\261\237\346\273\250/Program.cs" "b/\345\276\220\346\261\237\346\273\250/Program.cs" new file mode 100644 index 0000000..2d4ab66 --- /dev/null +++ "b/\345\276\220\346\261\237\346\273\250/Program.cs" @@ -0,0 +1,214 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Program + { + static DFJS gone; + static PB gtwo; + static Boolean TorF = false; + static int c = 0; + static string Gamename; + static void Main(string[] args) + { + Game(); + } + static void ChooseObsr() + { + if (c == 1) + { + Gamename = "刘备"; + } + else if (c == 2) + { + Gamename = "孙权"; + } + else if (c == 3) + { + Gamename = "曹操"; + } + Console.WriteLine("请输入你的姓名:"); + string GameName = Console.ReadLine(); + gone = new DFJS(Gamename); + gtwo = new PB(Gamename); + Console.WriteLine(gone.Name + "VS" + gtwo.Name + " 对战"); + + Console.WriteLine("开始游戏吗?"); + string numo = Console.ReadLine(); + if (numo == "y") + { + Start(); + } + else + { + Console.WriteLine("已退出!!!"); + } + } + static void Game() + { + Console.WriteLine("-------------欢迎进入游戏世界----------------"); + Console.WriteLine("*********************************************"); + Console.WriteLine("****************猜拳,开始*******************"); + Console.WriteLine("*********************************************"); + Console.WriteLine("出拳规则,1.剪刀 2.石头 3.布"); + Console.WriteLine("请选择对方角色<1:刘备 2:孙权 3:曹操>"); + int num = Convert.ToInt32(Console.ReadLine()); + + switch (num) + { + case 1: + c = 1; + ChooseObsr(); + break; + case 2: + c = 2; + ChooseObsr(); + break; + case 3: + c = 3; + ChooseObsr(); + break; + default: + Console.WriteLine("输入名字错误,请重新进入游戏!!"); + Game(); + break; + } + } + static void EndScore() + { + Console.WriteLine("============================================================="); + Console.WriteLine("姓名 " + " 得分"); + Console.WriteLine(gone.Name + "\t \t" + DFJS.gamercore); + Console.WriteLine(gtwo.Name + "\t \t" + PB.oberscore); + if (DFJS.gamercore > PB.oberscore) + { + Console.WriteLine("结果:" + gone.Name + "赢," + gtwo.Name + "笨蛋"); + } + else if (DFJS.gamercore == PB.oberscore) + { + Console.WriteLine("平局了!!!"); + } + else + { + Console.WriteLine("结果:" + gtwo.Name + "赢," + gone.Name + "笨蛋"); + } + } + static void AgainStart() + { + + if (TorF == true) + { + Console.WriteLine("要开始下一局吗?(y/n)"); + string numo = Console.ReadLine(); + if (numo == "y") + { + Game(); + } + else + { + Console.WriteLine("系统退出!"); + } + } + else + { + Console.WriteLine("是否要开始下一轮?"); + string numo = Console.ReadLine(); + + if (numo == "y") + { + Start(); + } + else + { + EndScore(); + Console.WriteLine("退出!"); + + } + } + } + static void Start() + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应数字:)"); + int num2 = Convert.ToInt32(Console.ReadLine()); + switch (num2) + { + case 1: + gone.fisttype = "剪刀"; + Say(); + break; + case 2: + gone.fisttype = "石头"; + Say(); + break; + case 3: + gone.fisttype = "布"; + Say(); + break; + default: + break; + } + Win(); + AgainStart(); + + } + static void Win() + { + if (gone.fisttype == "剪刀" && PB.fistname == "剪刀") + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + else if (gone.fisttype == "剪刀" && PB.fistname == "石头") + { + Console.WriteLine("笨蛋," + gone.Name + "输了"); + PB.oberscore++; + } + else if (gone.fisttype == "剪刀" && PB.fistname == "布") + { + Console.WriteLine("恭喜," + gone.Name + "赢了"); + DFJS.gamercore++; + } + else if (gone.fisttype == "石头" && PB.fistname == "石头") + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + else if (gone.fisttype == "石头" && PB.fistname == "布") + { + Console.WriteLine("笨蛋," + gone.Name + "输了"); + PB.oberscore++; + } + else if (gone.fisttype == "石头" && PB.fistname == "剪刀") + { + Console.WriteLine("恭喜," + gone.Name + "赢了"); + DFJS.gamercore++; + } + else if (gone.fisttype == "布" && PB.fistname == "布") + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + else if (gone.fisttype == "布" && PB.fistname == "剪刀") + { + Console.WriteLine("笨蛋," + gone.Name + "输了"); + PB.oberscore++; + } + else if (gone.fisttype == "布" && PB.fistname == "石头") + { + Console.WriteLine("恭喜," + gone.Name + "赢了"); + DFJS.gamercore++; + } + else + { + Console.WriteLine(" "); + } + AgainStart(); + } + static void Say() + { + gone.play(); + gtwo.play(); + } + } +} -- Gitee From 62cbf5b83218a0f36120bb15713011aa34694106 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=9C=E6=B5=B7=E5=BD=AA?= <3305448617@qq.com> Date: Sun, 6 Jun 2021 22:10:25 +0800 Subject: [PATCH 55/74] 123 --- .../Caipan.cs" | 143 ++++++++++++++++++ .../Computer.cs" | 66 ++++++++ .../Player.cs" | 34 +++++ .../Program.cs" | 32 ++++ .../Useplay.cs" | 38 +++++ 5 files changed, 313 insertions(+) create mode 100644 "\346\235\234\346\265\267\345\275\252/Caipan.cs" create mode 100644 "\346\235\234\346\265\267\345\275\252/Computer.cs" create mode 100644 "\346\235\234\346\265\267\345\275\252/Player.cs" create mode 100644 "\346\235\234\346\265\267\345\275\252/Program.cs" create mode 100644 "\346\235\234\346\265\267\345\275\252/Useplay.cs" diff --git "a/\346\235\234\346\265\267\345\275\252/Caipan.cs" "b/\346\235\234\346\265\267\345\275\252/Caipan.cs" new file mode 100644 index 0000000..602ba9c --- /dev/null +++ "b/\346\235\234\346\265\267\345\275\252/Caipan.cs" @@ -0,0 +1,143 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Caipan + //裁判 + { + static Computer computer = new Computer(); + static Useplay user = new Useplay(); + public bool statr(String inputName, String computName) + { + int comWinCount = 0; + int userWinCount = 0; + bool flag = false; + int count = 1; + string j; + Console.WriteLine("准备开始游戏了吗(y/n)"); + j = Console.ReadLine(); + if (j.Equals("y")) + { + m: do + { + count++; + //玩家出拳 + int userValue = user.getInputWhat(); + Console.WriteLine(inputName + "出拳: "); + //电脑出拳 + int comValue = computer.getInputWhat(); + Console.WriteLine(computName + "出拳: "); + //裁判比较 + int result = compare(comValue, userValue); + if (result == 1) + { + Console.WriteLine("笨蛋," + computName + "赢了"); + comWinCount++; + } + else if (result == -1) + { + Console.WriteLine("笨蛋," + inputName + "赢了"); + userWinCount++; + } + else + { + Console.WriteLine("嘿嘿,和局真衰,等着瞧吧"); + } + Console.WriteLine("准备开始游戏了吗(y/n)"); + j = Console.ReadLine(); + switch (j) + { + case "y": + flag = true; + break; + case "n": + Console.WriteLine("=========================================="); + Console.WriteLine(inputName + " VS " + computName); + Console.WriteLine("对战次数" + count); + Console.WriteLine(); + Console.WriteLine("姓名\t\t得分"); + Console.WriteLine(inputName + "\t\t" + userWinCount); + Console.WriteLine(computName + "\t\t" + comWinCount); + if (userWinCount > comWinCount) + { + Console.WriteLine(inputName + "赢"); + } + else if (userWinCount > comWinCount) + { + Console.WriteLine(computName + "赢"); + } + else + { + Console.WriteLine("平局"); + } + Console.WriteLine("退出系统"); + break; + } + goto m; + } while (flag); + } + else if (j.Equals("n")) + { + Console.WriteLine("系统退出"); + } + return flag; + } + public int compare(int computerValue, int userValue) + { + if (computerValue == userValue) + { + return 0; + } + else if (computerValue == 1)//1 剪刀 + { + if (userValue == 2)//1 石头 + { + return -1; + } + else//3 布 + { + return 1; + } + } + else if (computerValue == 2)//2 石头 + { + if (userValue == 1)// 1 剪刀 + { + return 1; + } + else//3 布 + { + return -1; + } + } + else//3 computerValue==布 + { + if (userValue == 2)//石头 + { + return 1; + } + else// 1 剪刀 + { + return -1; + } + } + //public enum Result + //{ + // 电脑赢, 玩家赢, 平局 + //} + //public static Result caipan(int playerNum, int cpuNum) + //{ + // if ((playerNum - cpuNum) == 1 || (playerNum - cpuNum) == -2) + // return Result.玩家赢; + // else if ((playerNum - cpuNum) == 0) + // return Result.平局; + // else + // return Result.电脑赢; + //} + } + } +} diff --git "a/\346\235\234\346\265\267\345\275\252/Computer.cs" "b/\346\235\234\346\265\267\345\275\252/Computer.cs" new file mode 100644 index 0000000..a0f588b --- /dev/null +++ "b/\346\235\234\346\265\267\345\275\252/Computer.cs" @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Computer:Player + //电脑 + { + public string name { get; set; } + static Random rand = new Random(); + public override int getInputWhat() + { + int value = rand.Next(1, 4); + if (value == 1) + { + Console.WriteLine("剪刀"); + } + else if (value == 2) + { + Console.WriteLine("石头"); + } + else if (value == 3) + { + Console.WriteLine("布"); + } + return value; + } + + public string getPlayerName(int num) + { + if (num == 1) + { + name = "佛耶戈"; + } + else if (num == 2) + { + name = "大头"; + } + else if (num == 3) + { + name = "莫德凯撒"; + } + return name; + } + //public string fist + //{ + // get; + // set; + //} + //public int cpuShowFist() + //{ + // Random r = new Random(); + // int cnum = r.Next(1, 4); + // switch (cnum) + // { + // case 1: this.fist = "剪刀"; break; + // case 2: this.fist = "石头"; break; + // case 3: this.fist = "布"; break; + // } + // return cnum; + //} + } +} diff --git "a/\346\235\234\346\265\267\345\275\252/Player.cs" "b/\346\235\234\346\265\267\345\275\252/Player.cs" new file mode 100644 index 0000000..6e29bf6 --- /dev/null +++ "b/\346\235\234\346\265\267\345\275\252/Player.cs" @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + abstract class Player + { + public string Name { get; set; } + public string What { get; set; } + public string Result { get; set; } + public Player() + { + + } + public abstract int getInputWhat(); + + //public int showFist(string str) + //{ + // int num = 0; + // switch (str) + // { + // case "剪刀": num = 1; break; + // case "石头": num = 2; break; + // case "布": num = 3; break; + + // } + // return num; + + //} + } +} diff --git "a/\346\235\234\346\265\267\345\275\252/Program.cs" "b/\346\235\234\346\265\267\345\275\252/Program.cs" new file mode 100644 index 0000000..8b85b35 --- /dev/null +++ "b/\346\235\234\346\265\267\345\275\252/Program.cs" @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Program + { + static void Main(string[] args) + { + Computer computer = new Computer(); + Useplay user = new Useplay(); + Caipan c = new Caipan(); + Console.WriteLine("----------------------欢迎进入游戏世界-------------------------"); + Console.WriteLine("**********************************************"); + Console.WriteLine("******************猜拳,开始******************"); + Console.WriteLine("**********************************************"); + Console.WriteLine("出拳规则:1.剪刀2.石头3.布"); + Console.WriteLine("请选择对方角色<1.佛耶戈 2.大头 3.莫德凯撒>"); + int num = int.Parse(Console.ReadLine()); + string computerName = computer.getPlayerName(num); + Console.WriteLine("请输入名字"); + string userName = Console.ReadLine(); + string personName = user.PersonName(userName); + Console.WriteLine(computerName + " VS " + personName + " 对战"); + Caipan.Equals(userName, computerName); + Console.WriteLine("准备开始游戏了吗(y/n)"); + } + } +} diff --git "a/\346\235\234\346\265\267\345\275\252/Useplay.cs" "b/\346\235\234\346\265\267\345\275\252/Useplay.cs" new file mode 100644 index 0000000..a27e6be --- /dev/null +++ "b/\346\235\234\346\265\267\345\275\252/Useplay.cs" @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Useplay:Player + //玩家 + { + public string name { get; set; } + public String PersonName(String inputName) + { + this.name = inputName; + return this.name; + } + public override int getInputWhat() + { + Console.WriteLine("请出拳:1.剪刀 2.石头3.布"); + int value = int.Parse(Console.ReadLine()); + if (value == 1) + { + Console.WriteLine("剪刀"); + } + else if (value == 2) + { + Console.WriteLine("石头"); + } + else if (value == 3) + { + Console.WriteLine("布"); + } + return value; + + } + } +} -- Gitee From 2a56b4319d693b635de663673b40a61ff854fe30 Mon Sep 17 00:00:00 2001 From: yang-wenrong <956352682@qq.com> Date: Sun, 6 Jun 2021 22:15:52 +0800 Subject: [PATCH 56/74] 6.6 --- "\346\235\250\346\226\207\350\215\243/Npc.cs" | 18 +++ .../Program.cs" | 152 ++++++++++++++++++ .../player.cs" | 17 ++ .../role.cs" | 16 ++ .../ruler.cs" | 13 ++ 5 files changed, 216 insertions(+) create mode 100644 "\346\235\250\346\226\207\350\215\243/Npc.cs" create mode 100644 "\346\235\250\346\226\207\350\215\243/Program.cs" create mode 100644 "\346\235\250\346\226\207\350\215\243/player.cs" create mode 100644 "\346\235\250\346\226\207\350\215\243/role.cs" create mode 100644 "\346\235\250\346\226\207\350\215\243/ruler.cs" diff --git "a/\346\235\250\346\226\207\350\215\243/Npc.cs" "b/\346\235\250\346\226\207\350\215\243/Npc.cs" new file mode 100644 index 0000000..76f77c5 --- /dev/null +++ "b/\346\235\250\346\226\207\350\215\243/Npc.cs" @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo +{ + class Npc:role + { + public override int print() + { + Random r = new Random(); + + return r.Next(3) + 1; + } + } +} diff --git "a/\346\235\250\346\226\207\350\215\243/Program.cs" "b/\346\235\250\346\226\207\350\215\243/Program.cs" new file mode 100644 index 0000000..fc63d3b --- /dev/null +++ "b/\346\235\250\346\226\207\350\215\243/Program.cs" @@ -0,0 +1,152 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo +{ + class Program + { + static int count = 0; + static int pcount = 0; + static int ncount = 0; + static Npc n = new Npc(); + static player p = new player(); + static ruler ruler = new ruler(); + enum chuquan + { + 剪刀 = 1, + 石头, + 布 + } + enum role + { + 刘备 = 1, + 孙权, + 曹操 + } + + static void Main(string[] args) + { + start(); + + } + public static void start() { + welcome(); + rule(); + ballte(); + result(); + } + public static void welcome() + { + Console.WriteLine("——————欢迎进入游戏世界——————"); + Console.WriteLine("*********************"); + Console.WriteLine("****猜拳,开始*****"); + Console.WriteLine("*********************"); + + } + public static void rule() + { + while (true) + { + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Console.WriteLine("请选择对方角色 1.刘备 2.孙权 3.曹操"); + int num = int.Parse(Console.ReadLine()); + Console.WriteLine("请输入你的姓名"); + string name = Console.ReadLine(); + Console.WriteLine("{0}VS{1} 对战", name, num); + Console.WriteLine("开始游戏吗(y/n)"); + string a = Console.ReadLine(); + if (a == "Y") + { + break; + } + } + + } + public static void ballte() + { + while (true) + { + Console.WriteLine("请出拳:{0}(输入相应数字)", ListPunch()); + int pf = p.print(); + int nf = n.print(); + Console.WriteLine("{0}出{1}",p.name,(chuquan)pf); + Console.WriteLine("{0}出{1}",n.name,(chuquan)nf); + int result = Iswin(pf,nf); + Console.WriteLine(); + Console.WriteLine(result==0?"和局":result==1?$"恭喜{p.name}赢了":$"{p.name}输了"); + count++; + if (result == 1) { + pcount++; + } + if (result == -1) { + ncount++; + } + Console.WriteLine("是否开始下一轮(y/n)"); + string key = Console.ReadLine(); + if (key == "n") { + break; + } + + } + } + public static void result() { + Console.WriteLine("\n================================"); + Console.WriteLine("{0}VS{1}",p.name,n.name); + Console.WriteLine("对战次数{0}",count); + Console.WriteLine(); + Console.WriteLine("姓名\t得分"); + Console.WriteLine("{0}\t{1}",p.name,pcount); + Console.WriteLine("{0}\t{1}", n.name, ncount); + Console.WriteLine("结果"+(pcount>ncount?p.name:n.name)+"赢了"); + Console.WriteLine("要开始下一局吗(y/n)"); + string key = Console.ReadLine(); + if (key == "y") + { + start(); + } + else { + Console.WriteLine("游戏结束"); + } + } + + public static string ListPunch() + { + string punchString = " "; + int i = 1; + foreach (chuquan n in Enum.GetValues(typeof(chuquan))) + { + punchString += i + "、" + n + ";"; + i++; + + } + return punchString; + } + public static string ListNpc() + { + string role = " "; + int i = 1; + foreach (role n in Enum.GetValues(typeof(role))) + { + role += i + "、" + n + ";"; + i++; + + } + return role; + } + + public static int Iswin(int pf,int nf) { + if (pf == nf) { + return 0; + } else if (pf == 1 & nf == 3 || pf == 2 & nf == 1 || pf == 3 & nf == 2) { + return 1; + + } + else { + return -1; + } + } + } +} diff --git "a/\346\235\250\346\226\207\350\215\243/player.cs" "b/\346\235\250\346\226\207\350\215\243/player.cs" new file mode 100644 index 0000000..43dc786 --- /dev/null +++ "b/\346\235\250\346\226\207\350\215\243/player.cs" @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo +{ + class player:role + { + public override int print() + { + int num = int.Parse(Console.ReadLine()); + return num; + } + } +} diff --git "a/\346\235\250\346\226\207\350\215\243/role.cs" "b/\346\235\250\346\226\207\350\215\243/role.cs" new file mode 100644 index 0000000..ffa56e0 --- /dev/null +++ "b/\346\235\250\346\226\207\350\215\243/role.cs" @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo +{ + class role + { + public string name { get; set; } + public virtual int print() { + return 0; + } + } +} diff --git "a/\346\235\250\346\226\207\350\215\243/ruler.cs" "b/\346\235\250\346\226\207\350\215\243/ruler.cs" new file mode 100644 index 0000000..bb5017f --- /dev/null +++ "b/\346\235\250\346\226\207\350\215\243/ruler.cs" @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo +{ + class ruler:role + { + + } +} -- Gitee From ac686dc0ecdc6a3b8935cf57ff144f631dd9a9ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=96=87=E8=81=AA?= <3148578490@qq.com> Date: Sun, 6 Jun 2021 22:17:41 +0800 Subject: [PATCH 57/74] =?UTF-8?q?=E6=96=B0=E5=BB=BA=20=E9=BB=84=E6=96=87?= =?UTF-8?q?=E8=81=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\351\273\204\346\226\207\350\201\252/.keep" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "\351\273\204\346\226\207\350\201\252/.keep" diff --git "a/\351\273\204\346\226\207\350\201\252/.keep" "b/\351\273\204\346\226\207\350\201\252/.keep" new file mode 100644 index 0000000..e69de29 -- Gitee From e512fd726f71a19e1f1b7d0f4d65ffdfeeb44768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=96=87=E8=81=AA?= <3148578490@qq.com> Date: Sun, 6 Jun 2021 22:18:55 +0800 Subject: [PATCH 58/74] =?UTF-8?q?=E5=A5=BD=E5=85=84=E5=BC=9F=E5=95=8A?= =?UTF-8?q?=EF=BC=8C=E5=85=AD=E4=B8=AA=E5=85=AD=E5=95=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Program.cs" | 246 ++++++++++++++++++ 1 file changed, 246 insertions(+) create mode 100644 "\351\273\204\346\226\207\350\201\252/Program.cs" diff --git "a/\351\273\204\346\226\207\350\201\252/Program.cs" "b/\351\273\204\346\226\207\350\201\252/Program.cs" new file mode 100644 index 0000000..ec87232 --- /dev/null +++ "b/\351\273\204\346\226\207\350\201\252/Program.cs" @@ -0,0 +1,246 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _210604猜拳 +{ + + class Hero + { + private string name; + public string Name + { + get { return this.name; } + set { this.name = value; } + } + public Hero(string Name) + { + this.name = Name; + } + public Hero() + { + + } + } + enum Fist + { + 石头 = 1, + 剪刀, + 布 + } + enum Yx + { + 刘备 = 1, + 孙权, + 曹操 + } + + class Program + { + //玩家姓名 + static string xm; + //对手姓名 + static Yx name; + //实例化随机数 + static Random sz = new Random(); + //计算分数 + static int playersum = 0, robotsum = 0, gamesum = 0; + static void Main(string[] args) + { + Console.WriteLine("---------------欢迎进入游戏世界---------------"); + Console.WriteLine(); + Console.WriteLine("*************************************"); + Console.WriteLine("**********猜拳··开始!!!*********"); + Console.WriteLine("*************************************"); + Console.WriteLine("出拳规则:1.剪刀2.石头3.布"); + pk(); + Console.ReadKey(); + } + static string listfist() + { + string fiststring = ""; + int i = 1; + foreach (Fist f in Enum.GetValues(typeof(Fist))) + { + fiststring += i + "、" + f + ";"; + i++; + } + return fiststring; + } + static string listyx() + { + string yxstring = ""; + int i = 1; + foreach (Yx f in Enum.GetValues(typeof(Yx))) + { + yxstring += i + "、" + f + ";"; + i++; + } + return yxstring; + } + static void pk() + { + Console.WriteLine("请选择对方角色{0}", listyx()); + int jx = int.Parse(Console.ReadLine()); + name = (Yx)jx; + Console.WriteLine("请输入你的姓名:"); + xm = Console.ReadLine(); + Console.WriteLine("{0} vs {1} 对战!", xm, name); + Console.WriteLine("开始游戏吗?(y/n)"); + string begin = Console.ReadLine(); + if (begin == "y") + { + confrontation(); + } + else if (begin == "n") + { + end(); + } + } + static void confrontation() + { + Console.WriteLine("请出拳:{0}(输入相应数字:)", listfist()); + int guess = int.Parse(Console.ReadLine()); + //我方出拳 + Fist fname = (Fist)guess; + //对手出拳 + int cq = sz.Next(1, 4); + Fist q = (Fist)cq; + int qq = (int)q; + switch (guess) + { + case 1: + Console.WriteLine("{0}:出拳:{1}", xm, fname); + Console.WriteLine("{0}:出拳:{1}", name, q); + if (qq.Equals(3)) + { + Console.WriteLine("{0}输了,不要害怕失败大不了从头来过!", xm); + robotsum++; + gamesum++; + } + else if (fname.Equals(q)) + { + Console.WriteLine("和局,真倒霉!你个王八犊子等着瞧!"); + gamesum++; + } + else + { + Console.WriteLine("芜湖!{0}赢了!", xm); + playersum++; + gamesum++; + } + circulation(); + break; + case 2: + Console.WriteLine("{0}:出拳:{1}", xm, fname); + Console.WriteLine("{0}:出拳:{1}", name, q); + if (qq.Equals(1)) + { + Console.WriteLine("{0}输了,不要害怕失败大不了从头来过!", xm); + robotsum++; + gamesum++; + } + else if (fname.Equals(q)) + { + Console.WriteLine("和局,真倒霉!你个王八犊子等着瞧!"); + gamesum++; + } + else + { + Console.WriteLine("芜湖!{0}赢了!", xm); + playersum++; + gamesum++; + } + circulation(); + break; + case 3: + Console.WriteLine("{0}:出拳:{1}", xm, fname); + Console.WriteLine("{0}:出拳:{1}", name, q); + if (qq.Equals(2)) + { + Console.WriteLine("{0}输了,不要害怕失败大不了从头来过!", xm); + robotsum++; + gamesum++; + } + else if (fname.Equals(q)) + { + Console.WriteLine("和局,真倒霉!你个王八犊子等着瞧!"); + gamesum++; + } + else + { + Console.WriteLine("芜湖!{0}赢了!", xm); + playersum++; + gamesum++; + } + circulation(); + break; + default: + Console.WriteLine("没有该选项!"); + break; + } + } + static void end() + { + Console.WriteLine(); + Console.WriteLine(); + Console.WriteLine("===================================="); + Console.WriteLine("{0} vs {1}", name, xm); + Console.WriteLine("对战次数:{0}", gamesum); + Console.WriteLine(); + Console.WriteLine("姓名\t得分"); + Console.WriteLine("{0}\t{1}", xm, playersum); + Console.WriteLine("{0}\t{1}", name, robotsum); + if (playersum > robotsum) + { + Console.WriteLine("结果:{0}赢,{1}输了", xm, name); + } + else if (playersum < robotsum) + { + Console.WriteLine("结果:{0}赢,{1}输了", name, xm); + } + else + { + Console.WriteLine("结果:似乎平局了哦"); + } + cx: + Console.WriteLine("要开始下一局吗?(y/n)"); + string newgame = Console.ReadLine(); + if (newgame == "y") + { + playersum = 0; robotsum = 0; gamesum = 0; + pk(); + } + else if (newgame == "n") + { + Console.WriteLine("系统退出"); + } + else + { + Console.WriteLine("没有该选项请重新选择"); + goto cx; + } + } + static void circulation() + { + cx: + Console.WriteLine("是否开启下一轮?(y/n)"); + string next = Console.ReadLine(); + if (next == "y") + { + confrontation(); + } + else if (next == "n") + { + end(); + } + else + { + Console.WriteLine("没有该选项!重新选择!"); + goto cx; + } + } + } +} -- Gitee From 99cbf8ced07ba265ad63fea3f5703e2e271f4c05 Mon Sep 17 00:00:00 2001 From: heiiii <1390105108@qq.com> Date: Sun, 6 Jun 2021 22:21:49 +0800 Subject: [PATCH 59/74] 55 --- "\351\231\210\346\227\255/Jse.cs" | 76 ++++++++++++++++ "\351\231\210\346\227\255/Program.cs" | 119 ++++++++++++++++++++++++++ 2 files changed, 195 insertions(+) create mode 100644 "\351\231\210\346\227\255/Jse.cs" create mode 100644 "\351\231\210\346\227\255/Program.cs" diff --git "a/\351\231\210\346\227\255/Jse.cs" "b/\351\231\210\346\227\255/Jse.cs" new file mode 100644 index 0000000..91991a9 --- /dev/null +++ "b/\351\231\210\346\227\255/Jse.cs" @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + public enum Qun + { + 剪刀 = 1, + 石头, + 布 + } + abstract class Jse + { + public Jse(string name) + { + this.name = name; + } + public int grade { get; set; }//分数 + public int FGG { get; set; }//猜拳 + public Jse() + { + + } + + public string name { get; set; } + + public abstract void Cun(); + + } + class Figure : Jse + { + public Figure(string name) : base(name) + { + + } + public override void Cun() + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布"); + this.FGG = int.Parse(Console.ReadLine()); + Qun qun = (Qun)FGG; + Console.WriteLine("{0}:出拳:{1}", this.name, qun); + } + } + class Npc : Jse + { + public Npc(string name) : base(name) + { + + } + + public override void Cun() + { + Random ran = new Random(); + this.FGG = ran.Next(3) + 1; + Qun qun = (Qun)FGG; + Console.WriteLine("{0}:出拳:{1}", this.name, qun); + } + } + class judge : Jse + { + public judge() + { + + } + public override void Cun() + { + + } + } + + + +} diff --git "a/\351\231\210\346\227\255/Program.cs" "b/\351\231\210\346\227\255/Program.cs" new file mode 100644 index 0000000..51ed39b --- /dev/null +++ "b/\351\231\210\346\227\255/Program.cs" @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Program + { + public enum Qun { + 剪刀=1, + 石头, + 布 + } + + static void Main(string[] args) + { + + Console.WriteLine("------欢 迎 来 到 游 戏 世 界------"); + Console.WriteLine("***********************************"); + Console.WriteLine("***********猜拳,开始**************"); + Console.WriteLine("***********************************"); + text1(); + } + + static void text1() + { + int i = 1; + Npc npc; + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Console.WriteLine("请选择对面角色(1.刘备 2.孙权 3.曹操)"); + int key = int.Parse(Console.ReadLine()); + switch (key) + { + case 1: + npc = new Npc("刘备"); + break; + case 2: + npc = new Npc("孙权"); + break; + case 3: + npc = new Npc("曹操"); + break; + default: + Console.WriteLine("输入不规范,默认对战刘备"); + npc = new Npc("刘备"); + break; + } + Console.WriteLine("请输入你的名字"); + string name = Console.ReadLine(); + Figure figure = new Figure(name); + longin: + Console.WriteLine("{0} vs {1} 对战",figure.name,npc.name); + figure.Cun(); + npc.Cun(); + text2(figure, npc); + Console.WriteLine("要不要下一轮(y/n)"); + string y = Console.ReadLine(); + switch (y) + { + case "y": + i++; + goto longin; + break; + case "n": + Console.WriteLine("{0} vs {1} 对战", figure.name, npc.name); + Console.WriteLine("对战次数"+i); + Console.WriteLine("名字\t得分"); + Console.WriteLine("{0}\t{1}",figure.name,figure.grade); + Console.WriteLine("{0}\t{1}",npc.name,npc.grade); + if (figure.grade >= npc.grade) + { + Console.WriteLine("结果,{0}赢了,{1}傻逼",figure.name, npc.name); + } + else + { + Console.WriteLine("结果,{0}赢了,{1}傻逼", npc.name, figure.name); + } + Console.WriteLine(); + Console.WriteLine("要开始下一局吗(y/n)"); + string n = Console.ReadLine(); + switch (n) + { + case "y": + + text1(); + break; + + default: + break; + } + break; + default: + break; + } + } + static void text2(Figure figure, Npc npc) + { + if (figure.FGG==npc.FGG) + { + Console.WriteLine("和局,真哀! 嘿嘿,等着瞧吧!"); + + } + else if (figure.FGG+1== npc.FGG || (figure.FGG==3 && npc.FGG==1)) + { + Console.WriteLine("傻逼,{0}输了",figure.name); + npc.grade++; + } + else + { + Console.WriteLine("牛逼,{0}赢了", figure.name); + figure.grade++; + } + } + + + } +} -- Gitee From f80558a483347a71a7dc9ad2afff7bbe4b689995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E4=BA=8C=E6=9F=B1?= <2964399941@qq.com> Date: Sun, 6 Jun 2021 22:21:56 +0800 Subject: [PATCH 60/74] =?UTF-8?q?=E6=9D=8E=E5=98=89=E5=9F=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\346\235\216\345\230\211\345\237\216/NPC.cs" | 25 ++++ .../Program.cs" | 123 ++++++++++++++++++ .../Publicinfo.cs" | 23 ++++ .../player.cs" | 24 ++++ 4 files changed, 195 insertions(+) create mode 100644 "\346\235\216\345\230\211\345\237\216/NPC.cs" create mode 100644 "\346\235\216\345\230\211\345\237\216/Program.cs" create mode 100644 "\346\235\216\345\230\211\345\237\216/Publicinfo.cs" create mode 100644 "\346\235\216\345\230\211\345\237\216/player.cs" diff --git "a/\346\235\216\345\230\211\345\237\216/NPC.cs" "b/\346\235\216\345\230\211\345\237\216/NPC.cs" new file mode 100644 index 0000000..98684c7 --- /dev/null +++ "b/\346\235\216\345\230\211\345\237\216/NPC.cs" @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class NPC : Publicinfo + { + public NPC(string name) : base(name) + { + this.Name = name; + } + public override int fist() + { + Random r = new Random(); + int a = r.Next(3) + 1; + + return a; + } + + + } +} \ No newline at end of file diff --git "a/\346\235\216\345\230\211\345\237\216/Program.cs" "b/\346\235\216\345\230\211\345\237\216/Program.cs" new file mode 100644 index 0000000..bf24655 --- /dev/null +++ "b/\346\235\216\345\230\211\345\237\216/Program.cs" @@ -0,0 +1,123 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + enum npcname + { + 刘备 = 1, + 孙权, + 曹操 + } + enum fist + { + 剪刀 = 1, + 石头, + 布 + } + class Program + { + + static void Main(string[] args) + { + int pgroud = 0; + int ngroud = 0; + int session = 0; + against(ref pgroud, ref ngroud, ref session); + against2(ref pgroud, ref ngroud, ref session); + } + public static void against2(ref int pgroud, ref int ngroud, ref int session) + { + Console.WriteLine("要开始下一局吗?1、要 2、 不要"); + int choose3 = int.Parse(Console.ReadLine()); + switch (choose3) + { + case 1: + against(ref pgroud, ref ngroud, ref session); + against2(ref pgroud, ref ngroud, ref session); + break; + case 2: + Console.WriteLine("拜了个拜"); + break; + default: + Console.WriteLine("输入错误,重新开始"); + against(ref pgroud, ref ngroud, ref session); + break; + } + } + public static void against(ref int pgroud, ref int ngroud, ref int session) + { + Console.WriteLine("----游戏即将开始----"); + Console.WriteLine("--------------------"); + Console.WriteLine("-----猜拳·开始-----"); + Console.WriteLine("--------------------"); + Console.WriteLine("出拳规则:1、剪刀 2、 石头 3、 布"); + Console.WriteLine("请选择对方角色:1、刘备 2 、孙权 3、 曹操 (请输入相应数字)"); + int choose1 = int.Parse(Console.ReadLine()); + npcname f = (npcname)choose1; + + Console.WriteLine("请输入您的名字"); + string play = Console.ReadLine(); + player player = new player(play); + game(ref f, ref pgroud, ref ngroud, ref session, ref player); + + } + + public static void game(ref npcname f, ref int pgroud, ref int ngroud, ref int session, ref player player) + { + NPC npc = new NPC(f.ToString()); + int a = player.fist(); + fist playfist = (fist)a; + int b = npc.fist(); + fist npcfist = (fist)b; + Console.WriteLine("{0}出的拳为{1}", player.Name, playfist); + Console.WriteLine("{0}出的拳为{1}", npc.Name, npcfist); + string a1 = playfist.ToString(); + string a2 = npcfist.ToString(); + judge(a1, a2, ref pgroud, ref ngroud, ref session); + Console.WriteLine("是否开始下一轮 1、继续 2 、停止 "); + int choose = int.Parse(Console.ReadLine()); + switch (choose) + { + case 1: + game(ref f, ref pgroud, ref ngroud, ref session, ref player); + break; + case 2: + Console.WriteLine("{0}对阵{1}", player.Name, npc.Name); + Console.WriteLine("对阵次数{0}", session); + Console.WriteLine("姓名 得分"); + Console.WriteLine("{0} {1}", player.Name, pgroud); + Console.WriteLine("{0} {1}", npc.Name, ngroud); + break; + default: + Console.WriteLine("输入错误,重新开始"); + game(ref f, ref pgroud, ref ngroud, ref session, ref player); + break; + } + } + + public static void judge(string player, string npcfist, ref int pgroud, ref int ngroud, ref int session) + { + if (player.Equals("石头") && npcfist.Equals("剪刀") || player.Equals("剪刀") && npcfist.Equals("布") || player.Equals("布") && npcfist.Equals("石头")) + { + Console.WriteLine("你获得胜利"); + pgroud++; + session++; + } + else if (player.Equals(npcfist)) + { + Console.WriteLine("平局了"); + session++; + } + else + { + Console.WriteLine("你输了"); + ngroud++; + session++; + } + } + } +} \ No newline at end of file diff --git "a/\346\235\216\345\230\211\345\237\216/Publicinfo.cs" "b/\346\235\216\345\230\211\345\237\216/Publicinfo.cs" new file mode 100644 index 0000000..389514e --- /dev/null +++ "b/\346\235\216\345\230\211\345\237\216/Publicinfo.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Publicinfo + { + public string Name { get; set; } + + public Publicinfo(string name) + { + Name = name; + } + public virtual int fist() + { + return 0; + } + + } +} \ No newline at end of file diff --git "a/\346\235\216\345\230\211\345\237\216/player.cs" "b/\346\235\216\345\230\211\345\237\216/player.cs" new file mode 100644 index 0000000..e2291b2 --- /dev/null +++ "b/\346\235\216\345\230\211\345\237\216/player.cs" @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class player : Publicinfo + { + public player(string name) : base(name) + { + this.Name = name; + } + public override int fist() + { + Console.WriteLine("请出拳:1、剪刀 2 、石头 3、 布 (请输入相应数字)"); + int choose2 = int.Parse(Console.ReadLine()); + return choose2; + } + + + } +} \ No newline at end of file -- Gitee From 76cbddaa4cb00e641fa9936758c5124b553e495a Mon Sep 17 00:00:00 2001 From: BMxhd796815 <2396054158@qq.com> Date: Sun, 6 Jun 2021 22:30:19 +0800 Subject: [PATCH 61/74] first commit --- .../Caipan.cs" | 37 +++++ .../Class1.cs" | 42 ++++++ .../Jiqi.cs" | 16 ++ .../Program.cs" | 140 ++++++++++++++++++ .../Wanjia.cs" | 15 ++ 5 files changed, 250 insertions(+) create mode 100644 "\345\210\230\351\237\265\345\251\267/Caipan.cs" create mode 100644 "\345\210\230\351\237\265\345\251\267/Class1.cs" create mode 100644 "\345\210\230\351\237\265\345\251\267/Jiqi.cs" create mode 100644 "\345\210\230\351\237\265\345\251\267/Program.cs" create mode 100644 "\345\210\230\351\237\265\345\251\267/Wanjia.cs" diff --git "a/\345\210\230\351\237\265\345\251\267/Caipan.cs" "b/\345\210\230\351\237\265\345\251\267/Caipan.cs" new file mode 100644 index 0000000..f05cd0b --- /dev/null +++ "b/\345\210\230\351\237\265\345\251\267/Caipan.cs" @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ZYL +{ + class Caipan : Class1 + { + private int judg; + private int judg2; + public int Judg { get => judg; set => judg = value; } + public int Judg2 { get => judg2; set => judg2 = value; } + + public Caipan(int judg, int judg2) + { + this.Judg = judg; + this.Judg2 = judg2; + } + public Caipan() { } + //写“嘻嘻嘻,玩家输了” + public int Port(int gnum, int mannum) + { + if (gnum == mannum) + { + return 0; + } + else if (gnum == 1 && mannum == 2 || gnum == 2 && mannum == 3 || gnum == 3 && mannum == 1) + { + return 1; + } + else + { + return -1; + } + } + } +} diff --git "a/\345\210\230\351\237\265\345\251\267/Class1.cs" "b/\345\210\230\351\237\265\345\251\267/Class1.cs" new file mode 100644 index 0000000..756aa0e --- /dev/null +++ "b/\345\210\230\351\237\265\345\251\267/Class1.cs" @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ZYL +{ + enum Fist + { + 石头 = 1, + 剪刀, + 布 + } + enum Man + { + 刘备 = 1, + 孙权, + 曹操 + } + + class Class1 + { + private string name; + private Fist fist; + private Man Man; + internal Man man { get => Man; set => Man = value; } + public string Name { get => name; set => name = value; } + internal Fist Fist { get => fist; set => fist = value; } + + public Class1() { } + public Class1(string name, Man man) + { + this.Name = name; + this.Fist = fist; + this.Man = man; + } + public virtual int ShowFist() + { + return 0; + } + + } +} diff --git "a/\345\210\230\351\237\265\345\251\267/Jiqi.cs" "b/\345\210\230\351\237\265\345\251\267/Jiqi.cs" new file mode 100644 index 0000000..2d36ec6 --- /dev/null +++ "b/\345\210\230\351\237\265\345\251\267/Jiqi.cs" @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ZYL +{ + class Jiqi + { + public override int ShowFist() + { + Random ran = new Random(); + int a = ran.Next(1, 4); + return a; + } + } +} diff --git "a/\345\210\230\351\237\265\345\251\267/Program.cs" "b/\345\210\230\351\237\265\345\251\267/Program.cs" new file mode 100644 index 0000000..8717bff --- /dev/null +++ "b/\345\210\230\351\237\265\345\251\267/Program.cs" @@ -0,0 +1,140 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ZYL +{ + class Program + { + static void Main(string[] args) + { + Wanjia w = new Wanjia(); + Jiqi j = new Jiqi(); + Caipan c = new Caipan(); + int aa = 0; + int bb = 0; + int cc = 0; + string flag = null; + logio: + Front(); + + Console.WriteLine("出拳规则:{0}", ListFist()); + Console.WriteLine("请选择对方角色<{0}>", Machinename()); + int key = int.Parse(Console.ReadLine()); + j.Name = ((Man)key).ToString(); + Console.WriteLine("请输入您的姓名:"); + w.Name = Console.ReadLine(); + + while (true) + { + Console.WriteLine("{0}vs{1}\t对战", w.Name, j.Name); + Console.WriteLine("开始游戏吗?(y/n)"); + flag = Console.ReadLine(); + if (flag.Equals("y")) + { + break; + } + } + while (true) + { + Console.WriteLine("\n\r请出拳:{0}(输入相应数字:)", ListFist()); + int gnum = w.ShowFist(); + int mannum = j.ShowFist(); + Console.WriteLine("{0}:出拳:{1}", w.Name, (Fist)gnum); + Console.WriteLine("{0}:出拳:{1}", j.Name, (Fist)mannum) + int a = c.Port(gnum, mannum); + User(a, w.Name); + if (a == 1) + { + cc++; + } + if (a == -1) + { + bb++; + } + aa++; + Console.WriteLine("是否开始进行下一轮?(y/n)"); + flag = Console.ReadLine(); + if (flag.Equals("n")) + { + break; + } + } + Console.WriteLine("==========================="); + Console.WriteLine("{0}\tvs\t{1}", j.Name, w.Name); + Console.WriteLine("对战次数:{0}", aa); + Console.WriteLine("姓名\t得分"); + Console.WriteLine("{0}\t{1}", w.Name, cc); + Console.WriteLine("{0}\t{1}", j.Name, bb); + if (cc > bb) + { + Console.WriteLine("胜利"); + } + else + { + Console.WriteLine("失败"); + } + Console.WriteLine("要开始进行下一轮?(y/n)"); + flag = Console.ReadLine(); + if (flag.Equals("y")) + { + aa = 0; + bb = 0; + cc = 0; + goto logio; + } + else + { + Console.WriteLine("退出"); + } + } + + private static void Front() + { + Console.WriteLine("-------------欢迎进入游戏世界---------------"); + Console.WriteLine("***************************"); + Console.WriteLine("*********猜拳,开始********"); + Console.WriteLine("***************************"); + } + + private static void User(int a, string name) + { + if (a == 0) + { + Console.WriteLine("平局"); + } + else if (a == 1) + { + Console.WriteLine("赢了", name); + } + else + { + Console.WriteLine("败了"); + } + } + + static string ListFist() + { + string fistString = ""; + int i = 1; + foreach (Fist f in Enum.GetValues(typeof(Fist))) + { + fistString += i + "、" + f + ";"; + i++; + } + return fistString; + } + + static string Machinename() + { + string fistString = ""; + int i = 1; + foreach (Man m in Enum.GetValues(typeof(Man))) + { + fistString += i + ":" + m + ";"; + i++; + } + return fistString; + } + } +} diff --git "a/\345\210\230\351\237\265\345\251\267/Wanjia.cs" "b/\345\210\230\351\237\265\345\251\267/Wanjia.cs" new file mode 100644 index 0000000..d296896 --- /dev/null +++ "b/\345\210\230\351\237\265\345\251\267/Wanjia.cs" @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ZYL +{ + class Wanjia : Class1 + { + public override int ShowFist() + { + int num = int.Parse(Console.ReadLine()); + return num; + } + } +} -- Gitee From 2bbab35b855eb04306e119151ac434fc37df26cd Mon Sep 17 00:00:00 2001 From: hzt1993 <248875989@qq.com> Date: Sun, 6 Jun 2021 22:50:43 +0800 Subject: [PATCH 62/74] first commit --- .../Game.cs" | 42 ++++++ .../Gameplayer.cs" | 16 ++ .../Judgment.cs" | 42 ++++++ .../ManMachine.cs" | 22 +++ .../Program.cs" | 140 ++++++++++++++++++ 5 files changed, 262 insertions(+) create mode 100644 "\345\207\214\345\256\217\344\270\275/Game.cs" create mode 100644 "\345\207\214\345\256\217\344\270\275/Gameplayer.cs" create mode 100644 "\345\207\214\345\256\217\344\270\275/Judgment.cs" create mode 100644 "\345\207\214\345\256\217\344\270\275/ManMachine.cs" create mode 100644 "\345\207\214\345\256\217\344\270\275/Program.cs" diff --git "a/\345\207\214\345\256\217\344\270\275/Game.cs" "b/\345\207\214\345\256\217\344\270\275/Game.cs" new file mode 100644 index 0000000..6d8673d --- /dev/null +++ "b/\345\207\214\345\256\217\344\270\275/Game.cs" @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Demo0604 +{ + //父类 + enum Fist + { + 石头=1, + 剪刀, + 布 + } + enum Man + { + 刘备 = 1, + 孙权, + 曹操 + } + + class Game + { + private string name; + private Fist fist; + private Man Man; + internal Man man { get => Man; set => Man = value; } + public string Name { get => name; set => name = value; } + internal Fist Fist { get => fist; set => fist = value; } + + public Game() { } + public Game(string name, Man man) + { + this.Name = name; + this.Fist = fist; + this.Man = man; + } + public virtual int ShowFist()//玩家人机出拳 + { + return 0; + } + } +} diff --git "a/\345\207\214\345\256\217\344\270\275/Gameplayer.cs" "b/\345\207\214\345\256\217\344\270\275/Gameplayer.cs" new file mode 100644 index 0000000..c3b71ad --- /dev/null +++ "b/\345\207\214\345\256\217\344\270\275/Gameplayer.cs" @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Demo0604 +{ + //玩家 + class Gameplayer : Game + { + public override int ShowFist() + { + int num = int.Parse(Console.ReadLine()); + return num; + } + } +} diff --git "a/\345\207\214\345\256\217\344\270\275/Judgment.cs" "b/\345\207\214\345\256\217\344\270\275/Judgment.cs" new file mode 100644 index 0000000..03140ce --- /dev/null +++ "b/\345\207\214\345\256\217\344\270\275/Judgment.cs" @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Demo0604 +{ + //裁判 + + class Judgment : Game + { + private int judg; + private int judg2; + public int Judg { get => judg; set => judg = value; } + public int Judg2 { get => judg2; set => judg2 = value; } + + public Judgment(int judg, int judg2) + { + this.Judg = judg; + this.Judg2 = judg2; + } + public Judgment() { } + //写“嘻嘻嘻,玩家输了” + public int Port(int gnum,int mannum) + { + if (gnum==mannum) + { + return 0; + } + else if (gnum == 1 && mannum == 2 || gnum == 2 && mannum == 3 || gnum == 3 && mannum == 1 ) + { + return 1; + } + else + { + return -1; + } + } + + + + } +} diff --git "a/\345\207\214\345\256\217\344\270\275/ManMachine.cs" "b/\345\207\214\345\256\217\344\270\275/ManMachine.cs" new file mode 100644 index 0000000..7eb49d2 --- /dev/null +++ "b/\345\207\214\345\256\217\344\270\275/ManMachine.cs" @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Demo0604 +{ + //人机 + + + class ManMachine:Game + { + //随机数 + public override int ShowFist() + { + Random ran = new Random(); + int a = ran.Next(1, 4); + return a; + } + + + } +} diff --git "a/\345\207\214\345\256\217\344\270\275/Program.cs" "b/\345\207\214\345\256\217\344\270\275/Program.cs" new file mode 100644 index 0000000..2bd5534 --- /dev/null +++ "b/\345\207\214\345\256\217\344\270\275/Program.cs" @@ -0,0 +1,140 @@ +using System; + +namespace Demo0604 +{ + class Program + { + static void Main(string[] args) + { + //变量&引用 + Gameplayer g = new Gameplayer();//玩家 + ManMachine man = new ManMachine();//人机 + Judgment jud = new Judgment();//裁判 + int time = 0;//总次数 + int r=0;//人机 + int w = 0;//玩家 + string flag = null; + logio: + Front();//开头 + + Console.WriteLine("出拳规则:{0}",ListFist()); + Console.WriteLine("请选择对方角色<{0}>",Machinename()); + int key = int.Parse(Console.ReadLine()); + man.Name = ((Man)key).ToString();//人机姓名 + Console.WriteLine("请输入您的姓名:"); + g.Name= Console.ReadLine();//玩家姓名 + //循环1 + while (true) + { + Console.WriteLine("{0}vs{1}\t对战",g.Name,man.Name); + Console.WriteLine("开始游戏吗?(y/n)"); + flag = Console.ReadLine(); + if (flag.Equals("y")) + { + break; + } + } + while (true) + { + Console.WriteLine("\n\r请出拳:{0}(输入相应数字:)",ListFist()); + int gnum = g.ShowFist();//玩家出拳 + int mannum = man.ShowFist();//人机出拳 + Console.WriteLine("{0}:出拳:{1}",g.Name,(Fist)gnum); + Console.WriteLine("{0}:出拳:{1}",man.Name,(Fist)mannum);//随机数 + int a = jud.Port(gnum,mannum); + User(a,g.Name); + if (a==1) + { + w++; + } + if (a==-1) + { + r++; + } + time++; + Console.WriteLine("是否开始进行下一轮?(y/n)"); + flag = Console.ReadLine(); + if (flag.Equals("n")) + { + break; + } + } + Console.WriteLine("==========================="); + Console.WriteLine("{0}\tvs\t{1}",man.Name,g.Name); + Console.WriteLine("对战次数:{0}",time); + Console.WriteLine("姓名\t得分"); + Console.WriteLine("{0}\t{1}",g.Name,w); + Console.WriteLine("{0}\t{1}",man.Name,r); + if (w>r) + { + Console.WriteLine("你赢了"); + } + else + { + Console.WriteLine("你输了"); + } + Console.WriteLine("要开始进行下一轮?(y/n)"); + flag = Console.ReadLine(); + if (flag.Equals("y")) + { + time = 0; + r = 0; + w = 0; + goto logio; + } + else + { + Console.WriteLine("系统退出!"); + } + } + + private static void Front() + { + //开头 + Console.WriteLine("-------------欢迎进入游戏世界---------------"); + Console.WriteLine("***************************"); + Console.WriteLine("*********猜拳,开始********"); + Console.WriteLine("***************************"); + } + + private static void User(int a,string name) + { + if (a == 0) + { + Console.WriteLine("和局"); + } + else if (a == 1) + { + Console.WriteLine("恭喜,{0}赢了",name); + } + else + { + Console.WriteLine("你输了!"); + } + } + //剪刀石头布 + static string ListFist() + { + string fistString = ""; + int i = 1; + foreach (Fist f in Enum.GetValues(typeof(Fist)) ) + { + fistString += i + "、" + f + ";"; + i++; + } + return fistString; + } + //人机名字 + static string Machinename() + { + string fistString = ""; + int i = 1; + foreach (Man m in Enum.GetValues(typeof(Man))) + { + fistString += i + ":" + m + ";"; + i++; + } + return fistString; + } + } +} -- Gitee From b72580554dceef1ca793fe08fc5b0ed4bcd45f3f Mon Sep 17 00:00:00 2001 From: huangziyi <3120130015@qq.com> Date: Sun, 6 Jun 2021 22:57:59 +0800 Subject: [PATCH 63/74] first commit1 --- .../Game.cs" | 41 +++++ .../Judgment.cs" | 41 +++++ .../ManMachine.cs" | 22 +++ .../Player.cs" | 17 +++ .../Program.cs" | 140 ++++++++++++++++++ 5 files changed, 261 insertions(+) create mode 100644 "\351\273\204\345\255\220\346\200\241/Game.cs" create mode 100644 "\351\273\204\345\255\220\346\200\241/Judgment.cs" create mode 100644 "\351\273\204\345\255\220\346\200\241/ManMachine.cs" create mode 100644 "\351\273\204\345\255\220\346\200\241/Player.cs" create mode 100644 "\351\273\204\345\255\220\346\200\241/Program.cs" diff --git "a/\351\273\204\345\255\220\346\200\241/Game.cs" "b/\351\273\204\345\255\220\346\200\241/Game.cs" new file mode 100644 index 0000000..dc856a6 --- /dev/null +++ "b/\351\273\204\345\255\220\346\200\241/Game.cs" @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ConsoleApp1 +{ + enum Fist + { + 石头 = 1, + 剪刀, + 布 + } + enum Man + { + 刘备 = 1, + 孙权, + 曹操 + } + + class Game + { + private string name; + private Fist fist; + private Man Man; + internal Man man { get => Man; set => Man = value; } + public string Name { get => name; set => name = value; } + internal Fist Fist { get => fist; set => fist = value; } + + public Game() { } + public Game(string name, Man man) + { + this.Name = name; + this.Fist = fist; + this.Man = man; + } + public virtual int ShowFist()//玩家人机出拳 + { + return 0; + } + } +} \ No newline at end of file diff --git "a/\351\273\204\345\255\220\346\200\241/Judgment.cs" "b/\351\273\204\345\255\220\346\200\241/Judgment.cs" new file mode 100644 index 0000000..ab604a7 --- /dev/null +++ "b/\351\273\204\345\255\220\346\200\241/Judgment.cs" @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ConsoleApp1 +{ + class Judgment + { + private class Judgments : Game + { + private int judg; + private int judg2; + public int Judg { get => judg; set => judg = value; } + public int Judg2 { get => judg2; set => judg2 = value; } + + public Judgments(int judg, int judg2) + { + this.Judg = judg; + this.Judg2 = judg2; + } + public Judgments() { } + //写“嘻嘻嘻,玩家输了” + public int Port(int gnum, int mannum) + { + if (gnum == mannum) + { + return 0; + } + else if (gnum == 1 && mannum == 2 || gnum == 2 && mannum == 3 || gnum == 3 && mannum == 1) + { + return 1; + } + else + { + return -1; + } + } + } + } +} + diff --git "a/\351\273\204\345\255\220\346\200\241/ManMachine.cs" "b/\351\273\204\345\255\220\346\200\241/ManMachine.cs" new file mode 100644 index 0000000..7eb49d2 --- /dev/null +++ "b/\351\273\204\345\255\220\346\200\241/ManMachine.cs" @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Demo0604 +{ + //人机 + + + class ManMachine:Game + { + //随机数 + public override int ShowFist() + { + Random ran = new Random(); + int a = ran.Next(1, 4); + return a; + } + + + } +} diff --git "a/\351\273\204\345\255\220\346\200\241/Player.cs" "b/\351\273\204\345\255\220\346\200\241/Player.cs" new file mode 100644 index 0000000..5fac3ec --- /dev/null +++ "b/\351\273\204\345\255\220\346\200\241/Player.cs" @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ConsoleApp1 +{ + class Player: Game + { + + public override int ShowFist() + { + int num = int.Parse(Console.ReadLine()); + return num; + } + } + } + \ No newline at end of file diff --git "a/\351\273\204\345\255\220\346\200\241/Program.cs" "b/\351\273\204\345\255\220\346\200\241/Program.cs" new file mode 100644 index 0000000..6c1e8e4 --- /dev/null +++ "b/\351\273\204\345\255\220\346\200\241/Program.cs" @@ -0,0 +1,140 @@ +using System; + +namespace Demo0604 +{ + class Program + { + static void Main(string[] args) + { + //变量&引用 + Gameplayer g = new Gameplayer();//玩家 + ManMachine man = new ManMachine();//人机 + Judgment jud = new Judgment();//裁判 + int time = 0;//总次数 + int r=0;//人机 + int w = 0;//玩家 + string flag = null; + logio: + Front();//开头 + + Console.WriteLine("出拳规则:{0}",ListFist()); + Console.WriteLine("请选择对方角色<{0}>",Machinename()); + int key = int.Parse(Console.ReadLine()); + man.Name = ((Man)key).ToString();//人机姓名 + Console.WriteLine("请输入您的姓名:"); + g.Name= Console.ReadLine();//玩家姓名 + //循环1 + while (true) + { + Console.WriteLine("{0}vs{1}\t对战",g.Name,man.Name); + Console.WriteLine("开始游戏吗?(y/n)"); + flag = Console.ReadLine(); + if (flag.Equals("y")) + { + break; + } + } + while (true) + { + Console.WriteLine("\n\r请出拳:{0}(输入相应数字:)",ListFist()); + int gnum = g.ShowFist();//玩家出拳 + int mannum = man.ShowFist();//人机出拳 + Console.WriteLine("{0}:出拳:{1}",g.Name,(Fist)gnum); + Console.WriteLine("{0}:出拳:{1}",man.Name,(Fist)mannum);//随机数 + int a = jud.Port(gnum,mannum); + User(a,g.Name); + if (a==1) + { + w++; + } + if (a==-1) + { + r++; + } + time++; + Console.WriteLine("是否开始进行下一轮?(y/n)"); + flag = Console.ReadLine(); + if (flag.Equals("n")) + { + break; + } + } + Console.WriteLine("==========================="); + Console.WriteLine("{0}\tvs\t{1}",man.Name,g.Name); + Console.WriteLine("对战次数:{0}",time); + Console.WriteLine("姓名\t得分"); + Console.WriteLine("{0}\t{1}",g.Name,w); + Console.WriteLine("{0}\t{1}",man.Name,r); + if (w>r) + { + Console.WriteLine("你赢了。"); + } + else + { + Console.WriteLine("你输了"); + } + Console.WriteLine("要开始进行下一轮?(y/n)"); + flag = Console.ReadLine(); + if (flag.Equals("y")) + { + time = 0; + r = 0; + w = 0; + goto logio; + } + else + { + Console.WriteLine("系统退出!"); + } + } + + private static void Front() + { + //开头 + Console.WriteLine("-------------欢迎进入游戏世界---------------"); + Console.WriteLine("***************************"); + Console.WriteLine("*********猜拳,开始********"); + Console.WriteLine("***************************"); + } + + private static void User(int a,string name) + { + if (a == 0) + { + Console.WriteLine("和局,真衰!呵呵,等着瞧吧!"); + } + else if (a == 1) + { + Console.WriteLine("恭喜,{0}赢了",name); + } + else + { + Console.WriteLine("嘿,笨蛋,你输了!"); + } + } + //剪刀石头布 + static string ListFist() + { + string fistString = ""; + int i = 1; + foreach (Fist f in Enum.GetValues(typeof(Fist)) ) + { + fistString += i + "、" + f + ";"; + i++; + } + return fistString; + } + //人机名字 + static string Machinename() + { + string fistString = ""; + int i = 1; + foreach (Man m in Enum.GetValues(typeof(Man))) + { + fistString += i + ":" + m + ";"; + i++; + } + return fistString; + } + } +} -- Gitee From dbbc0ef20dd8bea291cf463dd8859a35ef279cb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=E6=A2=A6=E6=9E=97?= <2777141796@qq.com> Date: Sun, 6 Jun 2021 23:01:38 +0800 Subject: [PATCH 64/74] =?UTF-8?q?=E7=A9=BA=E4=BD=A0=E5=87=A0=E7=93=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\346\235\250\346\242\246\346\236\227/Cp.cs" | 144 ++++++++++++++++++ .../Dian.cs" | 66 ++++++++ .../Player.cs" | 34 +++++ .../Program.cs" | 32 ++++ "\346\235\250\346\242\246\346\236\227/Wan.cs" | 38 +++++ 5 files changed, 314 insertions(+) create mode 100644 "\346\235\250\346\242\246\346\236\227/Cp.cs" create mode 100644 "\346\235\250\346\242\246\346\236\227/Dian.cs" create mode 100644 "\346\235\250\346\242\246\346\236\227/Player.cs" create mode 100644 "\346\235\250\346\242\246\346\236\227/Program.cs" create mode 100644 "\346\235\250\346\242\246\346\236\227/Wan.cs" diff --git "a/\346\235\250\346\242\246\346\236\227/Cp.cs" "b/\346\235\250\346\242\246\346\236\227/Cp.cs" new file mode 100644 index 0000000..3217746 --- /dev/null +++ "b/\346\235\250\346\242\246\346\236\227/Cp.cs" @@ -0,0 +1,144 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Cp + + //裁判 + { + static Computer computer = new Computer(); + static Useplay user = new Useplay(); + public bool statr(String inputName, String computName) + { + int comWinCount = 0; + int userWinCount = 0; + bool flag = false; + int count = 1; + string j; + Console.WriteLine("准备开始游戏了吗(y/n)"); + j = Console.ReadLine(); + if (j.Equals("y")) + { + m: do + { + count++; + //玩家出拳 + int userValue = user.getInputWhat(); + Console.WriteLine(inputName + "出拳: "); + //电脑出拳 + int comValue = computer.getInputWhat(); + Console.WriteLine(computName + "出拳: "); + //裁判比较 + int result = compare(comValue, userValue); + if (result == 1) + { + Console.WriteLine("笨蛋," + computName + "赢了"); + comWinCount++; + } + else if (result == -1) + { + Console.WriteLine("笨蛋," + inputName + "赢了"); + userWinCount++; + } + else + { + Console.WriteLine("嘿嘿,和局真衰,等着瞧吧"); + } + Console.WriteLine("准备开始游戏了吗(y/n)"); + j = Console.ReadLine(); + switch (j) + { + case "y": + flag = true; + break; + case "n": + Console.WriteLine("=========================================="); + Console.WriteLine(inputName + " VS " + computName); + Console.WriteLine("对战次数" + count); + Console.WriteLine(); + Console.WriteLine("姓名\t\t得分"); + Console.WriteLine(inputName + "\t\t" + userWinCount); + Console.WriteLine(computName + "\t\t" + comWinCount); + if (userWinCount > comWinCount) + { + Console.WriteLine(inputName + "赢"); + } + else if (userWinCount > comWinCount) + { + Console.WriteLine(computName + "赢"); + } + else + { + Console.WriteLine("平局"); + } + Console.WriteLine("退出系统"); + break; + } + goto m; + } while (flag); + } + else if (j.Equals("n")) + { + Console.WriteLine("系统退出"); + } + return flag; + } + public int compare(int computerValue, int userValue) + { + if (computerValue == userValue) + { + return 0; + } + else if (computerValue == 1)//1 剪刀 + { + if (userValue == 2)//1 石头 + { + return -1; + } + else//3 布 + { + return 1; + } + } + else if (computerValue == 2)//2 石头 + { + if (userValue == 1)// 1 剪刀 + { + return 1; + } + else//3 布 + { + return -1; + } + } + else//3 computerValue==布 + { + if (userValue == 2)//石头 + { + return 1; + } + else// 1 剪刀 + { + return -1; + } + } + //public enum Result + //{ + // 电脑赢, 玩家赢, 平局 + //} + //public static Result caipan(int playerNum, int cpuNum) + //{ + // if ((playerNum - cpuNum) == 1 || (playerNum - cpuNum) == -2) + // return Result.玩家赢; + // else if ((playerNum - cpuNum) == 0) + // return Result.平局; + // else + // return Result.电脑赢; + //} + } + } +} diff --git "a/\346\235\250\346\242\246\346\236\227/Dian.cs" "b/\346\235\250\346\242\246\346\236\227/Dian.cs" new file mode 100644 index 0000000..4c07c55 --- /dev/null +++ "b/\346\235\250\346\242\246\346\236\227/Dian.cs" @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Dian:Cheng + // + { + public string name { get; set; } + static Random rand = new Random(); + public override int getInputWhat() + { + int value = rand.Next(1, 4); + if (value == 1) + { + Console.WriteLine(""); + } + else if (value == 2) + { + Console.WriteLine("ʯͷ"); + } + else if (value == 3) + { + Console.WriteLine(""); + } + return value; + } + + public string getPlayerName(int num) + { + if (num == 1) + { + name = ""; + } + else if (num == 2) + { + name = "Ȩ"; + } + else if (num == 3) + { + name = "ܲ"; + } + return name; + } + //public string fist + //{ + // get; + // set; + //} + //public int cpuShowFist() + //{ + // Random r = new Random(); + // int cnum = r.Next(1, 4); + // switch (cnum) + // { + // case 1: this.fist = ""; break; + // case 2: this.fist = "ʯͷ"; break; + // case 3: this.fist = ""; break; + // } + // return cnum; + //} + } +} diff --git "a/\346\235\250\346\242\246\346\236\227/Player.cs" "b/\346\235\250\346\242\246\346\236\227/Player.cs" new file mode 100644 index 0000000..271a9fd --- /dev/null +++ "b/\346\235\250\346\242\246\346\236\227/Player.cs" @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + abstract class Cheng + { + public string Name { get; set; } + public string What { get; set; } + public string Result { get; set; } + public Player() + { + + } + public abstract int getInputWhat(); + + //public int showFist(string str) + //{ + // int num = 0; + // switch (str) + // { + // case "剪刀": num = 1; break; + // case "石头": num = 2; break; + // case "布": num = 3; break; + + // } + // return num; + + //} + } +} diff --git "a/\346\235\250\346\242\246\346\236\227/Program.cs" "b/\346\235\250\346\242\246\346\236\227/Program.cs" new file mode 100644 index 0000000..f61a3de --- /dev/null +++ "b/\346\235\250\346\242\246\346\236\227/Program.cs" @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Program + { + static void Main(string[] args) + { + Computer computer = new Computer(); + Useplay user = new Useplay(); + Caipan c = new Caipan(); + Console.WriteLine("----------------------ӭϷ-------------------------"); + Console.WriteLine("**********************************************"); + Console.WriteLine("******************ȭʼ******************"); + Console.WriteLine("**********************************************"); + Console.WriteLine("ȭ:1.2.ʯͷ3."); + Console.WriteLine("ѡԷɫ1. 2.Ȩ 3.ܲ"); + int num = int.Parse(Console.ReadLine()); + string computerName = computer.getPlayerName(num); + Console.WriteLine(""); + string userName = Console.ReadLine(); + string personName = user.PersonName(userName); + Console.WriteLine(computerName + " VS " + personName + " ս"); + Caipan.Equals(userName, computerName); + Console.WriteLine("׼ʼϷ(y/n)"); + } + } +} diff --git "a/\346\235\250\346\242\246\346\236\227/Wan.cs" "b/\346\235\250\346\242\246\346\236\227/Wan.cs" new file mode 100644 index 0000000..62c5450 --- /dev/null +++ "b/\346\235\250\346\242\246\346\236\227/Wan.cs" @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Wan:Cheng + //玩家 + { + public string name { get; set; } + public String PersonName(String inputName) + { + this.name = inputName; + return this.name; + } + public override int getInputWhat() + { + Console.WriteLine("请出拳:1.剪刀 2.石头3.布"); + int value = int.Parse(Console.ReadLine()); + if (value == 1) + { + Console.WriteLine("剪刀"); + } + else if (value == 2) + { + Console.WriteLine("石头"); + } + else if (value == 3) + { + Console.WriteLine("布"); + } + return value; + + } + } +} -- Gitee From 598e137ffcab028e92e860ddd09a822e0c51e0f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=8F=B6=E5=B8=85?= <2876015251@qq.com> Date: Sun, 6 Jun 2021 23:06:20 +0800 Subject: [PATCH 65/74] =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Program.cs" | 192 ++++++++++++++++++ 1 file changed, 192 insertions(+) create mode 100644 "\351\273\204\345\217\266\345\270\205/Program.cs" diff --git "a/\351\273\204\345\217\266\345\270\205/Program.cs" "b/\351\273\204\345\217\266\345\270\205/Program.cs" new file mode 100644 index 0000000..5928c6f --- /dev/null +++ "b/\351\273\204\345\217\266\345\270\205/Program.cs" @@ -0,0 +1,192 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + + class Program + + { + public enum Fist + { + 剪刀 = 1, + 石头, + 布 + } + public static string name; + static int x = 0; + static int y = 0; + static int sum = x+y; + static string npc = null; + private static object yes; + private static object no; + + static void Main(string[] args) + { + Console.WriteLine("-----------------------欢迎进入游戏世界---------------"); + Console.WriteLine("******************************"); + Console.WriteLine("**********猜拳,开始**********"); + Console.WriteLine("******************************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Console.WriteLine("请选择对方角色:<1:刘备 2:孙策 3:曹操>"); + int key = int.Parse(Console.ReadLine()); + Console.WriteLine("请输入您的名字:"); + name = Console.ReadLine(); + + + switch (key) + { + case 1: + npc = "刘备"; + Console.WriteLine($"{name} VS {npc} 对战"); + break; + case 2: + npc = "孙策"; + Console.WriteLine(name + "VS" + "孙策 对战"); + break; + case 3: + npc = "曹操"; + Console.WriteLine(name + "VS" + "曹操 对战"); + break; + + default: + break; + } + Task1(npc); + Task2(); + + + + + } + + private static void Task2() + { + Console.WriteLine("是否要开始下一局?"); + string xyj = Console.ReadLine(); + switch (xyj) + { + case "yes": + Fist a = userFist(); + Fist b = npcFist(); + Console.WriteLine(name + ": 出拳:{0}", a); + Console.WriteLine(npc+": 出拳:{0}",b); + int c = (int)a; + int d = (int)b; + Task(c, d); + Task2(); + break; + case "no": + Console.WriteLine("==============================="); + Console.WriteLine($"{npc}VS{name}"); + Console.WriteLine("姓名 得分"); + Console.WriteLine("{0}", name); + Console.WriteLine("{0}", npc); + Console.WriteLine($"结果:{name}赢,{npc}输"); + Console.WriteLine("要开下一局吗?"); + Task2(); + break; + + + + + + + + default: + break; + } + + } + + + + static Fist npcFist() + { + Random red = new Random(); + int s = red.Next(1, 4); + Fist fist = (Fist)s; + return fist; + } + static Fist userFist() + { + + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应数字)"); + int b = int.Parse(Console.ReadLine()); + Fist fist = (Fist)b; + return fist; + } + + private static void Task1(string npc) + { + Console.WriteLine("开始游戏?"); + string yn = Console.ReadLine(); + if (yn.Equals ("yes")) + { + Fist a = userFist(); + Fist b = npcFist(); + Console.WriteLine(name + ": 出拳:{0}", a); + Console.WriteLine($"{npc}: 出拳:{b}"); + int c = (int)a; + int d = (int)b; + Task(c, d); + } + else if (yn.Equals("no")) + { + Console.WriteLine("==============================="); + Console.WriteLine($"{npc}VS{name}"); + Console.WriteLine("姓名 得分"); + Console.WriteLine($"{name} {x}"); + Console.WriteLine($"{npc} {y}"); + Console.WriteLine("结果:{name}赢,{npc}输"); + Console.WriteLine("要开下一局吗?"); + Task2(); + + + + } + + + } + + private static void Task(int a, int b) + { + if (a == b) + { + Console.WriteLine("和局,嘿嘿,等着瞧"); + } + else if ((a == 1 && b == 2) || (a == 2 && b == 3)|| (a == 3 && b == 1)) + { + Console.WriteLine($"恭喜{name}赢"); + x += 1; + } + else + { + Console.WriteLine("输"); + y += 1; + } + } + + + + + + + + + + + + + + + + + + + + } +} -- Gitee From 14affeb7715c50aa74bb28a7c64eb203b44079da Mon Sep 17 00:00:00 2001 From: adios <1347358158@qq.com> Date: Sun, 6 Jun 2021 23:55:10 +0800 Subject: [PATCH 66/74] =?UTF-8?q?=E6=96=B0=E5=BB=BA=20=E6=A2=81=E4=B8=96?= =?UTF-8?q?=E8=B4=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\346\242\201\344\270\226\350\264\244/.keep" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "\346\242\201\344\270\226\350\264\244/.keep" diff --git "a/\346\242\201\344\270\226\350\264\244/.keep" "b/\346\242\201\344\270\226\350\264\244/.keep" new file mode 100644 index 0000000..e69de29 -- Gitee From 746abe0f438f41e8bb9aaa60d447dfef34bab68a Mon Sep 17 00:00:00 2001 From: adios <1347358158@qq.com> Date: Sun, 6 Jun 2021 23:55:48 +0800 Subject: [PATCH 67/74] =?UTF-8?q?=E6=A2=81=E4=B8=96=E8=B4=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Program.cs" | 245 ++++++++++++++++++ 1 file changed, 245 insertions(+) create mode 100644 "\346\242\201\344\270\226\350\264\244/Program.cs" diff --git "a/\346\242\201\344\270\226\350\264\244/Program.cs" "b/\346\242\201\344\270\226\350\264\244/Program.cs" new file mode 100644 index 0000000..e01eb07 --- /dev/null +++ "b/\346\242\201\344\270\226\350\264\244/Program.cs" @@ -0,0 +1,245 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp4 +{ + class Hero + { + private string name; + public string Name + { + get { return this.name; } + set { this.name = value; } + } + public Hero(string Name) + { + this.name = Name; + } + public Hero() + { + + } + } + enum Fist + { + 石头 = 1, + 剪刀, + 布 + } + enum Yx + { + 刘备 = 1, + 孙权, + 曹操 + } + + class Program + { + //玩家姓名 + static string xm; + //对手姓名 + static Yx name; + //实例化随机数 + static Random sz = new Random(); + //计算分数 + static int playersum = 0, robotsum = 0, gamesum = 0; + static void Main(string[] args) + { + Console.WriteLine("---------------欢迎进入游戏世界---------------"); + Console.WriteLine(); + Console.WriteLine("*************************************"); + Console.WriteLine("**********猜拳··开始!!!*********"); + Console.WriteLine("*************************************"); + Console.WriteLine("出拳规则:1.剪刀2.石头3.布"); + pk(); + Console.ReadKey(); + } + static string listfist() + { + string fiststring = ""; + int i = 1; + foreach (Fist f in Enum.GetValues(typeof(Fist))) + { + fiststring += i + "、" + f + ";"; + i++; + } + return fiststring; + } + static string listyx() + { + string yxstring = ""; + int i = 1; + foreach (Yx f in Enum.GetValues(typeof(Yx))) + { + yxstring += i + "、" + f + ";"; + i++; + } + return yxstring; + } + static void pk() + { + Console.WriteLine("请选择对方角色{0}", listyx()); + int jx = int.Parse(Console.ReadLine()); + name = (Yx)jx; + Console.WriteLine("请输入你的姓名:"); + xm = Console.ReadLine(); + Console.WriteLine("{0} vs {1} 对战!", xm, name); + Console.WriteLine("开始游戏吗?(y/n)"); + string begin = Console.ReadLine(); + if (begin == "y") + { + confrontation(); + } + else if (begin == "n") + { + end(); + } + } + static void confrontation() + { + Console.WriteLine("请出拳:{0}(输入相应数字:)", listfist()); + int guess = int.Parse(Console.ReadLine()); + //我方出拳 + Fist fname = (Fist)guess; + //对手出拳 + int cq = sz.Next(1, 4); + Fist q = (Fist)cq; + int qq = (int)q; + switch (guess) + { + case 1: + Console.WriteLine("{0}:出拳:{1}", xm, fname); + Console.WriteLine("{0}:出拳:{1}", name, q); + if (qq.Equals(3)) + { + Console.WriteLine("{0}输了,不要害怕失败大不了从头来过!", xm); + robotsum++; + gamesum++; + } + else if (fname.Equals(q)) + { + Console.WriteLine("和局,真倒霉!你个王八犊子等着瞧!"); + gamesum++; + } + else + { + Console.WriteLine("芜湖!{0}赢了!", xm); + playersum++; + gamesum++; + } + circulation(); + break; + case 2: + Console.WriteLine("{0}:出拳:{1}", xm, fname); + Console.WriteLine("{0}:出拳:{1}", name, q); + if (qq.Equals(1)) + { + Console.WriteLine("{0}输了,不要害怕失败大不了从头来过!", xm); + robotsum++; + gamesum++; + } + else if (fname.Equals(q)) + { + Console.WriteLine("和局,真倒霉!你个王八犊子等着瞧!"); + gamesum++; + } + else + { + Console.WriteLine("芜湖!{0}赢了!", xm); + playersum++; + gamesum++; + } + circulation(); + break; + case 3: + Console.WriteLine("{0}:出拳:{1}", xm, fname); + Console.WriteLine("{0}:出拳:{1}", name, q); + if (qq.Equals(2)) + { + Console.WriteLine("{0}输了,不要害怕失败大不了从头来过!", xm); + robotsum++; + gamesum++; + } + else if (fname.Equals(q)) + { + Console.WriteLine("和局,真倒霉!你个王八犊子等着瞧!"); + gamesum++; + } + else + { + Console.WriteLine("芜湖!{0}赢了!", xm); + playersum++; + gamesum++; + } + circulation(); + break; + default: + Console.WriteLine("没有该选项!"); + break; + } + } + static void end() + { + Console.WriteLine(); + Console.WriteLine(); + Console.WriteLine("===================================="); + Console.WriteLine("{0} vs {1}", name, xm); + Console.WriteLine("对战次数:{0}", gamesum); + Console.WriteLine(); + Console.WriteLine("姓名\t得分"); + Console.WriteLine("{0}\t{1}", xm, playersum); + Console.WriteLine("{0}\t{1}", name, robotsum); + if (playersum > robotsum) + { + Console.WriteLine("结果:{0}赢,{1}输了", xm, name); + } + else if (playersum < robotsum) + { + Console.WriteLine("结果:{0}赢,{1}输了", name, xm); + } + else + { + Console.WriteLine("结果:似乎平局了哦"); + } + cx: + Console.WriteLine("要开始下一局吗?(y/n)"); + string newgame = Console.ReadLine(); + if (newgame == "y") + { + playersum = 0; robotsum = 0; gamesum = 0; + pk(); + } + else if (newgame == "n") + { + Console.WriteLine("系统退出"); + } + else + { + Console.WriteLine("没有该选项请重新选择"); + goto cx; + } + } + static void circulation() + { + cx: + Console.WriteLine("是否开启下一轮?(y/n)"); + string next = Console.ReadLine(); + if (next == "y") + { + confrontation(); + } + else if (next == "n") + { + end(); + } + else + { + Console.WriteLine("没有该选项!重新选择!"); + goto cx; + } + } + } +} -- Gitee From cc950e72565866f03190c768d6b98abe10d09945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=9F1=E6=B4=8B?= <2357323419@qq.com> Date: Mon, 7 Jun 2021 00:32:29 +0800 Subject: [PATCH 68/74] =?UTF-8?q?=E6=B1=9F=E6=B4=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\346\261\237\346\264\213/Program.cs" | 123 ++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 "\346\261\237\346\264\213/Program.cs" diff --git "a/\346\261\237\346\264\213/Program.cs" "b/\346\261\237\346\264\213/Program.cs" new file mode 100644 index 0000000..51222ca --- /dev/null +++ "b/\346\261\237\346\264\213/Program.cs" @@ -0,0 +1,123 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + enum yingxiong { + 刘备=1, + 孙权, + 曹操 + } + enum jdstb { + 剪刀=1, + 石头, + 布 + } + class Program + { + static string str; + static int a; + static void Main(string[] args) + { + jy(); + } + + private static void jy() + { + Console.WriteLine("--------------欢\t迎\t进\t入\t游\t戏\t世\t界--------------"); + Console.WriteLine("******************************"); + Console.WriteLine("**********猜拳,开始**********"); + Console.WriteLine("******************************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Console.WriteLine("请选择对方角色<1:刘备 2:孙权 3:曹操>"); + a = int.Parse(Console.ReadLine()); + yingxiong b = (yingxiong)a; + Console.WriteLine("请输入您的姓名:"); + str = Console.ReadLine(); + Console.WriteLine("{0} vs {1} 对战", str, b); + Console.WriteLine("开始游戏吗?"); + string key = Console.ReadLine(); + switch (key) + { + case "y": + //Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应数字:)"); + //int quan = int.Parse(Console.ReadLine()); + //jdstb p = (jdstb)quan; + //Console.WriteLine("{0}:出拳:{1}", str, p); + //Random ran = new Random(); + //int d = 1 + ran.Next(3); + //jdstb s = (jdstb)d; + //Console.WriteLine("{0}:出拳:{1}", b, s); + //if (quan==d) { + // Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + //} + jy1(); + break; + case "n": + jy2(); + break; + default: + break; + } + } + private static void jy1() + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应数字:)"); + int quan = int.Parse(Console.ReadLine()); + jdstb p = (jdstb)quan; + Console.WriteLine("{0}:出拳:{1}", str, p); + Random ran = new Random(); + int d = 1 + ran.Next(3); + jdstb s = (jdstb)d; + yingxiong b = (yingxiong)a; + Console.WriteLine("{0}:出拳:{1}", b, s); + if (quan == d) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + xyl(); + } + else if (quan == 1 && d == 2 || quan == 2 && d == 3 || quan == 3 && d == 1) + { + Console.WriteLine("傻逼{0},人机都玩不过!!!", str); + xyl(); + } + else if (quan == 1 && d == 3 || quan == 2 && d == 1 || quan == 3 && d == 2) + { + Console.WriteLine("恭喜{0},赢了!!!", str); + xyl(); + } + else { + Console.WriteLine("输入错误"); + } + } + + private static void xyl() + { + Console.WriteLine("是否开始下一轮?"); + string key = Console.ReadLine(); + switch (key) + { + case "y": + jy1(); + break; + case "n": + + break; + default: + break; + } + } + + private static void jy2() + { + } + + + + + + } +} -- Gitee From eb6e5a162f17e806d911e125e02750523df7c9f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=AB=E6=84=81=E5=95=8A=E4=B8=B6?= <2486779710@qq.com> Date: Mon, 7 Jun 2021 07:01:17 +0800 Subject: [PATCH 69/74] =?UTF-8?q?=E6=96=B0=E5=BB=BA=20=E5=88=98=E9=BE=99?= =?UTF-8?q?=E5=86=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\345\210\230\351\276\231\345\206\260/.keep" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "\345\210\230\351\276\231\345\206\260/.keep" diff --git "a/\345\210\230\351\276\231\345\206\260/.keep" "b/\345\210\230\351\276\231\345\206\260/.keep" new file mode 100644 index 0000000..e69de29 -- Gitee From 1c8f0333642e046d5607d16d414bd75e3f6bd06d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=AB=E6=84=81=E5=95=8A=E4=B8=B6?= <2486779710@qq.com> Date: Mon, 7 Jun 2021 07:03:45 +0800 Subject: [PATCH 70/74] =?UTF-8?q?add=20=E5=88=98=E9=BE=99=E5=86=B0/Father.?= =?UTF-8?q?cs.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Father.cs" | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 "\345\210\230\351\276\231\345\206\260/Father.cs" diff --git "a/\345\210\230\351\276\231\345\206\260/Father.cs" "b/\345\210\230\351\276\231\345\206\260/Father.cs" new file mode 100644 index 0000000..9af191f --- /dev/null +++ "b/\345\210\230\351\276\231\345\206\260/Father.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + + +namespace ConsoleApp1 +{ + abstract class Father + { + public static string[] fist ={ "石头","剪刀","布" }; + + + private string name; + public string Name { get => name; set => name = value; } + + + + public Father(string Name) + { + this.name = Name; + } + public abstract void Play(); + } +} \ No newline at end of file -- Gitee From 506de7c44588fdb1c872c09129e0199cdd8a636a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=AB=E6=84=81=E5=95=8A=E4=B8=B6?= <2486779710@qq.com> Date: Mon, 7 Jun 2021 07:04:25 +0800 Subject: [PATCH 71/74] =?UTF-8?q?add=20=E5=88=98=E9=BE=99=E5=86=B0/Gamepeo?= =?UTF-8?q?ple.cs.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Gamepeople.cs" | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 "\345\210\230\351\276\231\345\206\260/Gamepeople.cs" diff --git "a/\345\210\230\351\276\231\345\206\260/Gamepeople.cs" "b/\345\210\230\351\276\231\345\206\260/Gamepeople.cs" new file mode 100644 index 0000000..a3a9988 --- /dev/null +++ "b/\345\210\230\351\276\231\345\206\260/Gamepeople.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Gamepeople:Father + { + public string fisttype; + public static int gamescore; + public Gamepeople(string Name):base(Name) {} + + + + + public override void Play() + { + Console.WriteLine(base.Name + ":" + " 出拳:" +this.fisttype); + } + } +} \ No newline at end of file -- Gitee From 3fe53db1fec90942e499647c481563a9f850977b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=BE=E5=A4=A7=E6=98=9F=E5=91=80?= <2454478226@qq.com> Date: Mon, 7 Jun 2021 07:04:52 +0800 Subject: [PATCH 72/74] zy --- .../IJanKenPunch].cs" | 14 +++ .../Judgment.cs" | 109 ++++++++++++++++ "\345\210\230\344\270\226\350\276\211/NPC.cs" | 45 +++++++ .../Player.cs" | 36 ++++++ .../Program.cs" | 118 ++++++++++++++++++ 5 files changed, 322 insertions(+) create mode 100644 "\345\210\230\344\270\226\350\276\211/IJanKenPunch].cs" create mode 100644 "\345\210\230\344\270\226\350\276\211/Judgment.cs" create mode 100644 "\345\210\230\344\270\226\350\276\211/NPC.cs" create mode 100644 "\345\210\230\344\270\226\350\276\211/Player.cs" create mode 100644 "\345\210\230\344\270\226\350\276\211/Program.cs" diff --git "a/\345\210\230\344\270\226\350\276\211/IJanKenPunch].cs" "b/\345\210\230\344\270\226\350\276\211/IJanKenPunch].cs" new file mode 100644 index 0000000..ce96a62 --- /dev/null +++ "b/\345\210\230\344\270\226\350\276\211/IJanKenPunch].cs" @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _2021_6_4 +{ + interface IJanKenPunch_ + { + janKenPunch DoJanKenPunch(); + janKenPunch DoJanKenPunch(int key); + } +} diff --git "a/\345\210\230\344\270\226\350\276\211/Judgment.cs" "b/\345\210\230\344\270\226\350\276\211/Judgment.cs" new file mode 100644 index 0000000..b909561 --- /dev/null +++ "b/\345\210\230\344\270\226\350\276\211/Judgment.cs" @@ -0,0 +1,109 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _2021_6_4 +{ + class Judgment + { + public string playerName; + public int playerScore; + public string npcName; + public int npcScore; + public int countBattle; + + public Judgment(string Player , string Npc) + { + this.playerName = Player; + this.npcName = Npc; + } + public void Decide(janKenPunch player , janKenPunch npc) + { + //玩家出剪刀的情况 + if (player == janKenPunch.剪刀) + { + if (npc == janKenPunch.剪刀) + { + countBattle++; + Console.WriteLine("和局"); + } + else if (npc == janKenPunch.布) + { + countBattle++; + playerScore++; + Console.WriteLine($"{playerName}胜!"); + } + else + { + countBattle++; + npcScore++; + Console.WriteLine($"{npcName}胜!"); + } + } + //出石头的情况 + else if (player == janKenPunch.石头) + { + if (npc == janKenPunch.石头) + { + countBattle++; + Console.WriteLine("和局"); + } + else if (npc == janKenPunch.剪刀) + { + countBattle++; + playerScore++; + Console.WriteLine($"{playerName}胜!"); + } + else + { + countBattle++; + npcScore++; + Console.WriteLine($"{npcName}胜!"); + } + } + //出布的情况 + else + { + if (npc == janKenPunch.布) + { + countBattle++; + Console.WriteLine("和局"); + } + else if (npc == janKenPunch.石头) + { + countBattle++; + playerScore++; + Console.WriteLine($"{playerName}胜!"); + } + else + { + countBattle++; + npcScore++; + Console.WriteLine($"{npcName}胜!"); + } + } + } + + public override string ToString() + { + string result; + + if (playerScore > npcScore) + { + result = $"{playerName}赢!"; + } + else if (playerScore < npcScore) + { + result = $"{npcName}赢!"; + } + else + { + result = "但是谁也没有赢"; + } + + return $"{playerName} VS {npcName}\n对局次数:{countBattle}\r\n姓名\t得分\n{playerName}\t{playerScore}\n{npcName}\t{npcScore}\n" + result; + } + } +} diff --git "a/\345\210\230\344\270\226\350\276\211/NPC.cs" "b/\345\210\230\344\270\226\350\276\211/NPC.cs" new file mode 100644 index 0000000..c34ecea --- /dev/null +++ "b/\345\210\230\344\270\226\350\276\211/NPC.cs" @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _2021_6_4 +{ + + //NPC类 实现石头剪刀布 + class NPC : IJanKenPunch_ + { + private string npcName; + + public string NpcName { get => npcName; set => npcName = value; } + + public janKenPunch npcAction; + + public NPC(string name) + { + this.NpcName = name; + } + + /// + /// 随机出拳、剪、布 + /// + /// 枚举 + public janKenPunch DoJanKenPunch() + { + Random r = new Random(); + int id = r.Next(1,3); + npcAction = (janKenPunch)id; + return (janKenPunch)id; + } + + public janKenPunch DoJanKenPunch(int key) + { + throw new NotImplementedException(); + } + public override string ToString() + { + return $"{NpcName}:{npcAction}"; + } + } +} diff --git "a/\345\210\230\344\270\226\350\276\211/Player.cs" "b/\345\210\230\344\270\226\350\276\211/Player.cs" new file mode 100644 index 0000000..79e221f --- /dev/null +++ "b/\345\210\230\344\270\226\350\276\211/Player.cs" @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _2021_6_4 +{ + class Player : IJanKenPunch_ + { + private string playerName; + janKenPunch playerAction; + public string PlayerName { get => playerName; set => playerName = value; } + + public Player(string name) + { + PlayerName = name; + } + + public janKenPunch DoJanKenPunch(int key) + { + playerAction = (janKenPunch)(key); + return (janKenPunch)(key); + } + + public janKenPunch DoJanKenPunch() + { + throw new NotImplementedException(); + } + + public override string ToString() + { + return $"{playerName}:{playerAction}"; + } + } +} diff --git "a/\345\210\230\344\270\226\350\276\211/Program.cs" "b/\345\210\230\344\270\226\350\276\211/Program.cs" new file mode 100644 index 0000000..bad27ab --- /dev/null +++ "b/\345\210\230\344\270\226\350\276\211/Program.cs" @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _2021_6_4 +{ + public enum janKenPunch + { + 剪刀 = 1, + 石头, + 布 + } + class Program + { + static void Main(string[] args) + { + while (true) + { + #region 开屏介绍及初始化 + Console.ForegroundColor = ConsoleColor.Green; + Console.WriteLine("——————欢迎进入游戏世界——————"); + Console.WriteLine("****************************************"); + Console.WriteLine("**************猜拳,开始****************"); + Console.WriteLine("****************************************"); + Console.WriteLine("--出拳规则:1、剪刀 2、石头 3、布"); + int key; + NPC enemy; + Player player; + Judgment jud; + #endregion + + #region 选择对手 + while (true) + { + Console.WriteLine("请选择你的对手:(1:刘备 2:孙权 3:曹操)"); + key = int.Parse(Console.ReadLine()); ; + if (key >= 1 && key <= 3) + { + enemy = RetrunNpc(key); + break; + } + else + { + Console.WriteLine("输入有误!"); + } + } + #endregion + + #region 创建玩家和裁判的对象 + Console.WriteLine("请输入你的名字:"); + player = new Player(Console.ReadLine()); + Console.WriteLine(); + jud = new Judgment(Player: player.PlayerName, Npc: enemy.NpcName); + #endregion + + #region 游戏过程 + while (true) + { + Console.WriteLine("请出拳:"); + key = int.Parse(Console.ReadLine()); + if (key >= 1 & key <= 3) + { + jud.Decide(player: player.DoJanKenPunch(key), npc: enemy.DoJanKenPunch()); + Console.WriteLine("信息:\n" + player +"\n" + enemy); + Console.WriteLine("按y开始下一局,任意键退出:"); + + if ((Console.ReadLine().Equals("y")) == false) + { + break; + } + } + else + { + Console.WriteLine("输入有误!"); + continue; + } + + } + #endregion + + #region 游戏结束 + Console.WriteLine("\n\r-----------------------------------"); + Console.WriteLine(jud); + Console.WriteLine("按y开始下一局,任意键退出"); + if ((Console.ReadLine().Equals("y")) == false) + { + break; + } + #endregion + } + + + } + /// + /// 返回一个对手对象 + /// + /// + /// NPC + public static NPC RetrunNpc(int key) + { + switch (key) + { + case 1: + return new NPC("刘备"); + case 2: + return new NPC("孙权"); + default: + return new NPC("曹操"); + } + + + } + + + } +} -- Gitee From b83259c6f8119e9be7bc61c4765262fa5f43365c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=AB=E6=84=81=E5=95=8A=E4=B8=B6?= <2486779710@qq.com> Date: Mon, 7 Jun 2021 07:05:01 +0800 Subject: [PATCH 73/74] =?UTF-8?q?add=20=E5=88=98=E9=BE=99=E5=86=B0/Oberpeo?= =?UTF-8?q?ple.cs.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Oberpeople.cs" | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 "\345\210\230\351\276\231\345\206\260/Oberpeople.cs" diff --git "a/\345\210\230\351\276\231\345\206\260/Oberpeople.cs" "b/\345\210\230\351\276\231\345\206\260/Oberpeople.cs" new file mode 100644 index 0000000..4c9823f --- /dev/null +++ "b/\345\210\230\351\276\231\345\206\260/Oberpeople.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Oberpeople:Father + { + + public static string fistname; + public static int oberscore; + public Oberpeople(string Name) : base(Name) { } + + public Random random = new Random(); + public override void Play() + { + fistname = fist[random.Next(0, 3)]; + Console.WriteLine(base.Name+":"+" 出拳:"+ fistname); + } + } +} \ No newline at end of file -- Gitee From 4019557d6d1e44fe3757bcbc0e62dc0260330f8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=AB=E6=84=81=E5=95=8A=E4=B8=B6?= <2486779710@qq.com> Date: Mon, 7 Jun 2021 07:05:32 +0800 Subject: [PATCH 74/74] =?UTF-8?q?add=20=E5=88=98=E9=BE=99=E5=86=B0/Program?= =?UTF-8?q?.cs.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Program.cs" | 206 ++++++++++++++++++ 1 file changed, 206 insertions(+) create mode 100644 "\345\210\230\351\276\231\345\206\260/Program.cs" diff --git "a/\345\210\230\351\276\231\345\206\260/Program.cs" "b/\345\210\230\351\276\231\345\206\260/Program.cs" new file mode 100644 index 0000000..fcc0d42 --- /dev/null +++ "b/\345\210\230\351\276\231\345\206\260/Program.cs" @@ -0,0 +1,206 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Program + { + + static Gamepeople gone; + static Oberpeople gtwo; + static Boolean TorF=false; + static int c = 0; + static string Gamename; + + static void Main(string[] args) + { + Game(); + } + static void ChooseOber() { + if (c == 1) + { + Gamename = "刘备"; + } + else if (c == 2) + { + Gamename = "孙权"; + } + else if (c == 3) + { + Gamename = "曹操"; + } + Console.WriteLine("请输入您的姓名:"); + string GameName = Console.ReadLine(); + gone = new Gamepeople(GameName); + gtwo = new Oberpeople(Gamename); + Console.WriteLine(gone.Name + " VS " + gtwo.Name + " 对战"); + + Console.WriteLine("开始游戏吗?"); + string numo = Console.ReadLine(); + if (numo == "y") + { + Start(); + } + else + { + Console.WriteLine("已退出!!!"); + } + } + static void Game(){ + Console.WriteLine("---------------------欢迎进入游戏世界-----------------------\n\n\n"); + Console.WriteLine("**************************\n********猜拳,开始********\n**************************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Console.WriteLine("请选择对方角色<1:刘备 2:孙权 3:曹操>"); + int num = Convert.ToInt32(Console.ReadLine()); + + switch (num) + { + case 1: + c = 1; + ChooseOber(); + break; + case 2: + c = 2; + ChooseOber(); + break; + case 3: + c = 3; + ChooseOber(); + break; + default: + Console.WriteLine("输入名字错误,请重新进入游戏!!"); + Game(); + break; + } + } + static void EndScore() { + Console.WriteLine("============================================================="); + Console.WriteLine("姓名 " + " 得分"); + Console.WriteLine(gone.Name + "\t \t"+Gamepeople.gamescore); + Console.WriteLine(gtwo.Name + "\t \t" + Oberpeople.oberscore); + if (Gamepeople.gamescore > Oberpeople.oberscore) + { + Console.WriteLine("结果:" + gone.Name + "赢," + gtwo.Name + "笨蛋"); + } + else if (Gamepeople.gamescore == Oberpeople.oberscore) + { + Console.WriteLine("平局,都不太行!!!"); + } + else + { + Console.WriteLine("结果:" + gtwo.Name + "赢," + gone.Name + "笨蛋"); + } + } + static void AgainStart() { + + if (TorF == true) + { + Console.WriteLine("要开始下一局吗?(y/n)"); + string numo = Console.ReadLine(); + if (numo == "y") + { + Game(); + } + else + { + Console.WriteLine("系统退出!"); + } + } + else { + Console.WriteLine("是否要开始下一轮?"); + string numo = Console.ReadLine(); + + if (numo == "y") + { + Start(); + } + else + { + EndScore(); + Console.WriteLine("退出!"); + + } + } + } + static void Start() { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应数字:)"); + int num2 = Convert.ToInt32(Console.ReadLine()); + switch (num2) + { + case 1: + gone.fisttype = "剪刀"; + Say(); + break; + case 2: + gone.fisttype = "石头"; + Say(); + break; + case 3: + gone.fisttype = "布"; + Say(); + break; + default: + break; + } + Win(); + AgainStart(); + + } + static void Win() { + if (gone.fisttype == "剪刀" && Oberpeople.fistname == "剪刀") + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + else if (gone.fisttype == "剪刀" && Oberpeople.fistname == "石头") + { + Console.WriteLine("笨蛋," + gone.Name + "输了"); + Oberpeople.oberscore++; + } + else if (gone.fisttype == "剪刀" && Oberpeople.fistname == "布") + { + Console.WriteLine("恭喜," + gone.Name + "赢了"); + Gamepeople.gamescore++; + } + else if (gone.fisttype == "石头" && Oberpeople.fistname == "石头") + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + else if (gone.fisttype == "石头" && Oberpeople.fistname == "布") + { + Console.WriteLine("笨蛋," + gone.Name + "输了"); + Oberpeople.oberscore++; + } + else if (gone.fisttype == "石头" && Oberpeople.fistname == "剪刀") + { + Console.WriteLine("恭喜," + gone.Name + "赢了"); + Gamepeople.gamescore++; + } + else if (gone.fisttype == "布" && Oberpeople.fistname == "布") + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + else if (gone.fisttype == "布" && Oberpeople.fistname == "剪刀") + { + Console.WriteLine("笨蛋," + gone.Name + "输了"); + Oberpeople.oberscore++; + } + else if (gone.fisttype == "布" && Oberpeople.fistname == "石头") + { + Console.WriteLine("恭喜," + gone.Name + "赢了"); + Gamepeople.gamescore++; + } + else + { + Console.WriteLine("我是谁?我在哪?"); + } + AgainStart(); + } + static void Say() { + gone.Play(); + gtwo.Play(); + } + } +} \ No newline at end of file -- Gitee