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 0000000000000000000000000000000000000000..285bfe8a93b5cd4a8303651d4d3ccf1cf0aad5f8 --- /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 0000000000000000000000000000000000000000..09c98002d8c4459346ad16c9601426a1270cb88f --- /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 0000000000000000000000000000000000000000..d8bd8f9e4ad0befa80ebc4e16e6b5a89e23915cd --- /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 0000000000000000000000000000000000000000..2378ae5d93acfbeb3d25a74e8ce2869edbd004c8 --- /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; + } + } +} 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 0000000000000000000000000000000000000000..b7f8bf43da65ce415c272f06bf875c4955882e8c --- /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 0000000000000000000000000000000000000000..2e1e2a6a4a3855aa4132091caf68b37899a20fd0 --- /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 0000000000000000000000000000000000000000..9179c5b8353e70d0656b34c2da0e9d662f44278d --- /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 0000000000000000000000000000000000000000..b0d943260c48fb4b9f0a315593ec7c649db8a9a5 --- /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; + } + } + } +} 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 0000000000000000000000000000000000000000..6d8673d424adb2711bb994f6082f2a2636194c34 --- /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 0000000000000000000000000000000000000000..c3b71adb285253a6e65aa7d57ba7fcc26cb064fc --- /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 0000000000000000000000000000000000000000..03140ce25da4d96eb552bc1a244d7393d99edecd --- /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 0000000000000000000000000000000000000000..7eb49d2658ffabe5525ac964137a3d3f19d5817b --- /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 0000000000000000000000000000000000000000..2bd55343cbbd3ce82e609a533eaa8c1bc7a5dac2 --- /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; + } + } +} 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 0000000000000000000000000000000000000000..efee50380cb0320c27bc52503e4258dba1cd8d25 --- /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 0000000000000000000000000000000000000000..38bb6827748458fdfecf60971fcfdf1a71beb5e6 --- /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 0000000000000000000000000000000000000000..705996fde7f9695de7885ed122777fe8db1d71cc --- /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 0000000000000000000000000000000000000000..14595921fcbb7e0db48efa41865c06f5b71a2901 --- /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(); + } + } +} 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 0000000000000000000000000000000000000000..ce96a62a8ff0f42edafc3b1ea266df45371c1a9a --- /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 0000000000000000000000000000000000000000..b9095613e0cef746974751a63ec94ca8f20868c4 --- /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 0000000000000000000000000000000000000000..c34ecea869e9cc0eea69c212643e0fefbfdbf566 --- /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 0000000000000000000000000000000000000000..79e221f0aa5ab06c49d0921eaedeec089cae56c3 --- /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 0000000000000000000000000000000000000000..bad27ab3580e9a613daf6053e0adfbe24f4477fa --- /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("曹操"); + } + + + } + + + } +} 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 0000000000000000000000000000000000000000..a14fb6b07d769370308480dc09c227b079f328a4 --- /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 0000000000000000000000000000000000000000..a5bd2e0f5ae11742b571d6b2c0d4f990b3ad0837 --- /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 0000000000000000000000000000000000000000..c1d623a885339e0dcd08370b426c9027e646c2dc --- /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 0000000000000000000000000000000000000000..cbf8c0fc8046a7be35766b0a872b10e8be6bf9ce --- /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; + } + + } +} 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 0000000000000000000000000000000000000000..4d2762dc672ccb1e5df34ea27f8820a5b76bf858 --- /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 0000000000000000000000000000000000000000..e4094f3adc79bebad6fc6676b07b3a6c4308606f --- /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 0000000000000000000000000000000000000000..3f9fb41e9fe190da915a7891b936872513e9c328 --- /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 0000000000000000000000000000000000000000..5f2ac31c261f06aaa36097cfc1bc94e1c1801feb --- /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; + } + + + } +} 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 0000000000000000000000000000000000000000..d22a4f70d2d683d6150796207d108888b19575bd --- /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 0000000000000000000000000000000000000000..2a0c3466fb8e386368a768eda69d955ff27bbb36 --- /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 0000000000000000000000000000000000000000..bdd2343ab16d3e19278ca47e4c9a943a8ca1efe0 --- /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 0000000000000000000000000000000000000000..a1554b28fe8e3953af8fe8a139c110641db6ec65 --- /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(); + } + + } +} 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 0000000000000000000000000000000000000000..f05cd0ba60428e3a5604485c5e46d450f5d04a5d --- /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 0000000000000000000000000000000000000000..756aa0e2352dcc01ecc2c60ecdea211a0e199339 --- /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 0000000000000000000000000000000000000000..2d36ec665a1672e306ae67ca9a81ba393bf8feca --- /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 0000000000000000000000000000000000000000..8717bff179035a623e503bb8896a365f530d6759 --- /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 0000000000000000000000000000000000000000..d2968969b80af879f77f53c862eed877078d11e9 --- /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; + } + } +} 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 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 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 0000000000000000000000000000000000000000..9af191fa7b7eebadf755965b07d2cad47d4e64ed --- /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 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 0000000000000000000000000000000000000000..a3a9988819ef0257bbd0ab8835ce495a3b1a756e --- /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 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 0000000000000000000000000000000000000000..4c9823fb0a8a2e591a4a3cf2ac5c7ab5942f6a3f --- /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 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 0000000000000000000000000000000000000000..fcc0d4257791384f461e64cfa2db070c52185eda --- /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 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 0000000000000000000000000000000000000000..389b4bd127df4825e5dacb0e5985fb36ee1d49c1 --- /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 0000000000000000000000000000000000000000..5baf5d8e11fe07fc4e3d51d1386c1a5dea7d1ea8 --- /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++; + } + + } + + + + } +} 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 0000000000000000000000000000000000000000..8cc5b29d7971b9e836ef823bc6d3b60ef7bb01e9 --- /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 0000000000000000000000000000000000000000..16495566b36b251770157223ac0c664731fd20d3 --- /dev/null +++ "b/\345\224\220\344\274\237\345\273\272/Program.cs" @@ -0,0 +1,243 @@ +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 + "猪一样"); + } + 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); + + //裁判 + 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 0000000000000000000000000000000000000000..b3f4e9bdbccbd5ac99daf76f81ec187a4ef6dbcc --- /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 0000000000000000000000000000000000000000..fd01b11357d577dac721701e0d14eab774469c30 --- /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; + } + + } +} 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 0000000000000000000000000000000000000000..b2778550530dd67bc43f90629eede9a84dd4ef9d --- /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 0000000000000000000000000000000000000000..eb9f4421db1a93c014bb73a71224e6f6a1977781 --- /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 0000000000000000000000000000000000000000..d23a1ded3914ef96865623b036c5dc111c6e032b --- /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 0000000000000000000000000000000000000000..8fc8c172bdcf389ef9c596ac5913805a0376e973 --- /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 0000000000000000000000000000000000000000..5d3cdb18ac65837e2158908a502c2f951f0f5cbb --- /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; + } + } +} 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 0000000000000000000000000000000000000000..efee50380cb0320c27bc52503e4258dba1cd8d25 --- /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 0000000000000000000000000000000000000000..38bb6827748458fdfecf60971fcfdf1a71beb5e6 --- /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 0000000000000000000000000000000000000000..705996fde7f9695de7885ed122777fe8db1d71cc --- /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 0000000000000000000000000000000000000000..14595921fcbb7e0db48efa41865c06f5b71a2901 --- /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(); + } + } +} 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 0000000000000000000000000000000000000000..9521a2d178fa1aedecd2dc9b67b37a0fcf875f2b --- /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 0000000000000000000000000000000000000000..493dadb3d1e164d2eb2154d1b27e4c547f01cfec --- /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 0000000000000000000000000000000000000000..f2f9cfb1b8587c880edaa4cd4df468428a8285b4 --- /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 0000000000000000000000000000000000000000..2d4ab66bea2ad8d70c173ee559ae30db211d0f5a --- /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(); + } + } +} 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 0000000000000000000000000000000000000000..98684c7bcb01a8ff91ee833a70b9c74683efed44 --- /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 0000000000000000000000000000000000000000..bf2465560394eef0588fac1649bb947e3c797710 --- /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 0000000000000000000000000000000000000000..389514eab86214b551c0b0e8010dd4eed088f0ee --- /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 0000000000000000000000000000000000000000..e2291b255fb8f210c6d2a4db81bdd54b54ab0ca5 --- /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 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 0000000000000000000000000000000000000000..49096face49892ea0559fc52157edfa6fa6a2e89 --- /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 0000000000000000000000000000000000000000..0223b7a4aac63cda71654ff67674444c0a91aacf --- /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 0000000000000000000000000000000000000000..44710c056be86c6b4e0f5788eba1c8267e2101f2 --- /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 0000000000000000000000000000000000000000..eb669ff53433becdaa90a32095111ae5dd2a7618 --- /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(); + } + } +} 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 0000000000000000000000000000000000000000..602ba9c387522dc1de30268d2df305755d11b45d --- /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 0000000000000000000000000000000000000000..a0f588b95c85c5f99ef2594eb351925b92927f43 --- /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 0000000000000000000000000000000000000000..6e29bf654fab9e809a229720b706680ac98f1a2e --- /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 0000000000000000000000000000000000000000..8b85b354f53bce4a5ae8e6e93aab1e047cddca4e --- /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 0000000000000000000000000000000000000000..a27e6beb54f2b65c164e1c6f198e9f5d7687b8d6 --- /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; + + } + } +} 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 0000000000000000000000000000000000000000..76f77c53b0bf54ded0688c48949647c28c8ed613 --- /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 0000000000000000000000000000000000000000..fc63d3b22645112374c8034cede02f10bac7cacc --- /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 0000000000000000000000000000000000000000..43dc786fb4701241da1f1df3a2d622928263b5c6 --- /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 0000000000000000000000000000000000000000..ffa56e08a1e64a83e61b3ca3e409945a45034131 --- /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 0000000000000000000000000000000000000000..bb5017f5845438354dfa8d6d4f6bb4fd029e778e --- /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 + { + + } +} 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 0000000000000000000000000000000000000000..32177467f9f271c11c5c7117e412a9e48bda23aa --- /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 0000000000000000000000000000000000000000..4c07c55191053e978eb8c73f988fbc8d6405f7c5 --- /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 0000000000000000000000000000000000000000..271a9fdaa949860e66cd5f805c237128ecbebf70 --- /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 0000000000000000000000000000000000000000..f61a3dee3767f4b951c901c7dbda6bf5ad04cbbe --- /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 0000000000000000000000000000000000000000..62c545041e80b73bbb6dc9ea1a35ab069aec0098 --- /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; + + } + } +} 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 0000000000000000000000000000000000000000..e4b8d6ef90012176a39a090c4c641909db6a516d --- /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" new file mode 100644 index 0000000000000000000000000000000000000000..aaf2e4361d40860cae9e6352280d09d054899741 --- /dev/null +++ "b/\346\236\227\346\265\267\346\266\233/Jse.cs" @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp3 +{ + enum cq + { + 石头, + 剪刀, + 布 + } + abstract class Jse + { + public Jse(string name) + { + this.name = name; + } + public int score { get; set; } + public int FGG { get; set; } + + public Jse() { } + public string name { get; set; } + public abstract void print(); + } +} 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 0000000000000000000000000000000000000000..386379ffd1fa2e900c11e30dfd91029e9524edbd --- /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 0000000000000000000000000000000000000000..bf83f50a8b0cc1f128cd3587c452582d9fdcd29a --- /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" new file mode 100644 index 0000000000000000000000000000000000000000..182f38f3042666eef8f952822a3e7e502505ac1f --- /dev/null +++ "b/\346\236\227\346\265\267\346\266\233/Program.cs" @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp3 +{ + class Program + { + enum cq + { + 石头=1, + 剪刀, + 布 + } + static void Main(string[] args) + { + Console.WriteLine("----- 欢 迎 进 入 游 戏 世 界 ----- "); + Console.WriteLine("********************"); + Console.WriteLine("*****猜拳,开始*****"); + Console.WriteLine("********************"); + t1(); + } + static void t1() + { + 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("输入不规范,重新输入!!"); + t1(); + break; + } + Console.WriteLine("请输入你的名字:"); + string name = Console.ReadLine(); + Figure figure = new Figure(name); + + 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 login; + 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.score); + Console.WriteLine("{0}\t{1}", npc.name, npc.score); + if (figure.score >= npc.score) + { + Console.WriteLine("结果,{0}赢了", figure.name); + } + else + { + Console.WriteLine("结果,{0}赢了", npc.name); + } + Console.WriteLine(); + + Console.WriteLine("要开始下一局吗?"); + string key3 = Console.ReadLine(); + switch (key3) + { + case "y": + t1(); + break; + default: + break; + } + break; + default: + break; + } + } + + 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)) + { + Console.WriteLine("傻逼,{0}输了", figure.name); + npc.score++; + } + else + { + Console.WriteLine("牛逼,{0}赢了", figure.name); + figure.score++; + } + } + } +} 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 0000000000000000000000000000000000000000..f9f32cfa4f2bc5c70e1461efccdf0cbd6f73a2b7 --- /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 0000000000000000000000000000000000000000..bca2faa71e12b00642985c840c3fcdc226deec5f --- /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 0000000000000000000000000000000000000000..62f00e31d8c44862a632d57eb8bf67dde23fd170 --- /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 0000000000000000000000000000000000000000..0302fe82acd69496ebc303ce02b41a6d09d45fd1 --- /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("玩家失败!"); + } + } + } +} 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 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 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 0000000000000000000000000000000000000000..e01eb0740b88c9f8a407fa220be71df295ab0ff7 --- /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; + } + } + } +} 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 0000000000000000000000000000000000000000..fd6d98598d741b97b1a98742fa56b833c014e79b --- /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 0000000000000000000000000000000000000000..1edc82decb8354c05ca94eeb046c270f9d49e4a1 --- /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 0000000000000000000000000000000000000000..24461dc599ab1088b8545ecd7b73a2af675331e4 --- /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 0000000000000000000000000000000000000000..efb2e35e982746eba652c13b00122c7ab0b49ace --- /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; + } + } +} 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 0000000000000000000000000000000000000000..4882f4f1591f3d93de4009c8eeb54f8d01bb2ae3 --- /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 0000000000000000000000000000000000000000..5f3615a7e143b65088a5a24c0d72e13c1a55e92c --- /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; + } + + + } + + + + } + +} 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 0000000000000000000000000000000000000000..51222ca0f35d9b1f2344c34fd96817a8f487c31d --- /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() + { + } + + + + + + } +} 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 0000000000000000000000000000000000000000..fa98e5a1ce3e461cc21070efbfe2eed581a89115 --- /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; + } + } + } +} 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 0000000000000000000000000000000000000000..4d2762dc672ccb1e5df34ea27f8820a5b76bf858 --- /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 0000000000000000000000000000000000000000..6468714802a81eaf7eec3d47569032ce93c670a0 --- /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 0000000000000000000000000000000000000000..389514eab86214b551c0b0e8010dd4eed088f0ee --- /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 0000000000000000000000000000000000000000..e2291b255fb8f210c6d2a4db81bdd54b54ab0ca5 --- /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 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 0000000000000000000000000000000000000000..df1ca6d443a7ba4d809ce590bfa876c60599075e --- /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 0000000000000000000000000000000000000000..e99b4e53545dcf55e4e4bd18a5a941709c1df198 --- /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 0000000000000000000000000000000000000000..6c43ff52f0c1ed08a92914f699d52912a60ea740 --- /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 0000000000000000000000000000000000000000..73afa49ebea22146d62b649870e59da50e4bc7c1 --- /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 0000000000000000000000000000000000000000..305a566e8ce3ba4eea23d395c67d50fc6abad93c --- /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; + } + } +} 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 0000000000000000000000000000000000000000..98684c7bcb01a8ff91ee833a70b9c74683efed44 --- /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 0000000000000000000000000000000000000000..bf2465560394eef0588fac1649bb947e3c797710 --- /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 0000000000000000000000000000000000000000..389514eab86214b551c0b0e8010dd4eed088f0ee --- /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 0000000000000000000000000000000000000000..e2291b255fb8f210c6d2a4db81bdd54b54ab0ca5 --- /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 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 0000000000000000000000000000000000000000..d0d0db28cd9b12eadc2222378de84512ba5e8278 --- /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 0000000000000000000000000000000000000000..e2432e2f98d132b40f3272963497d45e0c0cdda7 --- /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 0000000000000000000000000000000000000000..35594d7305c302572659409921b8c05acf18a121 --- /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 0000000000000000000000000000000000000000..7db0bd72174f38f24b81729432e94d7093c8fbaf --- /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("玩家失败!"); + } + } + + } +} 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 0000000000000000000000000000000000000000..7f7a6bfd2b481b989721d0c276f7f4437cbd3a3c --- /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 0000000000000000000000000000000000000000..f7b29546829adda336d0ee6e8fc7dd51a8a1fef9 --- /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 0000000000000000000000000000000000000000..aebf75ec0655685712e755b4b394cc7ecb593287 --- /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 0000000000000000000000000000000000000000..c24f2f5a53457e8be8a418785f41cb6b532ebb5a --- /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; + } + + + } +} 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 0000000000000000000000000000000000000000..ecf3682264712da6aed85801abc5815a0d9a53f3 --- /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 0000000000000000000000000000000000000000..e99e4f3ce1c92772f0d5a836027e9faddfebbb77 --- /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 0000000000000000000000000000000000000000..836166c1c7366dcbb77d7d814ee50f09641f7901 --- /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 0000000000000000000000000000000000000000..c3b4ea0f64fe2ca00cc115604be23a3109457377 --- /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; + } + } +} 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 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 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 0000000000000000000000000000000000000000..4ae93363013847a7cd3af1d4b6a0a120caa13d25 --- /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 0000000000000000000000000000000000000000..2f24dc49f71db6762398df9d5171a14f06dc11d6 --- /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; + } + } + } + } + + 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 0000000000000000000000000000000000000000..25f1300644b414b50aee74349326090a8a35b0f2 --- /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= 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++; + } + } + + + } +} 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 0000000000000000000000000000000000000000..f1079dd44113e1f431f38e0e141f34ad154a248d --- /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 0000000000000000000000000000000000000000..6e9500736a288c2f908a672ff4417053c9f26919 --- /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 0000000000000000000000000000000000000000..e0ad0d03ca5ea814e01a4711dfa00ac18b3506bf --- /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 0000000000000000000000000000000000000000..f6e8e88643047c0ad1f323e162eaccc8c403363d --- /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 0000000000000000000000000000000000000000..a8f41e49d9e2e09b5bf47425b1d4a8a36dec8f1f --- /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; + } + } +} 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 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 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 0000000000000000000000000000000000000000..7ddbc8d6aab0f023cde9a1a644568b5b70bccc5c --- /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 0000000000000000000000000000000000000000..5ae6872118ccbfae3df201a0adad69275e97a520 --- /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 0000000000000000000000000000000000000000..42c0066b738f580f883c2d9455176903c1b94438 --- /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 0000000000000000000000000000000000000000..370de23041ddd2c75c88acff3fd1fb2b78ce0ba6 --- /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; + } + } +} 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 0000000000000000000000000000000000000000..ce96a62a8ff0f42edafc3b1ea266df45371c1a9a --- /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 0000000000000000000000000000000000000000..b9095613e0cef746974751a63ec94ca8f20868c4 --- /dev/null +++ "b/\351\231\210\350\257\227\346\235\260/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/\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 0000000000000000000000000000000000000000..c34ecea869e9cc0eea69c212643e0fefbfdbf566 --- /dev/null +++ "b/\351\231\210\350\257\227\346\235\260/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/\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 0000000000000000000000000000000000000000..79e221f0aa5ab06c49d0921eaedeec089cae56c3 --- /dev/null +++ "b/\351\231\210\350\257\227\346\235\260/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/\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 0000000000000000000000000000000000000000..bad27ab3580e9a613daf6053e0adfbe24f4477fa --- /dev/null +++ "b/\351\231\210\350\257\227\346\235\260/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("曹操"); + } + + + } + + + } +} 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 0000000000000000000000000000000000000000..568d724c1961b16eaabdfd382942453ae627a3fd --- /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 0000000000000000000000000000000000000000..67ce63499db8840f102fdbe628b164036d832f45 --- /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 0000000000000000000000000000000000000000..56e351c605c50d1cf4228b87a54fe512c06a9725 --- /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 0000000000000000000000000000000000000000..93a269ff00fd7385fb73e6e48d40768201c4ed9f --- /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 0000000000000000000000000000000000000000..ec224e2697a0c77e16b9cc770fd4d1cebf38acf9 --- /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; + } + } +} 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 0000000000000000000000000000000000000000..3d52d7a61604daf6e6e14c6bf524bdceef0cfd14 --- /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 0000000000000000000000000000000000000000..0609453b7d10658d42c5f137e95081b351e84cf5 --- /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 0000000000000000000000000000000000000000..a57d39ccdf4f0ca74128303a96cfe964eebbfc48 --- /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 0000000000000000000000000000000000000000..6defc2b5d08c811d7a59b61a027b934ccc9e0736 --- /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; + } + } +} 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 0000000000000000000000000000000000000000..5928c6f476418c0a3e61b37840b7791ee69d3e43 --- /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; + } + } + + + + + + + + + + + + + + + + + + + + } +} 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 0000000000000000000000000000000000000000..dc856a64a50313335e32d268e3fde087bd7de19f --- /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 0000000000000000000000000000000000000000..ab604a7eec96d9053acc070c92d5e67cd9447967 --- /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 0000000000000000000000000000000000000000..7eb49d2658ffabe5525ac964137a3d3f19d5817b --- /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 0000000000000000000000000000000000000000..5fac3ec5e19e0fd5b68abd81eaa6a4c54bb84c3f --- /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 0000000000000000000000000000000000000000..6c1e8e42e66a105f9611ef8b77bc7d8695858c38 --- /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; + } + } +} 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 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 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 0000000000000000000000000000000000000000..ec87232e51c1a87ba50b2c153fe1d15e1eea5466 --- /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; + } + } + } +} 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 0000000000000000000000000000000000000000..8419bdfd9d5d995f13415ab6ae810c6bdcec0165 --- /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 0000000000000000000000000000000000000000..2d4a864c4839b28ac844452b20d339b603dfbdb7 --- /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 0000000000000000000000000000000000000000..d431679c46764863981e2d89312fae4d3c235561 --- /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 0000000000000000000000000000000000000000..526c53304c4e28d996a8fd7f619eb1b3c41be0dc --- /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!"); + } + } + } + } +} 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 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 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 0000000000000000000000000000000000000000..285bfe8a93b5cd4a8303651d4d3ccf1cf0aad5f8 --- /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 0000000000000000000000000000000000000000..09c98002d8c4459346ad16c9601426a1270cb88f --- /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 0000000000000000000000000000000000000000..d8bd8f9e4ad0befa80ebc4e16e6b5a89e23915cd --- /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 0000000000000000000000000000000000000000..2378ae5d93acfbeb3d25a74e8ce2869edbd004c8 --- /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; + } + } +} 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 0000000000000000000000000000000000000000..6d8673d424adb2711bb994f6082f2a2636194c34 --- /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 0000000000000000000000000000000000000000..c3b71adb285253a6e65aa7d57ba7fcc26cb064fc --- /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 0000000000000000000000000000000000000000..03140ce25da4d96eb552bc1a244d7393d99edecd --- /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 0000000000000000000000000000000000000000..7eb49d2658ffabe5525ac964137a3d3f19d5817b --- /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 0000000000000000000000000000000000000000..28afb1a198a8a2f82d1363c34c2418f57bdcd5ae --- /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; + } + } +}