diff --git "a/\344\275\225\351\223\255\346\266\233/Program.cs" "b/\344\275\225\351\223\255\346\266\233/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..e647b77cc86340aa0bf074c5e5791f86a4645951 --- /dev/null +++ "b/\344\275\225\351\223\255\346\266\233/Program.cs" @@ -0,0 +1,135 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Program + { + enum enrole + { 刘备 = 1, + 孙权 = 2, + 曹操 = 3 + } + enum enMora + { + 石头 = 1, + 剪刀 = 2, + 布 = 3 + } + static void Main(string[] args) + { + Console.WriteLine("---------------------------------欢迎进入游戏世界--------------------" + "\n"); + Console.WriteLine("*************************************************"); + Console.WriteLine("*******************猜拳开始***********************"); + Console.WriteLine("*************************************************"); + Console.WriteLine("出拳规则:1.剪刀2.石头3.布"); + Console.WriteLine("请选择对方的角色(1:刘备2.孙权3.曹操)"); + int numname = int.Parse(Console.ReadLine()); + string name = Enum.GetName(typeof(enrole), numname); + + Role role = new Role(name); + Console.WriteLine("请输入您的姓名"); + string playname = Console.ReadLine(); + + Console.WriteLine(playname + " VS " + name); + + Console.WriteLine("是否开始游戏(y/n)"); + char char1 = Convert.ToChar(Console.ReadLine()); + if (char1 == 'y' || char1 == 'Y') + { + WinMora(role, name, playname); + } + else if(char1 == 'n' || char1 == 'N') + { + Console.WriteLine("退出游戏"); + } + Console.WriteLine("要开始下一局游戏吗?(y/n)"); + char char3 = Convert.ToChar(Console.ReadLine()); + if (char3 == 'y' || char3 == 'Y') + { + WinMora(role, name, playname); + } + else if (char3 == 'n' || char3 == 'N') + { + Console.WriteLine("退出程序"); + System.Environment.Exit(0); + } + } + + private static void WinMora(Role role, string name, string playname) + { + int draw = 0; + int NPCwin = 0; + int Playwin = 0; + + while (true) + { + Console.WriteLine("请出拳1.石头2.剪刀3.布请输入数字(请输入相应的数字)"); + int Moranum = int.Parse(Console.ReadLine()); + string playMora = Enum.GetName(typeof(enMora), Moranum); //获取用户输入的数字转化为相应的枚举里的值 + + Console.WriteLine(playname + " : 出拳: " + playMora); + role.Write(); + + if (role.StrMora == playMora) + { + Console.WriteLine("平局,下次再会"); + draw = draw + 1; + } + else if (playMora == "石头" && role.StrMora == "剪刀" || playMora == "布" && role.StrMora == "石头" || playMora == "剪刀" && role.StrMora == "布") + { + Console.WriteLine("恭喜您,胜利"); + Playwin = Playwin + 1; + } + else if (role.StrMora == "剪刀" && playMora == "布" || role.StrMora == "石头" && playMora == "剪刀" || role.StrMora == "布" && playMora == "石头") + { + Console.WriteLine("这也会输"); + NPCwin = NPCwin + 1; + } + else if (playMora != "石头" || playMora != "剪刀" || playMora != "布") + { + NPCwin = NPCwin + 1; + Console.WriteLine("出拳不符合规则"); + } + + Console.WriteLine("是否开始下一局(y/n)"); + char char2 = Convert.ToChar(Console.ReadLine()); + if (char2 == 'y' || char2 == 'Y') + { + } + else if(char2 == 'n' || char2 == 'N') + { + Console.WriteLine("结束游戏"); + Console.WriteLine("==========================="); + Console.WriteLine(playname + " VS " + npcstr); + Console.WriteLine("对战次数" + (Playwin + NPCwin + draw)); + Console.WriteLine("姓名 得分"); + Console.WriteLine($"{playname} {Playwin}"); + Console.WriteLine($"{npcstr} {NPCwin}"); + if (Playwin > NPCwin) + { + Console.WriteLine( "玩家 "+playname+" 胜出,恭喜恭喜"); + } + else if (NPCwin > Playwin) + { + Console.WriteLine( "电脑"+ npcstr+"胜出,不错呦"); + } + else + { + Console.WriteLine("平局"); + } + break; + } + + + } + } + } + + +} + + diff --git "a/\344\275\225\351\223\255\346\266\233/Role.cs" "b/\344\275\225\351\223\255\346\266\233/Role.cs" new file mode 100644 index 0000000000000000000000000000000000000000..bf944ac83d33490d0a723ebe18b67fd808f599aa --- /dev/null +++ "b/\344\275\225\351\223\255\346\266\233/Role.cs" @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Role + { + private string name; + private string strmora; + public string Name { get; set; } + public string StrMora + { + get { return this.strmora; } + set { this.strmora=value; } + } + + public Role(string name) + { + this.Name = name; + } + public void Test(string strmora) + { + Random random = new Random(); + + if (random.Next(1, 4) == 1) + { + strmora = "石头"; + } + else if (random.Next(1, 4) == 2) + { + strmora = "布"; + } + else if (random.Next(1, 4) == 3) + { + strmora = "剪刀"; + } + + this.StrMora = strmora; + } + public void Write() + { + Test(strmora); + StrMora = strmora; + Console.WriteLine("{0}: 出拳 :{1}",Name, StrMora); + } + + } +} diff --git "a/\345\205\260\351\246\250\345\204\277/\347\273\223\346\236\204\344\275\223/PersonClass.cs" "b/\345\205\260\351\246\250\345\204\277/\347\273\223\346\236\204\344\275\223/PersonClass.cs" new file mode 100644 index 0000000000000000000000000000000000000000..9d5927b3221bfa28bdccc09c23cb6c7721412c03 --- /dev/null +++ "b/\345\205\260\351\246\250\345\204\277/\347\273\223\346\236\204\344\275\223/PersonClass.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp8 +{ + class PersonClass + { + public string name; + public int tel; + public string address; + + public PersonClass(string name, int tel, string address) + { + this.name = name; + this.tel = tel; + this.address = address; + } + + } +} diff --git "a/\345\205\260\351\246\250\345\204\277/\347\273\223\346\236\204\344\275\223/Program.cs" "b/\345\205\260\351\246\250\345\204\277/\347\273\223\346\236\204\344\275\223/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..018a26b681be7805ca441b30044adf822cae83e5 --- /dev/null +++ "b/\345\205\260\351\246\250\345\204\277/\347\273\223\346\236\204\344\275\223/Program.cs" @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +//定义一个结构体,名为PersonStruct,有三个成员变量:姓名、电话、地址, +//在主方法中,创建一个PersonStruct结构体对象p1,为p1的成员变量赋值。 +//再声明一个PersonStruct结构体变量p2,把p1赋值给p2,改变p2的姓名,打印p1的内容。 + +//定义一个类,名为PersonClass,有三个成员变量:姓名、电话、地址, +//在主方法中,创建一个PersonClass对象p3,为p3的成员变量赋值。 +//再声明一个PersonClass变量p4,把p3赋值给p4,改变p4的姓名,打印p3的内容。 + +namespace ConsoleApp8 +{ + class Program + { + struct PersonStruct + { + public string name; + public int tel; + public string address; + + public PersonStruct(string name, int tel, string address) + { + this.name = name; + this.tel = tel; + this.address = address; + } + } + static void Main(string[] args) + { + PersonStruct p1 = new PersonStruct(); + p1.name = "哈哈"; + p1.tel = 123123123; + p1.address = "龙岩"; + + //把p1赋值给p2,改变p2的姓名,打印p1的内容。 + PersonStruct p2 = p1; + p2.name = "g"; + Console.WriteLine("姓名:{0},电话:{1},地址:{2}", p1.name, p1.tel, p1.address); + + //再声明一个PersonClass变量p4,把p3赋值给p4,改变p4的姓名,打印p3的内容。 + + PersonStruct p3 = new PersonStruct(); + p3.name = "a"; + p3.tel = 123432993; + p3.address = "福州"; + + PersonStruct p4 = p3; + p4.name = "d"; + Console.WriteLine("姓名:{0},电话:{1},地址:{2}", p3.name, p3.tel, p3.address); + } + } +} diff --git "a/\345\210\230\346\200\235\347\233\210/\347\273\223\346\236\204\344\275\223/PersonClass.cs" "b/\345\210\230\346\200\235\347\233\210/\347\273\223\346\236\204\344\275\223/PersonClass.cs" new file mode 100644 index 0000000000000000000000000000000000000000..a3ce38f7d4045354948582465f7830b5f936deec --- /dev/null +++ "b/\345\210\230\346\200\235\347\233\210/\347\273\223\346\236\204\344\275\223/PersonClass.cs" @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp22 +{ + class PersonClass + { + public string name; + public string phone; + public string address; + + public PersonClass() + { + } + + public PersonClass(string name, string phone, string address) + { + + this.address = address; + this.name = name; + this.phone = phone; + + + } + + } +} diff --git "a/\345\210\230\346\200\235\347\233\210/\347\273\223\346\236\204\344\275\223/Program.cs" "b/\345\210\230\346\200\235\347\233\210/\347\273\223\346\236\204\344\275\223/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..6ec7806604fe61755afaab1609ce7b3bf9df8e2d --- /dev/null +++ "b/\345\210\230\346\200\235\347\233\210/\347\273\223\346\236\204\344\275\223/Program.cs" @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp22 +{ + class Program + { +// 定义一个结构体,名为PersonStruct,有三个成员变量:姓名、电话、地址, +//在主方法中,创建一个PersonStruct结构体对象p1,为p1的成员变量赋值。 +//再声明一个PersonStruct结构体变量p2,把p1赋值给p2,改变p2的姓名,打印p1的内容。 + +//定义一个类,名为PersonClass,有三个成员变量:姓名、电话、地址, +//在主方法中,创建一个PersonClass对象p3,为p3的成员变量赋值。 +//再声明一个PersonClass变量p4,把p3赋值给p4,改变p4的姓名,打印p3的内容。 + struct PersonStruct + { + + public string name; + public string phone; + public string address; + public PersonStruct(string name,string phone,string address) + { + + this.address = address; + this.name = name; + this.phone = phone; + + + } + + } + + static void Main(string[] args) + { + PersonStruct p1 = new PersonStruct(); + p1.name = "啦啦"; + p1.phone = "315465876865"; + p1.address = "北京市三环路"; + + PersonStruct p2 = new PersonStruct(); + p2.name = "啦"; + p2.phone = "315465876865"; + p2.address = "三环路"; + p2 = p1; + p2.name = "fdkg"; + Console.WriteLine(p1.name,p1.phone,p1.address); + + + + PersonClass p3 = new PersonClass(); + p3.name = "啦啦"; + p3.phone = "315465876865"; + p3.address = "北京市三环路"; + + PersonClass p4 = new PersonClass(); + p4.name = "啦"; + p4.phone = "315465876865"; + p4.address = "三环路"; + p4 = p3; + p4.name = "fdkg"; + Console.WriteLine(p3.name, p3.phone, p3.address); + } + } +} diff --git "a/\345\210\230\346\257\205/\347\214\234\346\213\263/Caipan.cs" "b/\345\210\230\346\257\205/\347\214\234\346\213\263/Caipan.cs" new file mode 100644 index 0000000000000000000000000000000000000000..41678d3ec6254a216d0f015c1cc84d47dc9e2d25 --- /dev/null +++ "b/\345\210\230\346\257\205/\347\214\234\346\213\263/Caipan.cs" @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Caipan + { + public void RuleSpeak() + { + Console.WriteLine("------欢迎进入游戏世界------"); + Console.WriteLine(); + Console.WriteLine("****************************"); + Console.WriteLine("*********猜拳,开始*********"); + Console.WriteLine("****************************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + } + public void returnup(string name,Heroname he,int counttime, int result1,int result2) + { + + Console.WriteLine("==================================="); + Console.WriteLine($"{name} vs {he}"); + Console.WriteLine($"对战次数:{counttime}"); + Console.WriteLine(); + Console.WriteLine($"姓名\t得分"); + Console.WriteLine($"{name}\t{result1}"); + Console.WriteLine($"{he}\t{result2}"); + Console.Write("结果:"); + result(name, he, result1, result2); + } + public void result(string name,Heroname he,int result1,int result2) + { + if (result1 > result2) + { + Console.WriteLine($"{name}赢,{he}笨蛋"); + } + else if(result1 > result2) + { + Console.WriteLine($"{he}赢,{name}笨蛋"); + } + else + { + Console.WriteLine("平局!"); + } + } + public void Shibai(string name) + { + Console.WriteLine($"笨蛋,{name}输了"); + } + public void Win(string name) + { + Console.WriteLine($"恭喜,{name}赢了"); + } + public void He() + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + } +} \ No newline at end of file diff --git "a/\345\210\230\346\257\205/\347\214\234\346\213\263/Cc.cs" "b/\345\210\230\346\257\205/\347\214\234\346\213\263/Cc.cs" new file mode 100644 index 0000000000000000000000000000000000000000..f53b9dd8c9d5d2f5b9184a49890a2f1a20abfcd4 --- /dev/null +++ "b/\345\210\230\346\257\205/\347\214\234\346\213\263/Cc.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Cc : Hero + { + public Cc(string name, int age, char sex) : base(name, age, sex) + { + base.Name = name; + base.Age = age; + base.Sex = sex; + } + public override void yuyin() + { + Console.WriteLine($"在下{base.Name},后会有期~"); + } + public override void chu() + { + + } + } +} diff --git "a/\345\210\230\346\257\205/\347\214\234\346\213\263/Computer.cs" "b/\345\210\230\346\257\205/\347\214\234\346\213\263/Computer.cs" new file mode 100644 index 0000000000000000000000000000000000000000..6316148b9860f879a07fc5800e5d27a66551817d --- /dev/null +++ "b/\345\210\230\346\257\205/\347\214\234\346\213\263/Computer.cs" @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + enum chuquanf + { + 剪刀=1, + 石头=2, + 布=3 + } + class Computer + { + Random rd = new Random(); + string[] arr = new string[3]; + int temp = 0; + int max = 3; + int min = 1; + //chuquanf cq = (chuquanf)Enum.Parse(typeof(chuquanf), rd); + public void chuquan() + { + + } + } +} diff --git "a/\345\210\230\346\257\205/\347\214\234\346\213\263/Hero.cs" "b/\345\210\230\346\257\205/\347\214\234\346\213\263/Hero.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b77c9584ec9d7403ca7e6008feee07edcc6698ea --- /dev/null +++ "b/\345\210\230\346\257\205/\347\214\234\346\213\263/Hero.cs" @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + abstract class Hero + { + private string name; + private int age; + private char sex; + public Hero() + { } + public Hero(string name, int age, char sex) + { + this.name = name; + this.age = age; + this.sex = sex; + } + + public string Name + { + get { return this.name; } + set { this.name = value; } + } + + public int Age { get => age; set => age = value; } + public char Sex { get => sex; set => sex = value; } + public abstract void yuyin(); + public abstract void chu(); + } +} diff --git "a/\345\210\230\346\257\205/\347\214\234\346\213\263/Liubei.cs" "b/\345\210\230\346\257\205/\347\214\234\346\213\263/Liubei.cs" new file mode 100644 index 0000000000000000000000000000000000000000..0dd9312d45d7fb2a7fc69bdf12fb7bbb77aa5390 --- /dev/null +++ "b/\345\210\230\346\257\205/\347\214\234\346\213\263/Liubei.cs" @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Liubei : Hero + { + public Liubei() { } + public Liubei(string name, int age, char sex) : base(name, age, sex) + { + base.Name = name; + base.Age = age; + base.Sex = sex; + } + public override void yuyin() + { + Console.WriteLine("在下{0},请多多指教。",base.Name); + } + public override void chu() + { + + } + } +} diff --git "a/\345\210\230\346\257\205/\347\214\234\346\213\263/Me.cs" "b/\345\210\230\346\257\205/\347\214\234\346\213\263/Me.cs" new file mode 100644 index 0000000000000000000000000000000000000000..2ae04473b508629e06fd55515e8e20f2e620077a --- /dev/null +++ "b/\345\210\230\346\257\205/\347\214\234\346\213\263/Me.cs" @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Me + { + + } +} diff --git "a/\345\210\230\346\257\205/\347\214\234\346\213\263/Program.cs" "b/\345\210\230\346\257\205/\347\214\234\346\213\263/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..40daa747b71bd7b4a2dcfe323c84707f94674e6a --- /dev/null +++ "b/\345\210\230\346\257\205/\347\214\234\346\213\263/Program.cs" @@ -0,0 +1,246 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + public enum Heroname//枚举英雄 + { + 刘备=1, + 孙权=2, + 曹操=3 + } + public enum Chuquaning//枚举出拳 + { + 剪刀 = 1, + 石头 = 2, + 布 = 3 + } + class Program + { + static void Main(string[] args)//主方法 + { + Play(); + } + public static void Play() + { + Caipan cp = new Caipan();//实例化裁判 + cp.RuleSpeak();//引入裁判规则 + //while (true) + //{ + Console.WriteLine("请选择对方角色<1:刘备 2:孙权 3:曹操>"); + int heroname = int.Parse(Console.ReadLine()); + Heroname he = (Heroname)Enum.Parse(typeof(Heroname), heroname.ToString()); + //if (heroname.Equals(he.)) + //{ + Console.WriteLine("请输入您的名字:"); + string username = Console.ReadLine(); + + Console.WriteLine("{0} vs {1} 对战", username, he); + Console.WriteLine("开始游戏吗?"); + string yn = Console.ReadLine(); + YN(yn, username, he); + //} + //else + //{ + // Console.WriteLine("输入英雄不存在,请重新输入!"); + //} + //} + } + public static void Youxi(string name,Heroname he) + { + Caipan cb = new Caipan(); + + //我方出拳 + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应数字:)"); + int renchuquan = int.Parse(Console.ReadLine()); + Chuquaning cqr = (Chuquaning)Enum.Parse(typeof(Chuquaning), renchuquan.ToString()); + + //电脑随机出拳 + int computercq = GetRandomByGuid(0, 3); + Chuquaning cqc = (Chuquaning)Enum.Parse(typeof(Chuquaning), computercq.ToString()); + + //比较双方出拳结果 + Bijiao(renchuquan,computercq,cb,name,he,cqc,cqr); + } + public static void Bijiao(int renchuquan, int computercq, Caipan cb, string name, Heroname he, Chuquaning cqc, Chuquaning cqr) + { + int time = 0; + int rscore = 0; + int cscore = 0; + while (true) + { + time++; + switch (renchuquan) + { + case 1: + Console.WriteLine($"{name}:出拳:{cqr}"); + Console.WriteLine($"{he}:出拳:{cqc}"); + qinkuan1(renchuquan, computercq, cb, name, rscore, cscore); + break; + case 2: + Console.WriteLine($"{name}:出拳:{cqr}"); + Console.WriteLine($"{he}:出拳:{cqc}"); + qinkuan2(renchuquan, computercq, cb, name, rscore, cscore); + break; + case 3: + Console.WriteLine($"{name}:出拳:{cqr}"); + Console.WriteLine($"{he}:出拳:{cqc}"); + qinkuan3(renchuquan, computercq, cb, name, rscore, cscore); + break; + default: + Console.WriteLine("出拳错误,请重新输入!"); + break; + } + + Console.WriteLine("是否开始下一轮?"); + string b = Console.ReadLine(); + + YNyn(b, name, he, rscore, cscore, time); + } + } + private static void qinkuan3(int aa,int bb,Caipan cb,string name,int rscore,int cscore) + { + if (aa == bb) + { + cb.He(); + } + else if (aa != bb) + { + if (aa == 1) + { + cb.Shibai(name); + cscore++; + } + else if (aa == 2) + { + cb.Win(name); + rscore++; + } + } + else + { + Console.WriteLine("输入错误!"); + } + } + private static void qinkuan2(int aa, int bb, Caipan cb,string name, int rscore, int cscore) + { + if (aa == bb) + { + cb.He(); + } + else if (aa != bb) + { + if (aa == 1) + { + cb.Win(name); + rscore ++; + } + else if (aa == 3) + { + cb.Shibai(name); + cscore++; + } + } + else + { + Console.WriteLine("输入错误!"); + } + } + private static void qinkuan1(int ren, int cpu, Caipan cb, string name, int rscore, int cscore) + { + if (ren == cpu) + { + cb.He(); + } + else if (ren != cpu) + { + if (cpu == 2) + { + cb.Shibai(name); + cscore ++; + } + else if (cpu == 3) + { + cb.Win(name); + rscore++; + } + } + else + { + Console.WriteLine("输入错误!"); + } + } + static void Return(string name,Heroname he,int cishu,int rfs,int cfs) + { + Caipan cb = new Caipan(); + cb.returnup(name,he,cishu,rfs,cfs); + + Console.WriteLine("要开始下一局吗?"); + string xzxz = Console.ReadLine(); + YN(xzxz, name, he); + } + + private static void YN(string beginorend, string name, Heroname he) + { + if (beginorend == "y") + { + Youxi(name, he); + } + else if (beginorend == "Y") + { + Youxi(name, he); + } + else if (beginorend == "n") + { + Play(); + } + else if (beginorend == "N") + { + Play(); + } + else + { + Console.WriteLine("系统退出!"); + Environment.Exit(0); + } + } + private static void YNyn(string xz,string name, Heroname h,int rfengshu,int cfengshu,int time) + { + if (xz == "y") + { + Youxi(name,h); + } + else if (xz == "Y") + { + Youxi(name,h); + } + else if (xz == "n") + { + Return(name,h, time, rfengshu, cfengshu); + } + else if (xz == "N") + { + Return(name,h, time, rfengshu, cfengshu); + } + else + { + Console.WriteLine("系统退出!"); + Environment.Exit(0); + } + } + //电脑出拳 + private static int GetRandomByGuid(int min, int max) + { + Random ro = new Random(GetRandomSeedByGuid()); + int ronum = ro.Next(min, max); + return ronum; + } + static int GetRandomSeedByGuid() + { + return new Guid().GetHashCode(); + } + } +} \ No newline at end of file diff --git "a/\345\210\230\346\257\205/\347\214\234\346\213\263/Sunquan.cs" "b/\345\210\230\346\257\205/\347\214\234\346\213\263/Sunquan.cs" new file mode 100644 index 0000000000000000000000000000000000000000..7a3a3500f37c484a3a5c29fac3e265176460b10d --- /dev/null +++ "b/\345\210\230\346\257\205/\347\214\234\346\213\263/Sunquan.cs" @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Sunquan : Hero + { + public Sunquan() { } + public Sunquan(string name, int age, char sex) : base(name, age, sex) + { + base.Name = name; + base.Age = age; + base.Sex = sex; + } + public override void yuyin() + { + Console.WriteLine($"{base.Name}在此,有何贵干?"); + } + public override void chu() + { + + } + } +} + diff --git "a/\345\210\230\346\257\205/\347\273\223\346\236\204\344\275\223/PersonClass.cs" "b/\345\210\230\346\257\205/\347\273\223\346\236\204\344\275\223/PersonClass.cs" new file mode 100644 index 0000000000000000000000000000000000000000..273c08f242b78e70b9e6e1c6f77bf3fbb7ef4fad --- /dev/null +++ "b/\345\210\230\346\257\205/\347\273\223\346\236\204\344\275\223/PersonClass.cs" @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class PersonClass + { + private string name; + private long phone; + private string adder; + + public PersonClass() + { } + public PersonClass(string name, long phone, string adder) + { + this.name = name; + this.phone = phone; + this.adder = adder; + } + + public string Name { get => name; set => name = value; } + public long Phone { get => phone; set => phone = value; } + public string Adder { get => adder; set => adder = value; } + } +} diff --git "a/\345\210\230\346\257\205/\347\273\223\346\236\204\344\275\223/Program.cs" "b/\345\210\230\346\257\205/\347\273\223\346\236\204\344\275\223/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..0de329ac220a770e63f33ab7755dc980c2f7a186 --- /dev/null +++ "b/\345\210\230\346\257\205/\347\273\223\346\236\204\344\275\223/Program.cs" @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + //定义一个结构体,名为PersonStruct,有三个成员变量:姓名、电话、地址, + //在主方法中,创建一个PersonStruct结构体对象p1,为p1的成员变量赋值。 + //再声明一个PersonStruct结构体变量p2,把p1赋值给p2,改变p2的姓名,打印p1的内容。 + + //定义一个类,名为PersonClass,有三个成员变量:姓名、电话、地址, + //在主方法中,创建一个PersonClass对象p3,为p3的成员变量赋值。 + //再声明一个PersonClass变量p4,把p3赋值给p4,改变p4的姓名,打印p3的内容。 + + + //观察打印结果,并在在注释中,说下你对此的认识(它们为什么会这样?) + class Program + { + /// + /// 它们为什么会这样? + /// 因为: + /// struct 有自己的存储空间,p1、p2相当于有两个分开的存储空间,p1的值赋值给p2,p1的值不会改变(p1有单独的存储空间)。 + /// class 是共有存储空间,p1、p2的值是相通的,p2值被改变,p1值同时被改变,反之亦然。 + /// + public struct PersonStruct + { + public string name; + public long phone; + public string adder; + } + + + static void Main(string[] args) + { + + + + PersonStruct p1 = new PersonStruct(); + p1.name = "阿珍"; + p1.phone =13520148521; + p1.adder = "上海老街"; + + + PersonStruct p2 = new PersonStruct(); + p2 = p1; + p2.name = "阿强"; + Console.WriteLine(p1.name);//未改变 + + + PersonClass p3 = new PersonClass(); + p3.Name = "阿珍爱上了阿强"; + p3.Phone = 12365485201; + p3.Adder = "夜上海"; + + + PersonClass p4 = new PersonClass(); + p4 = p3; + p4.Name = "阿强爱上了阿珍"; + Console.WriteLine(p3.Name);//改变 + + + } + } +} diff --git "a/\345\210\230\346\261\211\346\226\207/Ad.cs" "b/\345\210\230\346\261\211\346\226\207/Ad.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b891a05aac3c99b17143c84194e417bb3ee99f72 --- /dev/null +++ "b/\345\210\230\346\261\211\346\226\207/Ad.cs" @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp14 +{ + class Ad + { + private string name; + + public Ad(string name) + { + this.name = name; + } + + public string Name { get => name; set => name = value; } + + public int Test1() + { + Console.WriteLine("请你选择出拳:1.剪刀 2.石头 3.布"); + int k = int.Parse(Console.ReadLine()); + switch (k) + { + case 1: + Console.WriteLine("{0}出了一个剪刀",name); + break; + case 2: + Console.WriteLine("{0}出了一个石头", name); + break; + case 3: + Console.WriteLine("{0}出了一个布",name); + break; + } + + return k; + } + } +} diff --git "a/\345\210\230\346\261\211\346\226\207/Judgment.cs" "b/\345\210\230\346\261\211\346\226\207/Judgment.cs" new file mode 100644 index 0000000000000000000000000000000000000000..182875c08e13b27cc0c103d36f8bf178865f97fd --- /dev/null +++ "b/\345\210\230\346\261\211\346\226\207/Judgment.cs" @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp14 +{ + class Judgment + { + int sum1 = 0; + int sum2 = 0; + int sum3 = 0; + int sum4 = 0; + + public void Date(int p1, int p2) + { + if (p1 - p2 == -2 || p1 - p2 == 1) + { + Console.WriteLine("玩家胜利!"); + sum2++; + } + else if (p1 == p2) + { + Console.WriteLine("平局"); + sum3++; + } + else + { + Console.WriteLine("玩家失败!"); + sum4++; + } + sum1 = sum2 + sum3 + sum4; + + } + + + internal void Date1() + { + Console.WriteLine("你的胜场数:{0}", sum2); + Console.WriteLine("对手胜场数:{0}", sum4); + Console.WriteLine("平局场数:{0}", sum3); + Console.WriteLine("总场数:{0}", sum1); + if (sum2 > sum4) + { + Console.WriteLine("你赢了"); + } + else if (sum2 < sum4) + { + Console.WriteLine("你输了"); + } + else if (sum2 == sum4) + { + Console.WriteLine("平局"); + } + } + } +} \ No newline at end of file diff --git "a/\345\210\230\346\261\211\346\226\207/Mdf.cs" "b/\345\210\230\346\261\211\346\226\207/Mdf.cs" new file mode 100644 index 0000000000000000000000000000000000000000..4747da175237f216f08b84c80ce3266387d2832d --- /dev/null +++ "b/\345\210\230\346\261\211\346\226\207/Mdf.cs" @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp14 +{ + class Npc : Ad + { + private string name1; + + public Npc(string name, string name1) : base(name) + { + this.Name1 = name1; + + } + + public string Name1 { get => name1; set => name1 = value; } + + public int MDF1() + { + Random random = new Random(); + int result = random.Next(1, 4); + string str = Convert.ToString(result); + switch (result) + { + case 1: + str = "剪刀"; + break; + case 2: + str = "石头"; + break; + case 3: + str = "布"; + break; + } + Console.WriteLine("{0}出了一个{1}",name1,str); + return result; + } + } +} \ No newline at end of file diff --git "a/\345\210\230\346\261\211\346\226\207/Program.cs" "b/\345\210\230\346\261\211\346\226\207/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..99c66e66ee02b036ec0fb2b783dfa0d1acb6aa97 --- /dev/null +++ "b/\345\210\230\346\261\211\346\226\207/Program.cs" @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp14 +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("---------------欢 迎 进 入 英 雄 联 盟 猜 拳 游 戏--------------"); + Console.WriteLine(); + Console.WriteLine("*********************猜拳开始***********************"); + Console.WriteLine(); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Console.WriteLine("请输入你的名字"); + string name = Console.ReadLine(); + Me me = new Me(name); + + Judgment judgment = new Judgment(); + Console.WriteLine("请选择你对战的角色:1.迪莫 2.小法 3.亚索"); + int a = int.Parse(Console.ReadLine()); + string str = Convert.ToString(a); + switch (str) + { + case "1": + str = "迪莫"; + break; + case "2": + str = "小法"; + break; + case "3": + str = "亚索"; + break; + default: + break; + } + + Mdf mdf = new Mdf(name,str); + switch (a) + { + case 1: + Console.WriteLine("{0} vs 迪莫", name); + dong(ad,mdf,judgment); + break; + case 2: + Console.WriteLine("{0} vs 小法", name); + dong(ad, mdf, judgment); + break; + case 3: + Console.WriteLine("{0} vs 亚索", name); + dong(ad, mdf, judgment); + break; + default: + break; + + } + + } + public static void dong(Ad ad,Mdf mdf,Judgment judgment) + { + + Console.WriteLine("游戏开始吗?"); + string str = Console.ReadLine(); + switch (str) + { + case "y": + dong2(ad, mdf, judgment); + break; + case "n": + + break; + } + } + public static void dong2(Ad ad, Mdf mdf, Judgment judgment) { + while (true) + { + int p1 = ad.Test1(); + int p2 = mdf.NPC1(); + judgment.Date(p1,p2); + Console.WriteLine("是否进行下一轮?"); + string str = Console.ReadLine(); + switch (str) + { + case "y": + dong2(ad, mdf, judgment); + break; + case "n": + judgment.Date1(); + break; + } + break; + } + } + } + } diff --git "a/\345\210\230\351\207\221\346\265\267/Program.cs" "b/\345\210\230\351\207\221\346\265\267/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..58342bfae6c1e807c72b1097eea5f015921b2964 --- /dev/null +++ "b/\345\210\230\351\207\221\346\265\267/Program.cs" @@ -0,0 +1,129 @@ +using ConsoleApp2; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp +{ + class Program + { + + enum enrole + { + 刘备 = 1, + 曹操 = 2, + 孙权 = 3 + } + enum enMora + { + 石头 = 1, + 剪刀 = 2, + 布 = 3 + } + static void Main(string[] args) + { + Console.WriteLine("欢迎来到游戏世界" + "\n"); + Console.WriteLine("猜拳开始"); + Console.WriteLine("出拳规则:1、石头 2、剪刀 3、布"); + Console.WriteLine("请选择对方的角色(1、刘备 2 、曹操 3、孙权"); + int numname = int.Parse(Console.ReadLine()); + string npcstr = Enum.GetName(typeof(enrole), numname); + Role role = new Role(npcstr); + Console.WriteLine("请输入您的名字"); + string playname = Console.ReadLine(); + Console.WriteLine(playname + "Vs" + npcstr); + Console.WriteLine("是否开始游戏(Y/N)"); + char char1 = Convert.ToChar(Console.ReadLine()); + if (char1 == 'Y' || char1 == 'y') + { + WinMora(role, npcstr, playname); + } + else if (char1 == 'N' || char1 == 'n') + { + Console.WriteLine("退出游戏"); + } + Console.WriteLine("要开始新的游戏吗?(Y/N)"); + char char2 = Convert.ToChar(Console.ReadLine()); + if (char2 == 'Y' || char2 == 'y') + { + WinMora(role, npcstr, playname); + + } + else if (char2 == 'N' || char2 == 'n') + { + Console.WriteLine("退出程序"); + System.Environment.Exit(0); + } + } + + private static void WinMora(Role role, string npcstr, string playname) + { + int draw = 0; + int NPCwin = 0; + int Playwin = 0; + + while (true) + { + Console.WriteLine("请出拳1.石头2.剪刀3.布请输入数字(请输入相应的数字)"); + int Moranum = int.Parse(Console.ReadLine()); + string playMora = Enum.GetName(typeof(enMora), Moranum); //获取用户输入的数字转化为相应的枚举里的值 + + Console.WriteLine(playname + " : 出拳: " + playMora); + role.Write(); + + if (role.StrMora == playMora) + { + Console.WriteLine("平局,放你一马"); + draw = draw + 1; + } + else if (playMora == "石头" && role.StrMora == "剪刀" || playMora == "布" && role.StrMora == "石头" || playMora == "剪刀" && role.StrMora == "布") + { + Console.WriteLine("恭喜您,勇夺三军,天下无双"); + Playwin = Playwin + 1; + } + else if (role.StrMora == "剪刀" && playMora == "布" || role.StrMora == "石头" && playMora == "剪刀" || role.StrMora == "布" && playMora == "石头") + { + Console.WriteLine("天啦噜,难以置信,这也会输"); + NPCwin = NPCwin + 1; + } + else if (playMora != "石头" || playMora != "剪刀" || playMora != "布") + { + NPCwin = NPCwin + 1; + Console.WriteLine("玩家,出拳不符合规则默认判负"); + } + + Console.WriteLine("是否开始下一局(y/n)"); + char char2 = Convert.ToChar(Console.ReadLine()); + if (char2 == 'y' || char2 == 'Y') + { + + } + else if (char2 == 'n' || char2 == 'N') + { + Console.WriteLine("结束游戏"); + Console.WriteLine("==========================="); + Console.WriteLine(playname + " VS " + npcstr); + Console.WriteLine("对战次数" + (Playwin + NPCwin + draw)); + Console.WriteLine("姓名 得分"); + Console.WriteLine($"{playname} {Playwin}"); + Console.WriteLine($"{npcstr} {NPCwin}"); + if (Playwin > NPCwin) + { + Console.WriteLine("玩家 " + playname + " 胜出,举世同庆"); + } + else if (NPCwin > Playwin) + { + Console.WriteLine("电脑" + npcstr + "胜出,棋差一手"); + } + else + { + Console.WriteLine("平局"); + } + break; + } + } + } + } +} diff --git "a/\345\210\230\351\207\221\346\265\267/Role.cs" "b/\345\210\230\351\207\221\346\265\267/Role.cs" new file mode 100644 index 0000000000000000000000000000000000000000..79b3286b21420bcd3631043ac6b614db2be3a227 --- /dev/null +++ "b/\345\210\230\351\207\221\346\265\267/Role.cs" @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Role + { + private string name; + private string strmora; + public string Name { get; set; } + public string StrMora + { + get { return this.strmora; } + set { this.strmora = value; } + } + + public Role(string name) + { + this.Name = name; + } + public void Test(string strmora) + { + Random random = new Random(); + + if (random.Next(1, 4) == 1) + { + strmora = "石头"; + } + else if (random.Next(1, 4) == 2) + { + strmora = "布"; + } + else if (random.Next(1, 4) == 3) + { + strmora = "剪刀"; + } + this.StrMora = strmora; + } + public void Write() + { + Test(strmora); + StrMora = strmora; + Console.WriteLine("{0}: 出手 :{1}", Name, StrMora); + } + + } +} diff --git "a/\345\210\230\351\207\221\346\265\267/\347\214\234\346\213\263/Caipan.cs" "b/\345\210\230\351\207\221\346\265\267/\347\214\234\346\213\263/Caipan.cs" new file mode 100644 index 0000000000000000000000000000000000000000..41678d3ec6254a216d0f015c1cc84d47dc9e2d25 --- /dev/null +++ "b/\345\210\230\351\207\221\346\265\267/\347\214\234\346\213\263/Caipan.cs" @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Caipan + { + public void RuleSpeak() + { + Console.WriteLine("------欢迎进入游戏世界------"); + Console.WriteLine(); + Console.WriteLine("****************************"); + Console.WriteLine("*********猜拳,开始*********"); + Console.WriteLine("****************************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + } + public void returnup(string name,Heroname he,int counttime, int result1,int result2) + { + + Console.WriteLine("==================================="); + Console.WriteLine($"{name} vs {he}"); + Console.WriteLine($"对战次数:{counttime}"); + Console.WriteLine(); + Console.WriteLine($"姓名\t得分"); + Console.WriteLine($"{name}\t{result1}"); + Console.WriteLine($"{he}\t{result2}"); + Console.Write("结果:"); + result(name, he, result1, result2); + } + public void result(string name,Heroname he,int result1,int result2) + { + if (result1 > result2) + { + Console.WriteLine($"{name}赢,{he}笨蛋"); + } + else if(result1 > result2) + { + Console.WriteLine($"{he}赢,{name}笨蛋"); + } + else + { + Console.WriteLine("平局!"); + } + } + public void Shibai(string name) + { + Console.WriteLine($"笨蛋,{name}输了"); + } + public void Win(string name) + { + Console.WriteLine($"恭喜,{name}赢了"); + } + public void He() + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + } +} \ No newline at end of file diff --git "a/\345\210\230\351\207\221\346\265\267/\347\214\234\346\213\263/Cc.cs" "b/\345\210\230\351\207\221\346\265\267/\347\214\234\346\213\263/Cc.cs" new file mode 100644 index 0000000000000000000000000000000000000000..f53b9dd8c9d5d2f5b9184a49890a2f1a20abfcd4 --- /dev/null +++ "b/\345\210\230\351\207\221\346\265\267/\347\214\234\346\213\263/Cc.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Cc : Hero + { + public Cc(string name, int age, char sex) : base(name, age, sex) + { + base.Name = name; + base.Age = age; + base.Sex = sex; + } + public override void yuyin() + { + Console.WriteLine($"在下{base.Name},后会有期~"); + } + public override void chu() + { + + } + } +} diff --git "a/\345\210\230\351\207\221\346\265\267/\347\214\234\346\213\263/Computer.cs" "b/\345\210\230\351\207\221\346\265\267/\347\214\234\346\213\263/Computer.cs" new file mode 100644 index 0000000000000000000000000000000000000000..6316148b9860f879a07fc5800e5d27a66551817d --- /dev/null +++ "b/\345\210\230\351\207\221\346\265\267/\347\214\234\346\213\263/Computer.cs" @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + enum chuquanf + { + 剪刀=1, + 石头=2, + 布=3 + } + class Computer + { + Random rd = new Random(); + string[] arr = new string[3]; + int temp = 0; + int max = 3; + int min = 1; + //chuquanf cq = (chuquanf)Enum.Parse(typeof(chuquanf), rd); + public void chuquan() + { + + } + } +} diff --git "a/\345\210\230\351\207\221\346\265\267/\347\214\234\346\213\263/Hero.cs" "b/\345\210\230\351\207\221\346\265\267/\347\214\234\346\213\263/Hero.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b77c9584ec9d7403ca7e6008feee07edcc6698ea --- /dev/null +++ "b/\345\210\230\351\207\221\346\265\267/\347\214\234\346\213\263/Hero.cs" @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + abstract class Hero + { + private string name; + private int age; + private char sex; + public Hero() + { } + public Hero(string name, int age, char sex) + { + this.name = name; + this.age = age; + this.sex = sex; + } + + public string Name + { + get { return this.name; } + set { this.name = value; } + } + + public int Age { get => age; set => age = value; } + public char Sex { get => sex; set => sex = value; } + public abstract void yuyin(); + public abstract void chu(); + } +} diff --git "a/\345\210\230\351\207\221\346\265\267/\347\214\234\346\213\263/Liubei.cs" "b/\345\210\230\351\207\221\346\265\267/\347\214\234\346\213\263/Liubei.cs" new file mode 100644 index 0000000000000000000000000000000000000000..0dd9312d45d7fb2a7fc69bdf12fb7bbb77aa5390 --- /dev/null +++ "b/\345\210\230\351\207\221\346\265\267/\347\214\234\346\213\263/Liubei.cs" @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Liubei : Hero + { + public Liubei() { } + public Liubei(string name, int age, char sex) : base(name, age, sex) + { + base.Name = name; + base.Age = age; + base.Sex = sex; + } + public override void yuyin() + { + Console.WriteLine("在下{0},请多多指教。",base.Name); + } + public override void chu() + { + + } + } +} diff --git "a/\345\210\230\351\207\221\346\265\267/\347\214\234\346\213\263/Me.cs" "b/\345\210\230\351\207\221\346\265\267/\347\214\234\346\213\263/Me.cs" new file mode 100644 index 0000000000000000000000000000000000000000..2ae04473b508629e06fd55515e8e20f2e620077a --- /dev/null +++ "b/\345\210\230\351\207\221\346\265\267/\347\214\234\346\213\263/Me.cs" @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Me + { + + } +} diff --git "a/\345\210\230\351\207\221\346\265\267/\347\214\234\346\213\263/Program.cs" "b/\345\210\230\351\207\221\346\265\267/\347\214\234\346\213\263/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..40daa747b71bd7b4a2dcfe323c84707f94674e6a --- /dev/null +++ "b/\345\210\230\351\207\221\346\265\267/\347\214\234\346\213\263/Program.cs" @@ -0,0 +1,246 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + public enum Heroname//枚举英雄 + { + 刘备=1, + 孙权=2, + 曹操=3 + } + public enum Chuquaning//枚举出拳 + { + 剪刀 = 1, + 石头 = 2, + 布 = 3 + } + class Program + { + static void Main(string[] args)//主方法 + { + Play(); + } + public static void Play() + { + Caipan cp = new Caipan();//实例化裁判 + cp.RuleSpeak();//引入裁判规则 + //while (true) + //{ + Console.WriteLine("请选择对方角色<1:刘备 2:孙权 3:曹操>"); + int heroname = int.Parse(Console.ReadLine()); + Heroname he = (Heroname)Enum.Parse(typeof(Heroname), heroname.ToString()); + //if (heroname.Equals(he.)) + //{ + Console.WriteLine("请输入您的名字:"); + string username = Console.ReadLine(); + + Console.WriteLine("{0} vs {1} 对战", username, he); + Console.WriteLine("开始游戏吗?"); + string yn = Console.ReadLine(); + YN(yn, username, he); + //} + //else + //{ + // Console.WriteLine("输入英雄不存在,请重新输入!"); + //} + //} + } + public static void Youxi(string name,Heroname he) + { + Caipan cb = new Caipan(); + + //我方出拳 + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应数字:)"); + int renchuquan = int.Parse(Console.ReadLine()); + Chuquaning cqr = (Chuquaning)Enum.Parse(typeof(Chuquaning), renchuquan.ToString()); + + //电脑随机出拳 + int computercq = GetRandomByGuid(0, 3); + Chuquaning cqc = (Chuquaning)Enum.Parse(typeof(Chuquaning), computercq.ToString()); + + //比较双方出拳结果 + Bijiao(renchuquan,computercq,cb,name,he,cqc,cqr); + } + public static void Bijiao(int renchuquan, int computercq, Caipan cb, string name, Heroname he, Chuquaning cqc, Chuquaning cqr) + { + int time = 0; + int rscore = 0; + int cscore = 0; + while (true) + { + time++; + switch (renchuquan) + { + case 1: + Console.WriteLine($"{name}:出拳:{cqr}"); + Console.WriteLine($"{he}:出拳:{cqc}"); + qinkuan1(renchuquan, computercq, cb, name, rscore, cscore); + break; + case 2: + Console.WriteLine($"{name}:出拳:{cqr}"); + Console.WriteLine($"{he}:出拳:{cqc}"); + qinkuan2(renchuquan, computercq, cb, name, rscore, cscore); + break; + case 3: + Console.WriteLine($"{name}:出拳:{cqr}"); + Console.WriteLine($"{he}:出拳:{cqc}"); + qinkuan3(renchuquan, computercq, cb, name, rscore, cscore); + break; + default: + Console.WriteLine("出拳错误,请重新输入!"); + break; + } + + Console.WriteLine("是否开始下一轮?"); + string b = Console.ReadLine(); + + YNyn(b, name, he, rscore, cscore, time); + } + } + private static void qinkuan3(int aa,int bb,Caipan cb,string name,int rscore,int cscore) + { + if (aa == bb) + { + cb.He(); + } + else if (aa != bb) + { + if (aa == 1) + { + cb.Shibai(name); + cscore++; + } + else if (aa == 2) + { + cb.Win(name); + rscore++; + } + } + else + { + Console.WriteLine("输入错误!"); + } + } + private static void qinkuan2(int aa, int bb, Caipan cb,string name, int rscore, int cscore) + { + if (aa == bb) + { + cb.He(); + } + else if (aa != bb) + { + if (aa == 1) + { + cb.Win(name); + rscore ++; + } + else if (aa == 3) + { + cb.Shibai(name); + cscore++; + } + } + else + { + Console.WriteLine("输入错误!"); + } + } + private static void qinkuan1(int ren, int cpu, Caipan cb, string name, int rscore, int cscore) + { + if (ren == cpu) + { + cb.He(); + } + else if (ren != cpu) + { + if (cpu == 2) + { + cb.Shibai(name); + cscore ++; + } + else if (cpu == 3) + { + cb.Win(name); + rscore++; + } + } + else + { + Console.WriteLine("输入错误!"); + } + } + static void Return(string name,Heroname he,int cishu,int rfs,int cfs) + { + Caipan cb = new Caipan(); + cb.returnup(name,he,cishu,rfs,cfs); + + Console.WriteLine("要开始下一局吗?"); + string xzxz = Console.ReadLine(); + YN(xzxz, name, he); + } + + private static void YN(string beginorend, string name, Heroname he) + { + if (beginorend == "y") + { + Youxi(name, he); + } + else if (beginorend == "Y") + { + Youxi(name, he); + } + else if (beginorend == "n") + { + Play(); + } + else if (beginorend == "N") + { + Play(); + } + else + { + Console.WriteLine("系统退出!"); + Environment.Exit(0); + } + } + private static void YNyn(string xz,string name, Heroname h,int rfengshu,int cfengshu,int time) + { + if (xz == "y") + { + Youxi(name,h); + } + else if (xz == "Y") + { + Youxi(name,h); + } + else if (xz == "n") + { + Return(name,h, time, rfengshu, cfengshu); + } + else if (xz == "N") + { + Return(name,h, time, rfengshu, cfengshu); + } + else + { + Console.WriteLine("系统退出!"); + Environment.Exit(0); + } + } + //电脑出拳 + private static int GetRandomByGuid(int min, int max) + { + Random ro = new Random(GetRandomSeedByGuid()); + int ronum = ro.Next(min, max); + return ronum; + } + static int GetRandomSeedByGuid() + { + return new Guid().GetHashCode(); + } + } +} \ No newline at end of file diff --git "a/\345\210\230\351\207\221\346\265\267/\347\214\234\346\213\263/Sunquan.cs" "b/\345\210\230\351\207\221\346\265\267/\347\214\234\346\213\263/Sunquan.cs" new file mode 100644 index 0000000000000000000000000000000000000000..7a3a3500f37c484a3a5c29fac3e265176460b10d --- /dev/null +++ "b/\345\210\230\351\207\221\346\265\267/\347\214\234\346\213\263/Sunquan.cs" @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Sunquan : Hero + { + public Sunquan() { } + public Sunquan(string name, int age, char sex) : base(name, age, sex) + { + base.Name = name; + base.Age = age; + base.Sex = sex; + } + public override void yuyin() + { + Console.WriteLine($"{base.Name}在此,有何贵干?"); + } + public override void chu() + { + + } + } +} + diff --git "a/\345\210\230\351\207\221\346\265\267/\347\273\223\346\236\204\344\275\223/PersonClass.cs" "b/\345\210\230\351\207\221\346\265\267/\347\273\223\346\236\204\344\275\223/PersonClass.cs" new file mode 100644 index 0000000000000000000000000000000000000000..273c08f242b78e70b9e6e1c6f77bf3fbb7ef4fad --- /dev/null +++ "b/\345\210\230\351\207\221\346\265\267/\347\273\223\346\236\204\344\275\223/PersonClass.cs" @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class PersonClass + { + private string name; + private long phone; + private string adder; + + public PersonClass() + { } + public PersonClass(string name, long phone, string adder) + { + this.name = name; + this.phone = phone; + this.adder = adder; + } + + public string Name { get => name; set => name = value; } + public long Phone { get => phone; set => phone = value; } + public string Adder { get => adder; set => adder = value; } + } +} diff --git "a/\345\210\230\351\207\221\346\265\267/\347\273\223\346\236\204\344\275\223/Program.cs" "b/\345\210\230\351\207\221\346\265\267/\347\273\223\346\236\204\344\275\223/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..0de329ac220a770e63f33ab7755dc980c2f7a186 --- /dev/null +++ "b/\345\210\230\351\207\221\346\265\267/\347\273\223\346\236\204\344\275\223/Program.cs" @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + //定义一个结构体,名为PersonStruct,有三个成员变量:姓名、电话、地址, + //在主方法中,创建一个PersonStruct结构体对象p1,为p1的成员变量赋值。 + //再声明一个PersonStruct结构体变量p2,把p1赋值给p2,改变p2的姓名,打印p1的内容。 + + //定义一个类,名为PersonClass,有三个成员变量:姓名、电话、地址, + //在主方法中,创建一个PersonClass对象p3,为p3的成员变量赋值。 + //再声明一个PersonClass变量p4,把p3赋值给p4,改变p4的姓名,打印p3的内容。 + + + //观察打印结果,并在在注释中,说下你对此的认识(它们为什么会这样?) + class Program + { + /// + /// 它们为什么会这样? + /// 因为: + /// struct 有自己的存储空间,p1、p2相当于有两个分开的存储空间,p1的值赋值给p2,p1的值不会改变(p1有单独的存储空间)。 + /// class 是共有存储空间,p1、p2的值是相通的,p2值被改变,p1值同时被改变,反之亦然。 + /// + public struct PersonStruct + { + public string name; + public long phone; + public string adder; + } + + + static void Main(string[] args) + { + + + + PersonStruct p1 = new PersonStruct(); + p1.name = "阿珍"; + p1.phone =13520148521; + p1.adder = "上海老街"; + + + PersonStruct p2 = new PersonStruct(); + p2 = p1; + p2.name = "阿强"; + Console.WriteLine(p1.name);//未改变 + + + PersonClass p3 = new PersonClass(); + p3.Name = "阿珍爱上了阿强"; + p3.Phone = 12365485201; + p3.Adder = "夜上海"; + + + PersonClass p4 = new PersonClass(); + p4 = p3; + p4.Name = "阿强爱上了阿珍"; + Console.WriteLine(p3.Name);//改变 + + + } + } +} diff --git "a/\345\214\205\346\254\243\345\246\202/Judgment.cs" "b/\345\214\205\346\254\243\345\246\202/Judgment.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b861efb6dc7d6ec8751737a44228e0c17692102f --- /dev/null +++ "b/\345\214\205\346\254\243\345\246\202/Judgment.cs" @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp14 +{ + class Judgment + { + int sum1 = 0; + int sum2 = 0; + int sum3 = 0; + int sum4 = 0; + + public void Date(int p1, int p2) + { + if (p1 - p2 == -2 || p1 - p2 == 1) + { + Console.WriteLine("玩家胜利!"); + sum2++; + } + else if (p1 == p2) + { + Console.WriteLine("平局"); + sum3++; + } + else + { + Console.WriteLine("玩家失败!"); + sum4++; + } + int sum1 = sum2 + sum3 + sum4; + + } + + + internal void Date1() + { + Console.WriteLine("你的胜场数:{0}", sum2); + Console.WriteLine("对手胜场数:{0}", sum4); + Console.WriteLine("平局场数:{0}", sum3); + Console.WriteLine("总场数:{0}", sum1); + if (sum2 > sum4) + { + Console.WriteLine("你赢了"); + } + else if (sum2 < sum4) + { + Console.WriteLine("你输了"); + } + else if (sum2 == sum4) + { + Console.WriteLine("平局"); + } + } + } +} \ No newline at end of file diff --git "a/\345\214\205\346\254\243\345\246\202/Me.cs" "b/\345\214\205\346\254\243\345\246\202/Me.cs" new file mode 100644 index 0000000000000000000000000000000000000000..e2e5257ae0c5763fc3c608ecc9eab900feaeaa37 --- /dev/null +++ "b/\345\214\205\346\254\243\345\246\202/Me.cs" @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp14 +{ + class Me + { + private string name; + + public Me(string name) + { + this.name = name; + } + + public string Name { get => name; set => name = value; } + + public int Test1() + { + Console.WriteLine("请你选择出拳:1.剪刀 2.石头 3.布"); + int a = int.Parse(Console.ReadLine()); + switch (a) + { + case 1: + Console.WriteLine("{0}出了一个剪刀",name); + break; + case 2: + Console.WriteLine("{0}出了一个石头", name); + break; + case 3: + Console.WriteLine("{0}出了一个布",name); + break; + } + + return a; + } + } +} diff --git "a/\345\214\205\346\254\243\345\246\202/Npc.cs" "b/\345\214\205\346\254\243\345\246\202/Npc.cs" new file mode 100644 index 0000000000000000000000000000000000000000..402cf20e31a597d6c286995b12dafd98207c665c --- /dev/null +++ "b/\345\214\205\346\254\243\345\246\202/Npc.cs" @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp14 +{ + class Npc : Me + { + private string name1; + + public Npc(string name, string name1) : base(name) + { + this.Name1 = name1; + + } + + public string Name1 { get => name1; set => name1 = value; } + + public int NPC1() + { + Random random = new Random(); + int result = random.Next(1, 4); + string str = Convert.ToString(result); + switch (result) + { + case 1: + str = "剪刀"; + break; + case 2: + str = "石头"; + break; + case 3: + str = "布"; + break; + } + Console.WriteLine("{0}出了一个{1}",name1,str); + return result; + } + } +} \ No newline at end of file diff --git "a/\345\214\205\346\254\243\345\246\202/Program.cs" "b/\345\214\205\346\254\243\345\246\202/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..1c9a9bf48c5b8883b41f24f3319615eacf148fc2 --- /dev/null +++ "b/\345\214\205\346\254\243\345\246\202/Program.cs" @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp14 +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine(" 开发人员:杨丰豪"); + Console.WriteLine(); + Console.WriteLine("------------欢 迎 进 入 三 国 猜 拳 游 戏-----------"); + Console.WriteLine("****************************************************"); + Console.WriteLine("********************猜拳开始************************"); + Console.WriteLine("****************************************************"); + Console.WriteLine(); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Console.WriteLine(); + Console.WriteLine("请输入你的名字"); + string name = Console.ReadLine(); + Me me = new Me(name); + + Judgment judgment = new Judgment(); + Console.WriteLine("请选择你对战的角色:1.刘备 2.孙权 3.曹操"); + int a = int.Parse(Console.ReadLine()); + string str = Convert.ToString(a); + switch (str) + { + case "1": + str = "刘备"; + break; + case "2": + str = "孙权"; + break; + case "3": + str = "曹操"; + break; + default: + break; + } + + Npc npc = new Npc(name,str); + switch (a) + { + case 1: + Console.WriteLine("{0} vs 刘备",name); + dong(me,npc,judgment); + break; + case 2: + Console.WriteLine("{0} vs 孙权", name); + dong(me, npc, judgment); + break; + case 3: + Console.WriteLine("{0} vs 曹操", name); + dong(me, npc, judgment); + break; + default: + break; + + } + + } + public static void dong(Me me,Npc npc,Judgment judgment) + { + + Console.WriteLine("游戏开始吗?"); + string str = Console.ReadLine(); + switch (str) + { + case "y": + dong2(me, npc, judgment); + break; + case "n": + + break; + } + } + public static void dong2(Me me, Npc npc, Judgment judgment) { + while (true) + { + int p1 = me.Test1(); + int p2 = npc.NPC1(); + judgment.Date(p1,p2); + Console.WriteLine("是否进行下一轮?"); + string str = Console.ReadLine(); + switch (str) + { + case "y": + dong2(me, npc, judgment); + break; + case "n": + judgment.Date1(); + break; + } + break; + } + } + } + } diff --git "a/\345\217\266\347\234\237/.keep" "b/\345\217\266\347\234\237/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\345\217\266\347\234\237/\345\211\252\345\210\200\347\237\263\345\244\264\345\270\203/Master.cs" "b/\345\217\266\347\234\237/\345\211\252\345\210\200\347\237\263\345\244\264\345\270\203/Master.cs" new file mode 100644 index 0000000000000000000000000000000000000000..43013036775ea7249d49e830252a00004ca1e41e --- /dev/null +++ "b/\345\217\266\347\234\237/\345\211\252\345\210\200\347\237\263\345\244\264\345\270\203/Master.cs" @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Master + { + private string playerName; + private string judgment; + private int npcAttack; + private string npcName; + + public string PlayerName + { + get { return this.playerName; } + set { this.playerName = value; } + } + public int NpcAttack + { + get { return this.npcAttack; } + set { this.npcAttack = value; } + } + public string NpcName + { + get { return this.npcName; } + set { this.npcName = value; } + } + public string Judgment + { + get { return this.judgment; } + set { this.judgment = value; } + } + public void JudgmentSayBegin() + { + Console.WriteLine("裁判:猜拳比赛"); + Console.WriteLine("裁判:猜拳规则:1、剪刀2、石头3、布"); + } + public Master() { } + + } +} diff --git "a/\345\217\266\347\234\237/\345\211\252\345\210\200\347\237\263\345\244\264\345\270\203/Program.cs" "b/\345\217\266\347\234\237/\345\211\252\345\210\200\347\237\263\345\244\264\345\270\203/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..fd81d2b9c0acdebca13b721172b1f676018b4f5f --- /dev/null +++ "b/\345\217\266\347\234\237/\345\211\252\345\210\200\347\237\263\345\244\264\345\270\203/Program.cs" @@ -0,0 +1,202 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + enum Attack + { + 剪刀 = 1, + 石头, + 布 + } + class Program + { + static int winTime = 0; + static int loseTime = 0; + //猜拳 + static void Main(string[] args) + { + Master master = new Master(); + master.Judgment = "裁判"; + + master.JudgmentSayBegin(); + + Console.WriteLine("请选择对手角色:1、刘备2、孙权3、曹操"); + int keyNpcName = int.Parse(Console.ReadLine()); + bool flagNpcName = true; + + while (flagNpcName) + { + switch (keyNpcName) + { + case 1: + master.NpcName = "刘备"; + flagNpcName = false; + break; + case 2: + master.NpcName = "孙权"; + flagNpcName = false; + break; + case 3: + master.NpcName = "曹操"; + flagNpcName = false; + break; + default: + Console.WriteLine("输入错误"); + break; + } + } + + Console.WriteLine("请输入您的昵称"); + string playerName = Console.ReadLine(); + master.PlayerName = playerName; + Console.WriteLine(master.PlayerName); + + + + Console.WriteLine(master.PlayerName + " VS " + master.NpcName); + + bool b1 = true; + + while (b1) + { + Console.WriteLine("开始游戏吗?y/n"); + string gameBegin = Console.ReadLine(); + + + if (gameBegin == "y"||gameBegin == "n") + { + + + switch (gameBegin) + { + case "y": + Random ran = new Random(); + int npcAttack = ran.Next(1, 4); + + Console.WriteLine("请出拳:1、剪刀 2、石头 3、布"); + int playerAttack = int.Parse(Console.ReadLine()); + + switch (playerAttack) + { + case 1: + PlayerAttackIsScissor(npcAttack); + break; + case 2: + PlayerAttackIsStone(npcAttack); + break; + case 3: + PlayerAttackIsCloth(npcAttack); + break; + default: + break; + } + break; + case "n": + EndGame(winTime,loseTime); + b1 = false; + break; + default: + Console.WriteLine("输入错误"); + break; + } + } + } + } + + private static void PlayerAttackIsCloth(int npcAttack) + { + Master master = new Master(); + + switch (npcAttack) + { + case 1: + Console.WriteLine(master.PlayerName + "出了:布"); + Console.WriteLine(master.NpcName + "出了:剪刀"); + Console.WriteLine("输了"); + loseTime += 1; + break; + case 2: + Console.WriteLine(master.PlayerName + "出了:布"); + Console.WriteLine(master.NpcName + "出了:石头"); + Console.WriteLine("赢了"); + winTime += 1; + break; + case 3: + Console.WriteLine(master.PlayerName + "出了:布"); + Console.WriteLine(master.NpcName + "出了:布"); + Console.WriteLine("平局"); + break; + default: + break; + } + } + + private static void PlayerAttackIsStone(int npcAttack) + { + Master master = new Master(); + + switch (npcAttack) + { + case 1: + Console.WriteLine(master.PlayerName+"出了:石头"); + Console.WriteLine(master.NpcName+"出了:剪刀"); + Console.WriteLine("赢了"); + winTime += 1; + break; + case 2: + Console.WriteLine(master.PlayerName + "出了:石头"); + Console.WriteLine(master.NpcName + "出了:石头"); + Console.WriteLine("平局"); + break; + case 3: + Console.WriteLine(master.PlayerName + "出了:石头"); + Console.WriteLine(master.NpcName + "出了:布"); + Console.WriteLine("输了"); + loseTime += 1; + break; + default: + break; + } + } + + private static void PlayerAttackIsScissor(int npcAttack) + { + Master master = new Master(); + + switch (npcAttack) + { + case 1: + Console.WriteLine(master.PlayerName + "出了:剪刀"); + Console.WriteLine(master.NpcName + "出了:剪刀"); + Console.WriteLine("平局"); + break; + case 2: + Console.WriteLine(master.PlayerName + "出了:剪刀"); + Console.WriteLine(master.NpcName + "出了:石头"); + Console.WriteLine("输了"); + loseTime += 1; + break; + case 3: + Console.WriteLine(master.PlayerName + "出了:剪刀"); + Console.WriteLine(master.NpcName + "出了:布"); + Console.WriteLine("赢了"); + winTime += 1; + break; + default: + break; + } + } + + private static void EndGame(int winTime,int loseTime) + { + Console.WriteLine("宁赢了:"+winTime); + Console.WriteLine("宁输了:"+loseTime); + + Console.WriteLine("程序已退出"); + } + } +} diff --git "a/\345\217\266\347\234\237/\347\273\223\346\236\204\344\275\223/PersonClass.cs" "b/\345\217\266\347\234\237/\347\273\223\346\236\204\344\275\223/PersonClass.cs" new file mode 100644 index 0000000000000000000000000000000000000000..afd7d61c2bc25d1b45d2f511ff17bed80bbb2f42 --- /dev/null +++ "b/\345\217\266\347\234\237/\347\273\223\346\236\204\344\275\223/PersonClass.cs" @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class PersonClass + { + public string className; + public int classTel; + public string classSite; + + public string ClassName + { + get { return this.className; } + set { this.className = value; } + } + public int ClassTel + { + get { return this.classTel; } + set { this.classTel = value; } + } + public string ClassSite + { + get { return this.classSite; } + set { this.classSite = value; } + } + + public PersonClass() + { + + } + + public PersonClass(string name,int tel,string site) + { + this.className = name; + this.classTel = tel; + this.classSite = site; + } + } +} diff --git "a/\345\217\266\347\234\237/\347\273\223\346\236\204\344\275\223/Program.cs" "b/\345\217\266\347\234\237/\347\273\223\346\236\204\344\275\223/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..806d79df1ba250365fbb71340bb775d99b3000f0 --- /dev/null +++ "b/\345\217\266\347\234\237/\347\273\223\346\236\204\344\275\223/Program.cs" @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Program + { + struct PersonStruct + { + public string name; + public int tel; + public string site; + + public PersonStruct(string name, int tel, string site) + { + this.name = name; + this.tel = tel; + this.site = site; + } + } +// 定义一个结构体,名为PersonStruct,有三个成员变量:姓名、电话、地址, +//在主方法中,创建一个PersonStruct结构体对象p1,为p1的成员变量赋值。 +//再声明一个PersonStruct结构体变量p2,把p1赋值给p2,改变p2的姓名,打印p1的内容。 + +//定义一个类,名为PersonClass,有三个成员变量:姓名、电话、地址, +//在主方法中,创建一个PersonClass对象p3,为p3的成员变量赋值。 +//再声明一个PersonClass变量p4,把p3赋值给p4,改变p4的姓名,打印p3的内容。 + static void Main(string[] args) + { + PersonStruct p1 = new PersonStruct("张三",123456789,"北京"); + + PersonStruct p2 = new PersonStruct(); + + p2 = p1; + p2.name = "王五"; + + Console.WriteLine(p1.name+p1.tel+p1.site); + + Console.WriteLine("------------------"); + + PersonClass p3 = new PersonClass("李四",21456879,"北京"); + PersonClass p4 = new PersonClass(); + + p4 = p3; + p4.className = "赵六"; + + Console.WriteLine(p3.className+p3.classTel+p3.classSite); + } + } +} diff --git "a/\345\217\266\351\231\210\350\276\211/.keep" "b/\345\217\266\351\231\210\350\276\211/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\345\217\266\351\231\210\350\276\211/Program.cs" "b/\345\217\266\351\231\210\350\276\211/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..a641985f7edb24b9e72d1dd5191cc1c8f3d00985 --- /dev/null +++ "b/\345\217\266\351\231\210\350\276\211/Program.cs" @@ -0,0 +1,136 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Program + { + enum enrole + { + 刘备 = 1, + 孙权 = 2, + 曹操 = 3 + } + enum enMora + { + 石头 = 1, + 剪刀 = 2, + 布 = 3 + } + static void Main(string[] args) + { + Console.WriteLine("-----------欢迎进入游戏世界-----------" + "\n"); + Console.WriteLine("************************"); + Console.WriteLine("********猜拳开始********"); + Console.WriteLine("************************"); + Console.WriteLine("出拳规则:1.剪刀2.石头3.布"); + Console.WriteLine("请选择对方的角色(1:刘备2.孙权3.曹操)"); + int numname = int.Parse(Console.ReadLine()); + string npcstr = Enum.GetName(typeof(enrole), numname); //NPC姓名 npcstr + + Role role = new Role(npcstr); //获取名字后传入类重写 + Console.WriteLine("请输入您的姓名"); // 玩家姓名 playname + string playname = Console.ReadLine(); + + Console.WriteLine(playname + " VS " + npcstr); + + Console.WriteLine("是否开始游戏(y/n)"); + char char1 = Convert.ToChar(Console.ReadLine()); + if (char1 == 'y' || char1 == 'Y') + { + WinMora(role, npcstr, playname); + } + else if(char1 == 'n' || char1 == 'N') + { + Console.WriteLine("退出游戏"); + } + Console.WriteLine("要开始下一局游戏吗?(y/n)"); + char char3 = Convert.ToChar(Console.ReadLine()); + if (char3 == 'y' || char3 == 'Y') + { + WinMora(role, npcstr, playname); + } + else if (char3 == 'n' || char3 == 'N') + { + Console.WriteLine("退出程序"); + System.Environment.Exit(0); + } + } + + private static void WinMora(Role role, string npcstr, string playname) + { + int draw = 0; + int NPCwin = 0; + int Playwin = 0; + + while (true) + { + Console.WriteLine("请出拳1.石头2.剪刀3.布请输入数字(请输入相应的数字)"); + int Moranum = int.Parse(Console.ReadLine()); + string playMora = Enum.GetName(typeof(enMora), Moranum); //获取用户输入的数字转化为相应的枚举里的值 + + Console.WriteLine(playname + " : 出拳: " + playMora); + role.Write(); + + if (role.StrMora == playMora) + { + Console.WriteLine("平局,下次再会"); + draw = draw + 1; + } + else if (playMora == "石头" && role.StrMora == "剪刀" || playMora == "布" && role.StrMora == "石头" || playMora == "剪刀" && role.StrMora == "布") + { + Console.WriteLine("恭喜您,胜利"); + Playwin = Playwin + 1; + } + else if (role.StrMora == "剪刀" && playMora == "布" || role.StrMora == "石头" && playMora == "剪刀" || role.StrMora == "布" && playMora == "石头") + { + Console.WriteLine("这也会输"); + NPCwin = NPCwin + 1; + } + else if (playMora != "石头" || playMora != "剪刀" || playMora != "布") + { + NPCwin = NPCwin + 1; + Console.WriteLine("出拳不符合规则"); + } + + Console.WriteLine("是否开始下一局(y/n)"); + char char2 = Convert.ToChar(Console.ReadLine()); + if (char2 == 'y' || char2 == 'Y') + { + } + else if(char2 == 'n' || char2 == 'N') + { + Console.WriteLine("结束游戏"); + Console.WriteLine("==========================="); + Console.WriteLine(playname + " VS " + npcstr); + Console.WriteLine("对战次数" + (Playwin + NPCwin + draw)); + Console.WriteLine("姓名 得分"); + Console.WriteLine($"{playname} {Playwin}"); + Console.WriteLine($"{npcstr} {NPCwin}"); + if (Playwin > NPCwin) + { + Console.WriteLine( "玩家 "+playname+" 胜出,恭喜恭喜"); + } + else if (NPCwin > Playwin) + { + Console.WriteLine( "电脑"+ npcstr+"胜出,不错呦"); + } + else + { + Console.WriteLine("平局"); + } + break; + } + + + } + } + } + + +} + + diff --git "a/\345\217\266\351\231\210\350\276\211/Role.cs" "b/\345\217\266\351\231\210\350\276\211/Role.cs" new file mode 100644 index 0000000000000000000000000000000000000000..bf944ac83d33490d0a723ebe18b67fd808f599aa --- /dev/null +++ "b/\345\217\266\351\231\210\350\276\211/Role.cs" @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Role + { + private string name; + private string strmora; + public string Name { get; set; } + public string StrMora + { + get { return this.strmora; } + set { this.strmora=value; } + } + + public Role(string name) + { + this.Name = name; + } + public void Test(string strmora) + { + Random random = new Random(); + + if (random.Next(1, 4) == 1) + { + strmora = "石头"; + } + else if (random.Next(1, 4) == 2) + { + strmora = "布"; + } + else if (random.Next(1, 4) == 3) + { + strmora = "剪刀"; + } + + this.StrMora = strmora; + } + public void Write() + { + Test(strmora); + StrMora = strmora; + Console.WriteLine("{0}: 出拳 :{1}",Name, StrMora); + } + + } +} diff --git "a/\345\217\266\351\242\200/\347\214\234\346\213\263/Program.cs" "b/\345\217\266\351\242\200/\347\214\234\346\213\263/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..e12dd86ada557e71ab78bbb0e24f2a579bc67ea9 --- /dev/null +++ "b/\345\217\266\351\242\200/\347\214\234\346\213\263/Program.cs" @@ -0,0 +1,125 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Program + { + private static string y; + private static string n; + + static void Main(string[] args) + { + Console.WriteLine("-------------欢迎进入游戏世界-------------"); + + Console.WriteLine("****************************"); + Console.WriteLine("**********猜拳,开始*********"); + Console.WriteLine("****************************"); + + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.步"); + Console.WriteLine("请选择对方角色:1.刘备 2.孙权 3.曹操"); + int a = int.Parse(Console.ReadLine()); + + if (a == 1) + { + Console.WriteLine("请输入您的姓名:"); + string x = Console.ReadLine(); + Console.WriteLine(x + "vs 刘备 对战"); + Console.WriteLine("开始游戏吗?(y/u)"); + string q = Console.ReadLine(); + + if (q == y) + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布 (输入相应数字:)"); + int j = int.Parse(Console.ReadLine()); + if (j == 1) + { + Console.WriteLine(x + ":出拳:剪刀"); + Console.WriteLine("刘备:出拳:石头"); + Console.WriteLine("笨蛋," + x + "输了"); + Console.WriteLine("是否开始下一轮?(y/n)"); + string q1 = Console.ReadLine(); + if (q1 == y) + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布 (输入相应数字:)"); + int j1 = int.Parse(Console.ReadLine()); + if (j1 == 2) + { + Console.WriteLine(x + ":出拳:石头"); + Console.WriteLine("刘备:出拳:石头"); + Console.WriteLine("和局"); + Console.WriteLine("是否开始下一轮?(y/n)"); + string q2 = Console.ReadLine(); + if (q2 == y) + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布 (输入相应数字:)"); + int j2 = int.Parse(Console.ReadLine()); + if (j2 == 3) + { + Console.WriteLine(x + ":出拳:布"); + Console.WriteLine("刘备:出拳:剪刀"); + Console.WriteLine("输了"); + Console.WriteLine("是否开始下一轮?(y/n)"); + string q3 = Console.ReadLine(); + if (q3 == y) + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布 (输入相应数字:)"); + int j3 = int.Parse(Console.ReadLine()); + if (j3 == 3) + { + Console.WriteLine(x + ":出拳:石头"); + Console.WriteLine("刘备:出拳:剪刀"); + Console.WriteLine("赢了"); + Console.WriteLine("是否开始下一轮?(y/n)"); + string q4 = Console.ReadLine(); + Console.WriteLine("==========================="); + Console.WriteLine("刘备 vs" + x); + Console.WriteLine("对战次数:4"); + Console.WriteLine(); + Console.WriteLine("姓名/t" + "得分"); + Console.WriteLine(x + "1"); + Console.WriteLine("刘备/t 2"); + Console.WriteLine("刘备赢了"); + + + } + } + + } + } + else + { + System.Environment.Exit(0); + } + + + } + } + else + { + System.Environment.Exit(0); + } + } + else if (q == n) + { + System.Environment.Exit(0); + + } + else + { + Console.WriteLine("您输入有误!"); + } + + + + + + + } + } + } + } +} diff --git "a/\345\217\266\351\242\200/\347\273\223\346\236\204\344\275\223/PersonClass.cs" "b/\345\217\266\351\242\200/\347\273\223\346\236\204\344\275\223/PersonClass.cs" new file mode 100644 index 0000000000000000000000000000000000000000..cde515de56369d7587986fed87247407772cbc8c --- /dev/null +++ "b/\345\217\266\351\242\200/\347\273\223\346\236\204\344\275\223/PersonClass.cs" @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class PersonClass + { + private string name; + private string dianhua; + private int dizhi; + + + + public string Name { get => name; set => name = value; } + public string Dianhua { get => dianhua; set => dianhua = value; } + public int Dizhi { get => dizhi; set => dizhi = value; } + + } +} diff --git "a/\345\217\266\351\242\200/\347\273\223\346\236\204\344\275\223/Program.cs" "b/\345\217\266\351\242\200/\347\273\223\346\236\204\344\275\223/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..713716010b45868bb9e24082efcf49d64c0622b7 --- /dev/null +++ "b/\345\217\266\351\242\200/\347\273\223\346\236\204\344\275\223/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 + { + public struct PersonStruct { + public string name; + public string dianhua; + public int dizhi; + + + + } + static void Main(string[] args) + { + + PersonStruct p1 = new PersonStruct(); + p1.name = "呵呵"; + PersonStruct p2= new PersonStruct(); + p2.name = p1.name; + p2.name = "傻傻"; + PersonClass p3 = new PersonClass(); + p3.Name = "思思"; + PersonClass p4 = new PersonClass(); + p4.Name = p3.Name; + p4.Name = "所谓的哈"; + Console.WriteLine(p1.name); + Console.WriteLine(p2.name); + Console.WriteLine(p3.Name); + Console.WriteLine(p4.Name); + Console.ReadKey(); + + } + } +} diff --git "a/\345\220\264\344\276\235\346\266\265/\347\237\263\345\244\264\345\211\252\345\210\200\345\270\203/CaiPan.cs" "b/\345\220\264\344\276\235\346\266\265/\347\237\263\345\244\264\345\211\252\345\210\200\345\270\203/CaiPan.cs" new file mode 100644 index 0000000000000000000000000000000000000000..288c6df92f671f74561ad7ad8a308efb95e94ea9 --- /dev/null +++ "b/\345\220\264\344\276\235\346\266\265/\347\237\263\345\244\264\345\211\252\345\210\200\345\270\203/CaiPan.cs" @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp11 +{ + class CaiPan : Father + { + public void kaishi1() + { + Console.WriteLine("开始游戏吗?"); + string start = Console.ReadLine(); + while (true) + { + if (start == "y") + { + Father quan = new Father("石头", "剪刀", "布"); + quan.chuquan(); + quan.change1(); + } + else if (start == "n") + { + quxiao(); + } + else + { + youwu(); + } + } + } + + public void kaishi2() + { + Console.WriteLine("开始游戏吗?"); + string start = Console.ReadLine(); + while (true) + { + if (start == "y") + { + Father quan = new Father("石头", "剪刀", "布"); + quan.chuquan(); + quan.change2(); + } + else if (start == "n") + { + quxiao(); + } + else + { + youwu(); + } + } + } + + public void kaishi3() + { + Console.WriteLine("开始游戏吗?"); + string start = Console.ReadLine(); + while (true) + { + if (start == "y") + { + Father quan = new Father("石头", "剪刀", "布"); + quan.chuquan(); + quan.change3(); + } + else if (start == "n") + { + quxiao(); + } + else + { + youwu(); + } + } + } + public void quxiao() + { + Console.WriteLine("你取消了游戏!"); + Environment.Exit(0); + } + + public void youwu() + { + Console.WriteLine("你的输入有误!"); + Environment.Exit(0); + } + + } +} diff --git "a/\345\220\264\344\276\235\346\266\265/\347\237\263\345\244\264\345\211\252\345\210\200\345\270\203/Father.cs" "b/\345\220\264\344\276\235\346\266\265/\347\237\263\345\244\264\345\211\252\345\210\200\345\270\203/Father.cs" new file mode 100644 index 0000000000000000000000000000000000000000..d35ff5f2c66bedb7402381c9678d4070bce5b52c --- /dev/null +++ "b/\345\220\264\344\276\235\346\266\265/\347\237\263\345\244\264\345\211\252\345\210\200\345\270\203/Father.cs" @@ -0,0 +1,348 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp11 +{ + class Father + { + int sum = 0; + int shengli = 0; + int shu = 0; + int he = 0; + + private string shitou; + private string jiandao; + private string bu; + private string name; + + + public string Shitou { get => shitou; set => shitou = value; } + public string Jiandao { get => jiandao; set => jiandao = value; } + public string Bu { get => bu; set => bu = value; } + public string Name { get => name; set => name = value; } + + public Father() { } + + public Father(string shitou, string jiandao, string bu) + { + this.Shitou = shitou; + this.Jiandao = jiandao; + this.Bu = bu; + } + public void Name1() + { + Console.WriteLine("请输入你的姓名:"); + this.Name = Console.ReadLine(); + Console.WriteLine(); + } + public void chuquan() + { + Console.WriteLine("请出拳:1.{0} 2.{1} 3.{2} (请输入相应数字:)", this.Shitou, this.Jiandao, this.Bu); + } + + public void lun1() + { + Console.WriteLine("是否开启下一轮?"); + sum++; + string lun = Console.ReadLine(); + if (lun == "y") + { + Father quan = new Father("石头", "剪刀", "布"); + quan.chuquan(); + quan.change1(); + } + else if (lun == "n") + { + Console.WriteLine(); + Console.WriteLine("你取消了下一轮!"); + Console.WriteLine("==============================="); + jishu(); + } + } + + public void change1() + { + int quan2 = int.Parse(Console.ReadLine()); + Random ran = new Random(); + int suiji = ran.Next(1, 4); + + if (quan2 == 1 & suiji == 2) + { + Father father = new Father(); + Console.WriteLine("你,出拳:石头"); + Console.WriteLine("刘备,出拳:剪刀"); + Console.WriteLine("恭喜,你赢了!"); + lun1(); + shengli++; + } + else if (quan2 == 1 & suiji == 3) + { + Father father = new Father(); + Console.WriteLine("你,出拳:石头"); + Console.WriteLine("刘备,出拳:布"); + Console.WriteLine("笨蛋,你输了!"); + lun1(); + shu++; + } + else if (quan2 == 2 & suiji == 1) + { + Father father = new Father(); + Console.WriteLine("你,出拳:剪刀"); + Console.WriteLine("刘备,出拳:石头"); + Console.WriteLine("笨蛋,你输了!"); + lun1(); + shu++; + } + else if (quan2 == 2 & suiji == 3) + { + Father father = new Father(); + Console.WriteLine("你,出拳:剪刀"); + Console.WriteLine("刘备,出拳:布"); + Console.WriteLine("恭喜,你赢了!"); + lun1(); + shengli++; + } + else if (quan2 == 3 & suiji == 1) + { + Father father = new Father(); + Console.WriteLine("你,出拳:布"); + Console.WriteLine("刘备,出拳:石头"); + Console.WriteLine("恭喜,你赢了!"); + lun1(); + shengli++; + } + else if (quan2 == 3 & suiji == 2) + { + Father father = new Father(); + Console.WriteLine("你,出拳:布"); + Console.WriteLine("刘备,出拳:剪刀"); + Console.WriteLine("笨蛋,你输了!"); + lun1(); + shu++; + } + else if (quan2 == 1 & suiji == 1) + { + Console.WriteLine("你,出拳:石头"); + Console.WriteLine("刘备,出拳:石头"); + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + lun1(); + he++; + } + else if (quan2 == 2 & suiji == 2) + { + Console.WriteLine("你,出拳:剪刀"); + Console.WriteLine("刘备,出拳:剪刀"); + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + lun1(); + he++; + } + else if (quan2 == 3 & suiji == 3) + { + Console.WriteLine("你,出拳:布"); + Console.WriteLine("刘备,出拳:布"); + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + lun1(); + he++; + } + } + + public void change2() + { + int quan2 = int.Parse(Console.ReadLine()); + Random ran = new Random(); + int suiji = ran.Next(1, 4); + + if (quan2 == 1 & suiji == 2) + { + Father father = new Father(); + Console.WriteLine("你,出拳:石头"); + Console.WriteLine("孙权,出拳:剪刀"); + Console.WriteLine("恭喜,你赢了!"); + lun1(); + shengli++; + } + else if (quan2 == 1 & suiji == 3) + { + Father father = new Father(); + Console.WriteLine("你,出拳:石头"); + Console.WriteLine("孙权,出拳:布"); + Console.WriteLine("笨蛋,你输了!"); + lun1(); + shu++; + } + else if (quan2 == 2 & suiji == 1) + { + Father father = new Father(); + Console.WriteLine("你,出拳:剪刀"); + Console.WriteLine("孙权,出拳:石头"); + Console.WriteLine("笨蛋,你输了!"); + lun1(); + shu++; + } + else if (quan2 == 2 & suiji == 3) + { + Father father = new Father(); + Console.WriteLine("你,出拳:剪刀"); + Console.WriteLine("孙权,出拳:布"); + Console.WriteLine("恭喜,你赢了!"); + lun1(); + shengli++; + } + else if (quan2 == 3 & suiji == 1) + { + Father father = new Father(); + Console.WriteLine("你,出拳:布"); + Console.WriteLine("孙权,出拳:石头"); + Console.WriteLine("恭喜,你赢了!"); + lun1(); + shengli++; + } + else if (quan2 == 3 & suiji == 2) + { + Father father = new Father(); + Console.WriteLine("你,出拳:布"); + Console.WriteLine("孙权,出拳:剪刀"); + Console.WriteLine("笨蛋,你输了!"); + lun1(); + shu++; + } + else if (quan2 == 1 & suiji == 1) + { + Console.WriteLine("你,出拳:石头"); + Console.WriteLine("孙权,出拳:石头"); + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + lun1(); + he++; + } + else if (quan2 == 2 & suiji == 2) + { + Console.WriteLine("你,出拳:剪刀"); + Console.WriteLine("孙权,出拳:剪刀"); + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + lun1(); + he++; + } + else if (quan2 == 3 & suiji == 3) + { + Console.WriteLine("你,出拳:布"); + Console.WriteLine("孙权,出拳:布"); + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + lun1(); + he++; + } + } + + public void change3() + { + int quan2 = int.Parse(Console.ReadLine()); + Random ran = new Random(); + int suiji = ran.Next(1, 4); + + if (quan2 == 1 & suiji == 2) + { + Father father = new Father(); + Console.WriteLine("你,出拳:石头"); + Console.WriteLine("曹操,出拳:剪刀"); + Console.WriteLine("恭喜,你赢了!"); + lun1(); + shengli++; + } + else if (quan2 == 1 & suiji == 3) + { + Father father = new Father(); + Console.WriteLine("你,出拳:石头"); + Console.WriteLine("曹操,出拳:布"); + Console.WriteLine("笨蛋,你输了!"); + lun1(); + shu++; + } + else if (quan2 == 2 & suiji == 1) + { + Father father = new Father(); + Console.WriteLine("你,出拳:剪刀"); + Console.WriteLine("曹操,出拳:石头"); + Console.WriteLine("笨蛋,你输了!"); + lun1(); + shu++; + } + else if (quan2 == 2 & suiji == 3) + { + Father father = new Father(); + Console.WriteLine("你,出拳:剪刀"); + Console.WriteLine("曹操,出拳:布"); + Console.WriteLine("恭喜,你赢了!"); + lun1(); + shengli++; + } + else if (quan2 == 3 & suiji == 1) + { + Father father = new Father(); + Console.WriteLine("你,出拳:布"); + Console.WriteLine("曹操,出拳:石头"); + Console.WriteLine("恭喜,你赢了!"); + lun1(); + shengli++; + } + else if (quan2 == 3 & suiji == 2) + { + Father father = new Father(); + Console.WriteLine("你,出拳:布"); + Console.WriteLine("曹操,出拳:剪刀"); + Console.WriteLine("笨蛋,你输了!"); + lun1(); + shu++; + } + else if (quan2 == 1 & suiji == 1) + { + Console.WriteLine("你,出拳:石头"); + Console.WriteLine("曹操,出拳:石头"); + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + lun1(); + he++; + } + else if (quan2 == 2 & suiji == 2) + { + Console.WriteLine("你,出拳:剪刀"); + Console.WriteLine("曹操,出拳:剪刀"); + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + lun1(); + he++; + } + else if (quan2 == 3 & suiji == 3) + { + Console.WriteLine("你,出拳:布"); + Console.WriteLine("曹操,出拳:布"); + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + lun1(); + he++; + } + } + + public void jishu() + { + Console.WriteLine(""); + Console.WriteLine("对战次数{0}", sum); + Console.WriteLine("胜利次数{0}", shengli); + Console.WriteLine("失败次数{0}", shu); + Console.WriteLine("平局次数{0}", he); + Console.WriteLine(); + Console.WriteLine("要开始下一局吗?(y/n)"); + string ju = Console.ReadLine(); + if (ju == "y") + { + Program program = new Program(); + program.main2(); + } + else if (ju == "n") + { + Console.WriteLine("系统退出!"); + Environment.Exit(0); + } + } + } +} + + diff --git "a/\345\220\264\344\276\235\346\266\265/\347\237\263\345\244\264\345\211\252\345\210\200\345\270\203/Program.cs" "b/\345\220\264\344\276\235\346\266\265/\347\237\263\345\244\264\345\211\252\345\210\200\345\270\203/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..98029e4b8b91ad28be16cb44172ec46124bf9ee8 --- /dev/null +++ "b/\345\220\264\344\276\235\346\266\265/\347\237\263\345\244\264\345\211\252\345\210\200\345\270\203/Program.cs" @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp11 +{ + class Program : Father + { + static void Main(string[] args) + { + Console.WriteLine("-------欢迎进入游戏世界-------"); + Console.WriteLine(); + Console.WriteLine("******************************"); + Console.WriteLine("**********猜拳,开始**********"); + Console.WriteLine("******************************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Console.WriteLine("请选择对方的角色:<1.刘备 2.孙权 3.曹操>"); + int join = int.Parse(Console.ReadLine()); + Father father = new Father(); + father.Name1(); + switch (join) + { + case 1: + Console.WriteLine(father.Name + " " + "VS" + " " + "刘备" + " " + "对战"); + CaiPan caiPan1 = new CaiPan(); + caiPan1.kaishi1(); + break; + case 2: + Console.WriteLine(father.Name + " " + "VS" + " " + "孙权" + " " + "对战"); + CaiPan caiPan2 = new CaiPan(); + caiPan2.kaishi2(); + break; + case 3: + Console.WriteLine(father.Name + " " + "VS" + " " + "曹操" + " " + "对战"); + CaiPan caiPan3 = new CaiPan(); + caiPan3.kaishi3(); + break; + default: + Console.WriteLine("输入有误!"); + break; + } + } + public void main2() + { + Console.WriteLine("-------欢迎进入游戏世界-------"); + Console.WriteLine(); + Console.WriteLine("******************************"); + Console.WriteLine("**********猜拳,开始**********"); + Console.WriteLine("******************************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Console.WriteLine("请选择对方的角色:<1.刘备 2.孙权 3.曹操>"); + int join = int.Parse(Console.ReadLine()); + Father father = new Father(); + father.Name1(); + switch (join) + { + case 1: + Console.WriteLine(father.Name + " " + "VS" + " " + "刘备" + " " + "对战"); + CaiPan caiPan1 = new CaiPan(); + caiPan1.kaishi1(); + break; + case 2: + Console.WriteLine(father.Name + " " + "VS" + " " + "孙权" + " " + "对战"); + CaiPan caiPan2 = new CaiPan(); + caiPan2.kaishi2(); + break; + case 3: + Console.WriteLine(father.Name + " " + "VS" + " " + "曹操" + " " + "对战"); + CaiPan caiPan3 = new CaiPan(); + caiPan3.kaishi3(); + break; + default: + Console.WriteLine("输入有误!"); + break; + } + } + } +} + diff --git "a/\345\220\264\344\276\235\346\266\265/\347\273\223\346\236\204\344\275\223/Program.cs" "b/\345\220\264\344\276\235\346\266\265/\347\273\223\346\236\204\344\275\223/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..887d298f34d6e5651d3e447bc6d1d16be64fe863 --- /dev/null +++ "b/\345\220\264\344\276\235\346\266\265/\347\273\223\346\236\204\344\275\223/Program.cs" @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + struct PersonStruct + { + public string name; + public int tel; + public string add; + } + class Program + { + static void Main(string[] args) + { + //定义一个结构体,名为PersonStruct,有三个成员变量:姓名、电话、地址, + //在主方法中,创建一个PersonStruct结构体对象p1,为p1的成员变量赋值。 + //再声明一个PersonStruct结构体变量p2,把p1赋值给p2,改变p2的姓名,打印p1的内容。 + PersonStruct p1; + p1.name = "王五"; + p1.tel = 13838438; + p1.add = "龙岩市"; + + PersonStruct p2; + p2 = p1; + p2.name = "老四"; + p2.tel = 3838438; + p2.add = "三明市"; + + Console.WriteLine("p1的信息为:"+p1.name + p1.tel + p1.add); + + //定义一个类,名为PersonClass,有三个成员变量:姓名、电话、地址, + //在主方法中,创建一个PersonClass对象p3,为p3的成员变量赋值。 + //再声明一个PersonClass变量p4,把p3赋值给p4,改变p4的姓名,打印p3的内容。 + PersonStruct p3; + p3.name = "张三"; + p3.tel = 23838438; + p3.add = "莆田市"; + + PersonStruct p4; + p4 = p3; + p4.name = "哦哦"; + p4.tel = 3838438; + p4.add = "福州市"; + + Console.WriteLine("p3的信息为:" + p3.name + p3.tel + p3.add); + + } + } +} diff --git "a/\345\220\264\346\230\237/\345\211\252\345\210\200\347\237\263\345\244\264\345\270\203/Master.cs" "b/\345\220\264\346\230\237/\345\211\252\345\210\200\347\237\263\345\244\264\345\270\203/Master.cs" new file mode 100644 index 0000000000000000000000000000000000000000..620ca15952949d9be4abc4735595b4cecb6e4d5f --- /dev/null +++ "b/\345\220\264\346\230\237/\345\211\252\345\210\200\347\237\263\345\244\264\345\270\203/Master.cs" @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Master + { + private string playerName; + private string judgment; + private int npcAttack; + private string npcName; + + public string PlayerName + { + get { return this.playerName; } + set { this.playerName = value; } + } + public int NpcAttack + { + get { return this.npcAttack; } + set { this.npcAttack = value; } + } + public string NpcName + { + get { return this.npcName; } + set { this.npcName = value; } + } + public string Judgment + { + get { return this.judgment; } + set { this.judgment = value; } + } + public void JudgmentSayBegin() + { + Console.WriteLine("裁判:猜拳比赛"); + Console.WriteLine("裁判:猜拳规则:1、剪刀2、石头3、布"); + } + public Master() { } + + } +} diff --git "a/\345\220\264\346\230\237/\345\211\252\345\210\200\347\237\263\345\244\264\345\270\203/Program.cs" "b/\345\220\264\346\230\237/\345\211\252\345\210\200\347\237\263\345\244\264\345\270\203/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..02fac94abd86fc75bb0e252228fa3c78777afc82 --- /dev/null +++ "b/\345\220\264\346\230\237/\345\211\252\345\210\200\347\237\263\345\244\264\345\270\203/Program.cs" @@ -0,0 +1,202 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + enum Attack + { + 剪刀 = 1, + 石头, + 布 + } + class Program + { + static int winTime = 0; + static int loseTime = 0; + //猜拳 + static void Main(string[] args) + { + Master master = new Master(); + master.Judgment = "裁判"; + + master.JudgmentSayBegin(); + + Console.WriteLine("请选择对手角色:1、刘备2、孙权3、曹操"); + int keyNpcName = int.Parse(Console.ReadLine()); + bool flagNpcName = true; + + while (flagNpcName) + { + switch (keyNpcName) + { + case 1: + master.NpcName = "刘备"; + flagNpcName = false; + break; + case 2: + master.NpcName = "孙权"; + flagNpcName = false; + break; + case 3: + master.NpcName = "曹操"; + flagNpcName = false; + break; + default: + Console.WriteLine("输入错误"); + break; + } + } + + Console.WriteLine("请输入您的昵称"); + string playerName = Console.ReadLine(); + master.PlayerName = playerName; + Console.WriteLine(master.PlayerName); + + + + Console.WriteLine(master.PlayerName + " VS " + master.NpcName); + + bool b1 = true; + + while (b1) + { + Console.WriteLine("开始游戏吗?y/n"); + string gameBegin = Console.ReadLine(); + + + if (gameBegin == "y"||gameBegin == "n") + { + + + switch (gameBegin) + { + case "y": + Random ran = new Random(); + int npcAttack = ran.Next(1, 4); + + Console.WriteLine("请出拳:1、剪刀 2、石头 3、布"); + int playerAttack = int.Parse(Console.ReadLine()); + + switch (playerAttack) + { + case 1: + PlayerAttackIsScissor(npcAttack); + break; + case 2: + PlayerAttackIsStone(npcAttack); + break; + case 3: + PlayerAttackIsCloth(npcAttack); + break; + default: + break; + } + break; + case "n": + EndGame(winTime,loseTime); + b1 = false; + break; + default: + Console.WriteLine("输入错误"); + break; + } + } + } + } + + private static void PlayerAttackIsCloth(int npcAttack) + { + Master master = new Master(); + + switch (npcAttack) + { + case 1: + Console.WriteLine(master.PlayerName + "出了:布"); + Console.WriteLine(master.NpcName + "出了:剪刀"); + Console.WriteLine("输了"); + loseTime += 1; + break; + case 2: + Console.WriteLine(master.PlayerName + "出了:布"); + Console.WriteLine(master.NpcName + "出了:石头"); + Console.WriteLine("赢了"); + winTime += 1; + break; + case 3: + Console.WriteLine(master.PlayerName + "出了:布"); + Console.WriteLine(master.NpcName + "出了:布"); + Console.WriteLine("平局"); + break; + default: + break; + } + } + + private static void PlayerAttackIsStone(int npcAttack) + { + Master master = new Master(); + + switch (npcAttack) + { + case 1: + Console.WriteLine(master.PlayerName+"出了:石头"); + Console.WriteLine(master.NpcName+"出了:剪刀"); + Console.WriteLine("赢了"); + winTime += 1; + break; + case 2: + Console.WriteLine(master.PlayerName + "出了:石头"); + Console.WriteLine(master.NpcName + "出了:石头"); + Console.WriteLine("平局"); + break; + case 3: + Console.WriteLine(master.PlayerName + "出了:石头"); + Console.WriteLine(master.NpcName + "出了:布"); + Console.WriteLine("输了"); + loseTime += 1; + break; + default: + break; + } + } + + private static void PlayerAttackIsScissor(int npcAttack) + { + Master master = new Master(); + + switch (npcAttack) + { + case 1: + Console.WriteLine(master.PlayerName + "出了:剪刀"); + Console.WriteLine(master.NpcName + "出了:剪刀"); + Console.WriteLine("平局"); + break; + case 2: + Console.WriteLine(master.PlayerName + "出了:剪刀"); + Console.WriteLine(master.NpcName + "出了:石头"); + Console.WriteLine("输了"); + loseTime += 1; + break; + case 3: + Console.WriteLine(master.PlayerName + "出了:剪刀"); + Console.WriteLine(master.NpcName + "出了:布"); + Console.WriteLine("赢了"); + winTime += 1; + break; + default: + break; + } + } + + private static void EndGame(int winTime,int loseTime) + { + Console.WriteLine("宁赢了:"+winTime); + Console.WriteLine("宁输了:"+loseTime); + + Console.WriteLine("程序已退出"); + } + } +} diff --git "a/\345\220\264\346\230\237/\347\273\223\346\236\204\344\275\223/PersonClass.cs" "b/\345\220\264\346\230\237/\347\273\223\346\236\204\344\275\223/PersonClass.cs" new file mode 100644 index 0000000000000000000000000000000000000000..1ec8a8419d8d18c1cff6e869a92752c68d3ccbd0 --- /dev/null +++ "b/\345\220\264\346\230\237/\347\273\223\346\236\204\344\275\223/PersonClass.cs" @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class PersonClass + { + public string className; + public int classTel; + public string classSite; + + public string ClassName + { + get { return this.className; } + set { this.className = value; } + } + public int ClassTel + { + get { return this.classTel; } + set { this.classTel = value; } + } + public string ClassSite + { + get { return this.classSite; } + set { this.classSite = value; } + } + + public PersonClass() + { + + } + + public PersonClass(string name,int tel,string site) + { + this.className = name; + this.classTel = tel; + this.classSite = site; + } + } +} diff --git "a/\345\220\264\346\230\237/\347\273\223\346\236\204\344\275\223/Program.cs" "b/\345\220\264\346\230\237/\347\273\223\346\236\204\344\275\223/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..67601c21bb942cfdf52e6b45f58c2a730adf4bfb --- /dev/null +++ "b/\345\220\264\346\230\237/\347\273\223\346\236\204\344\275\223/Program.cs" @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Program + { + struct PersonStruct + { + public string name; + public int tel; + public string site; + + public PersonStruct(string name, int tel, string site) + { + this.name = name; + this.tel = tel; + this.site = site; + } + } +// 定义一个结构体,名为PersonStruct,有三个成员变量:姓名、电话、地址, +//在主方法中,创建一个PersonStruct结构体对象p1,为p1的成员变量赋值。 +//再声明一个PersonStruct结构体变量p2,把p1赋值给p2,改变p2的姓名,打印p1的内容。 + +//定义一个类,名为PersonClass,有三个成员变量:姓名、电话、地址, +//在主方法中,创建一个PersonClass对象p3,为p3的成员变量赋值。 +//再声明一个PersonClass变量p4,把p3赋值给p4,改变p4的姓名,打印p3的内容。 + static void Main(string[] args) + { + PersonStruct p1 = new PersonStruct("张三",123456789,"北京"); + + PersonStruct p2 = new PersonStruct(); + + p2 = p1; + p2.name = "王五"; + + Console.WriteLine(p1.name+p1.tel+p1.site); + + Console.WriteLine("------------------"); + + PersonClass p3 = new PersonClass("李四",21456879,"北京"); + PersonClass p4 = new PersonClass(); + + p4 = p3; + p4.className = "赵六"; + + Console.WriteLine(p3.className+p3.classTel+p3.classSite); + } + } +} diff --git "a/\345\224\220\345\207\241\350\276\211/2/.keep" "b/\345\224\220\345\207\241\350\276\211/2/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\345\224\220\345\207\241\350\276\211/2/Program.cs" "b/\345\224\220\345\207\241\350\276\211/2/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..24e85456568b74680955d89f013a6c01df6ea5d4 --- /dev/null +++ "b/\345\224\220\345\207\241\350\276\211/2/Program.cs" @@ -0,0 +1,222 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Program + { + static int sum; + static int shu; + static int ying; + static int ping; + struct juese + { + public string name; + public string name1; + public string name2; + + } + struct caijuan + { + public string jiandao; + public string shitou; + public string bu; + + } + + static void Main(string[] args) + { + + Text1(); + } + public static void Text1() + { + Console.WriteLine("游戏开始"); + caijuan cq = new caijuan(); + cq.shitou = "石头"; + cq.jiandao = "剪刀"; + cq.bu = "布"; + juese js = new juese(); + js.name = "黑"; + js.name1 = "白"; + js.name2 = "空"; + + Console.WriteLine("出拳规则:{0},{1},{2}", cq.shitou, cq.jiandao, cq.bu); + Console.WriteLine("请选择对方角色:{0},{1},{2}", js.name, js.name1, js.name2); + string key = Console.ReadLine(); + Console.WriteLine("请输入你的姓名"); + string ming = Console.ReadLine(); + switch (key) + { + case "黑": + Text2(); + break; + case "白": + Text2(); + break; + case "空": + Text2(); + break; + default: + Text2(); + break; + } + + } + public static void Text6() + { + Console.WriteLine("是否开始下一轮"); + int a = int.Parse(Console.ReadLine()); + switch (a) + { + case 1: + Text2(); + break; + case 2: + Console.WriteLine("次数{0}", sum); + Console.WriteLine("赢次数{0}", ying); + Console.WriteLine("输次数{0}", shu); + Console.WriteLine("平次数{0}", ping); + if (ying>shu) + { + Console.WriteLine("九龙拉棺,泰山封禅"); + } + if ( shu name; set => name = value; } + public string Dianhua { get => dianhua; set => dianhua = value; } + public int Dizhi { get => dizhi; set => dizhi = value; } + + } +} diff --git "a/\345\224\220\345\207\241\350\276\211/\347\273\223\346\236\204\344\275\223/Program.cs" "b/\345\224\220\345\207\241\350\276\211/\347\273\223\346\236\204\344\275\223/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..713716010b45868bb9e24082efcf49d64c0622b7 --- /dev/null +++ "b/\345\224\220\345\207\241\350\276\211/\347\273\223\346\236\204\344\275\223/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 + { + public struct PersonStruct { + public string name; + public string dianhua; + public int dizhi; + + + + } + static void Main(string[] args) + { + + PersonStruct p1 = new PersonStruct(); + p1.name = "呵呵"; + PersonStruct p2= new PersonStruct(); + p2.name = p1.name; + p2.name = "傻傻"; + PersonClass p3 = new PersonClass(); + p3.Name = "思思"; + PersonClass p4 = new PersonClass(); + p4.Name = p3.Name; + p4.Name = "所谓的哈"; + Console.WriteLine(p1.name); + Console.WriteLine(p2.name); + Console.WriteLine(p3.Name); + Console.WriteLine(p4.Name); + Console.ReadKey(); + + } + } +} diff --git "a/\345\225\206\350\265\242\346\227\255/Program.cs" "b/\345\225\206\350\265\242\346\227\255/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..8d568abac75481d2807afabeb1fa61655c4dbe15 --- /dev/null +++ "b/\345\225\206\350\265\242\346\227\255/Program.cs" @@ -0,0 +1,144 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Program + { + + enum enrole + { + 刘备 = 1, + 孙权 = 2, + 曹操 = 3 + } + enum enMora + { + 石头 = 1, + 剪刀 = 2, + 布 = 3 + } + static void Main(string[] args) + { + //人物类 出的选型类 + + Console.WriteLine("-----------欢迎进入游戏世界-----------" + "\n"); + Console.WriteLine("************************"); + Console.WriteLine("********猜拳开始********"); + Console.WriteLine("************************"); + Console.WriteLine("出拳规则:1.剪刀2.石头3.布"); + Console.WriteLine("请选择对方的角色(1:刘备2.孙权3.曹操)"); + int numname = int.Parse(Console.ReadLine()); + string npcstr = Enum.GetName(typeof(enrole), numname); //NPC姓名 npcstr + + Role role = new Role(npcstr); //获取名字后传入类重写 + Console.WriteLine("请输入您的姓名"); // 玩家姓名 playname + string playname = Console.ReadLine(); + + Console.WriteLine(playname + " VS " + npcstr); + + Console.WriteLine("是否开始游戏(y/n)"); + char char1 = Convert.ToChar(Console.ReadLine()); + if (char1 == 'y' || char1 == 'Y') + { + WinMora(role, npcstr, playname); + + } + else if(char1 == 'n' || char1 == 'N') + { + Console.WriteLine("退出游戏"); + } + Console.WriteLine("要开始下一局游戏吗?(y/n)"); + char char3 = Convert.ToChar(Console.ReadLine()); + if (char3 == 'y' || char3 == 'Y') + { + WinMora(role, npcstr, playname); + + } + else if (char3 == 'n' || char3 == 'N') + { + Console.WriteLine("退出程序"); + System.Environment.Exit(0); + } + } + + private static void WinMora(Role role, string npcstr, string playname) + { + + + int draw = 0; + int NPCwin = 0; + int Playwin = 0; + + while (true) + { + Console.WriteLine("请出拳1.石头2.剪刀3.布请输入数字(请输入相应的数字)"); + int Moranum = int.Parse(Console.ReadLine()); + string playMora = Enum.GetName(typeof(enMora), Moranum); //获取用户输入的数字转化为相应的枚举里的值 + + Console.WriteLine(playname + " : 出拳: " + playMora); + role.Write(); + + if (role.StrMora == playMora) + { + Console.WriteLine("平局,放你一马"); + draw = draw + 1; + } + else if (playMora == "石头" && role.StrMora == "剪刀" || playMora == "布" && role.StrMora == "石头" || playMora == "剪刀" && role.StrMora == "布") + { + Console.WriteLine("恭喜您,勇夺三军,天下无双"); + Playwin = Playwin + 1; + } + else if (role.StrMora == "剪刀" && playMora == "布" || role.StrMora == "石头" && playMora == "剪刀" || role.StrMora == "布" && playMora == "石头") + { + Console.WriteLine("天啦噜,难以置信,这也会输"); + NPCwin = NPCwin + 1; + } + else if (playMora != "石头" || playMora != "剪刀" || playMora != "布") + { + NPCwin = NPCwin + 1; + Console.WriteLine("玩家,出拳不符合规则默认判负"); + } + + Console.WriteLine("是否开始下一局(y/n)"); + char char2 = Convert.ToChar(Console.ReadLine()); + if (char2 == 'y' || char2 == 'Y') + { + + } + else if(char2 == 'n' || char2 == 'N') + { + Console.WriteLine("结束游戏"); + Console.WriteLine("==========================="); + Console.WriteLine(playname + " VS " + npcstr); + Console.WriteLine("对战次数" + (Playwin + NPCwin + draw)); + Console.WriteLine("姓名 得分"); + Console.WriteLine($"{playname} {Playwin}"); + Console.WriteLine($"{npcstr} {NPCwin}"); + if (Playwin > NPCwin) + { + Console.WriteLine( "玩家 "+playname+" 胜出,举世同庆"); + } + else if (NPCwin > Playwin) + { + Console.WriteLine( "电脑"+ npcstr+"胜出,棋差一手"); + } + else + { + Console.WriteLine("平局"); + } + break; + } + + + } + } + } + + +} + + diff --git "a/\345\225\206\350\265\242\346\227\255/Role.cs" "b/\345\225\206\350\265\242\346\227\255/Role.cs" new file mode 100644 index 0000000000000000000000000000000000000000..2970a348aa51a9de886523e6d5e30f4896d4161f --- /dev/null +++ "b/\345\225\206\350\265\242\346\227\255/Role.cs" @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Role + { + private string name; + private string strmora; + public string Name { get; set; } + public string StrMora + { + get { return this.strmora; } + set { this.strmora=value; } + + } + + public Role(string name) + { + this.Name = name; + } + public void Test(string strmora) + { + + Random random = new Random(); + + + if (random.Next(1, 4) == 1) + { + strmora = "石头"; + } + else if (random.Next(1, 4) == 2) + { + strmora = "布"; + } + else if (random.Next(1, 4) == 3) + { + strmora = "剪刀"; + } + + this.StrMora = strmora; + + + } + public void Write() + { + Test(strmora); + StrMora = strmora; + Console.WriteLine("{0}: 出拳 :{1}",Name, StrMora); + + + } + + } +} diff --git "a/\345\274\240\345\256\217/Program.cs" "b/\345\274\240\345\256\217/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b232cf7d2466a2a9d465f769d682c3bd750c64f7 --- /dev/null +++ "b/\345\274\240\345\256\217/Program.cs" @@ -0,0 +1,51 @@ +using System; + +namespace Demo1 +{ + class Program + { + public struct PersonStruct + { + public string name; + public string plone; + public string home; + + public PersonStruct(string name, string plone, string home) + { + this.name = name; + this.plone = plone; + this.home = home; + } + } + + + static void Main(string[] args) + { + //定义一个结构体,名为PersonStruct,有三个成员变量:姓名、电话、地址, + //在主方法中,创建一个PersonStruct结构体对象p1,为p1的成员变量赋值。 + //再声明一个PersonStruct结构体变量p2,把p1赋值给p2,改变p2的姓名,打印p1的内容。 + + + + PersonStruct p1; + p1.name = "邓夏晖"; + p1.plone = "18379777344"; + p1.home = "上犹县"; + + PersonStruct p2; + p2.name = "张宏"; + p2.plone = "18460360774"; + p2.home = "南康区"; + + + p2.name ="张伟"; + p2.plone = p1.plone; + p2.home = p1.home; + + Console.WriteLine(p2.name); + Console.WriteLine(p2.plone); + Console.WriteLine(p2.home); + + } + } +} diff --git "a/\345\274\240\345\256\217/Program1.cs" "b/\345\274\240\345\256\217/Program1.cs" new file mode 100644 index 0000000000000000000000000000000000000000..c5c2e4a11de327f18be4e2670afce15bcfe37bd6 --- /dev/null +++ "b/\345\274\240\345\256\217/Program1.cs" @@ -0,0 +1,243 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo9 +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine( ); + Console.WriteLine("---------------------------------------欢迎进入游戏世界--------------------------------"); + Console.WriteLine(); + Console.WriteLine("***************************************************************************************"); + Console.WriteLine("*************************************猜拳,开始****************************************"); + Console.WriteLine("***************************************************************************************"); + Console.WriteLine(); + + Console.WriteLine("出拳规则: 1,剪刀 2,石头 3,布"); + Console.WriteLine(); + + Text(); + + Console.WriteLine(); + Console.WriteLine("要继续吗? (Y / N)"); + char num5 = char.Parse(Console.ReadLine()); + if (num5 == 'Y') + { + Text(); + } + else + { + Console.WriteLine("游戏已退出!!!!!"); + } + + } + static void Text() + { + + Console.WriteLine("请选择对方的角色:<1:刘备 2:孙权 3:曹操>"); + int num = int.Parse(Console.ReadLine()); + Console.WriteLine("请输入您的姓名:"); + string name = Console.ReadLine(); + Console.WriteLine(); + + if (num == 1) + { + Console.WriteLine(name + " VS " + " 刘备 对战!"); + } + else if (num == 2) + { + Console.WriteLine(name + " VS " + " 孙权 对战!"); + } + else + { + Console.WriteLine(name + " VS " + " 曹操 对战!"); + } + + Console.WriteLine("已选择好角色,确定开始游戏吗?(Y / N)"); + char num1 = char.Parse(Console.ReadLine()); + Console.WriteLine(); + + if (num1 == 'Y') + { + for (int i = 0; i < 3; i++) + { + Console.WriteLine(); + Console.WriteLine("请出拳: 1,剪刀 2,石头 3,布 (请输入相应数字!)"); + int num2 = int.Parse(Console.ReadLine()); + Console.WriteLine(); + + int num3 = 0; + int num4 = 0; + + if (num == 1) + { + if (num2 == 1 ) + { + Console.WriteLine(name + " 出拳:" + "剪刀"); + Console.WriteLine("刘备" + "出拳:" + "石头"); + Console.WriteLine("笨蛋," + name + "输了!"); + num4++; + } + else if(num2 == 2) + { + Console.WriteLine(name + " 出拳:" + "石头"); + Console.WriteLine("刘备"+ "出拳:" + "石头"); + Console.WriteLine("平局"); + + } + else + { + Console.WriteLine(name + " 出拳:" + "布"); + Console.WriteLine("刘备" + "出拳:" + "石头"); + Console.WriteLine("哈哈哈,你赢了"); + num3++; + } + + + } + else if (num == 2) + { + if (num2 == 1) + { + Console.WriteLine(name + " 出拳:" + "剪刀"); + Console.WriteLine("孙权" + "出拳:" + "石头"); + Console.WriteLine("真衰,嘿嘿,等着瞧!"); + num4++; + } + if (num2 == 2) + { + Console.WriteLine(name + " 出拳:" + "石头"); + Console.WriteLine("孙权" + "出拳:" + "石头"); + Console.WriteLine("平局"); + } + else + { + Console.WriteLine(name + " 出拳:" + "布"); + Console.WriteLine("孙权" + "出拳:" + "石头"); + Console.WriteLine("哈哈哈,你赢了"); + num3++; + } + + + } + else + { + if (num2 == 1) + { + Console.WriteLine(name + " 出拳:" + "剪刀"); + Console.WriteLine("曹操" + "出拳:" + "石头"); + Console.WriteLine("哈哈哈,真衰,你输了"); + num4++; + } + if (num2 == 2) + { + Console.WriteLine(name + " 出拳:" + "石头"); + Console.WriteLine("曹操" + "出拳:" + "石头"); + Console.WriteLine("平局"); + + } + else + { + Console.WriteLine(name + " 出拳:" + "布"); + Console.WriteLine("曹操" + "出拳:" + "石头"); + Console.WriteLine("哈哈哈,你赢了!"); + num3++; + } + + } + if (i == 2) + { + if (num == 1) + { + Console.WriteLine(); + Console.WriteLine("******************************"); + Console.WriteLine(); + Console.WriteLine(name + "VS" + "刘备"); + Console.WriteLine("对战次数:3"); + Console.WriteLine(); + Console.WriteLine("姓名 得分"); + Console.WriteLine("刘备"+ " " + num4); + Console.WriteLine(name + " " + num3); + if (num3 > num4) + { + Console.WriteLine("恭喜" + name + "赢了!"); + } + else if(num3 < num4) + { + Console.WriteLine("恭喜" + "刘备"+ "赢了!"); + } + else + { + Console.WriteLine("哈哈哈,没想到吧,平局,嘿嘿!"); + } + + } + else if(num == 2) + { + Console.WriteLine(); + Console.WriteLine("******************************"); + Console.WriteLine(); + Console.WriteLine(name + "VS" + "孙权"); + Console.WriteLine("对战次数:3"); + Console.WriteLine(); + Console.WriteLine("姓名 得分"); + Console.WriteLine("孙权" + " " + num4); + Console.WriteLine(name+ " " + num3); + if (num3 > num4) + { + Console.WriteLine("恭喜" + name + "赢了!"); + } + else if(num3 < num4) + { + Console.WriteLine("恭喜" + "孙权" + "赢了!"); + } + else + { + Console.WriteLine("哈哈哈,没有想到吧,平局,嘿嘿."); + } + + } + else + { + Console.WriteLine(); + Console.WriteLine("******************************"); + Console.WriteLine(); + Console.WriteLine(name + "VS" + "曹操"); + Console.WriteLine("对战次数:3"); + Console.WriteLine(); + Console.WriteLine("姓名 得分"); + Console.WriteLine("曹操"+ " " + num4); + Console.WriteLine(name + " " + num3); + if (num3 > num4) + { + Console.WriteLine("恭喜" + name + "赢了!"); + } + else if (num3 < num4) + { + Console.WriteLine("恭喜" + "曹操" + "赢了!"); + } + else + { + Console.WriteLine("哈哈哈,没有想到吧,平局,嘿嘿."); + } + + + } + + } + } + + } + else + { + Console.WriteLine("系统退出!!!"); + } + + } + } +} diff --git "a/\345\274\240\351\221\253/Program.cs" "b/\345\274\240\351\221\253/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b05cdeee53cb3a6ee10726337167ca6b3882b5da --- /dev/null +++ "b/\345\274\240\351\221\253/Program.cs" @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Program + { + enum enrole + { + 刘 = 1, + 孙 = 2, + 曹 = 3 + } + enum enmora + { + 石头 = 1, + 剪刀 = 2, + 布 = 3 + } + static void Main(string[] args) + { + Console.WriteLine("********************"); + Console.WriteLine("*****猜拳,开始*****"); + Console.WriteLine("********************"); + Console.WriteLine("出拳:1.剪刀 2.石头 3.布"); + Console.WriteLine("请选择你的对手《1.刘备 2.孙权 3.曹操》"); + int numname = int.Parse(Console.ReadLine()); + String npc = Enum.GetName(typeof(enrole), numname); + character ch = new character(npc); + Console.WriteLine("请输入你的名字"); + string playn = Console.ReadLine(); + Console.WriteLine(playn + "VS" + npc); + Console.WriteLine("开始游戏(y/n)"); + char char1 = Convert.ToChar(Console.ReadLine()); + if (char1 == 'y' || char1 == 'Y') + { + WinMora(ch, npc, playn); + } + else if(char1 == 'n' || char1 == 'N') + { + Console.WriteLine("退出程序"); + System.Environment.Exit(0); + } + } + private static void WinMora(character role, string npc, string playn) + { + int draw = 0; + int NPCwin = 0; + int Playwin = 0; + + while (true) + { + Console.WriteLine("请出拳1.石头2.剪刀3.布 ---请输入相应的数字"); + int Moranum = int.Parse(Console.ReadLine()); + string playMore = Enum.GetName(typeof(enmora), Moranum); + Console.WriteLine(playn + "出拳" + playMora); + role.Write(); + + if (role.StrMora == playMora) + { + Console.WriteLine("平局"); + draw = draw + 1; + } + else if (playMora == "石头" && role.StrMora == "剪刀" || playMora == "布" && role.StrMora == "石头" || playMora == "剪刀" && role.StrMora == "布") + { + Console.WriteLine("恭喜您,你赢了"); + Playwin = Playwin + 1; + } + else if (role.StrMora == "剪刀" && playMora == "布" || role.StrMora == "石头" && playMora == "剪刀" || role.StrMora == "布" && playMora == "石头") + { + Console.WriteLine("你输了"); + NPCwin = NPCwin + 1; + } + else if (playMora != "石头" || playMora != "剪刀" || playMora != "布") + { + NPCwin = NPCwin + 1; + Console.WriteLine("玩家,出拳不符合规则默认判负"); + } + + Console.WriteLine("是否开始下一局(y/n)"); + char char2 = Convert.ToChar(Console.ReadLine()); + if (char2 == 'y' || char2 == 'Y') + { + + } + else if (char2 == 'n' || char2 == 'N') + { + Console.WriteLine("结束游戏"); + Console.WriteLine("==========================="); + Console.WriteLine(playn + " VS " + npc); + Console.WriteLine("对战次数" + (Playwin + NPCwin + draw)); + Console.WriteLine("姓名 得分"); + Console.WriteLine($"{playn} {Playwin}"); + Console.WriteLine($"{npc} {NPCwin}"); + if (Playwin > NPCwin) + { + Console.WriteLine("玩家 " + playn + " 胜出,举世同庆"); + } + else if (NPCwin > Playwin) + { + Console.WriteLine("电脑" + npc + "胜出,棋差一手"); + } + else + { + Console.WriteLine("平局"); + } + break; + } + } + } + } +} diff --git "a/\345\274\240\351\221\253/character.cs" "b/\345\274\240\351\221\253/character.cs" new file mode 100644 index 0000000000000000000000000000000000000000..c3fd89cf089ce1621b82e53ae558ba04fb031d41 --- /dev/null +++ "b/\345\274\240\351\221\253/character.cs" @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class character + { + private string name; + private string strmora; + public string Name { get; set; } + public string StrMora + { + get { return this.strmora; } + set { this.strmora = value; } + + } + + public character(string name) + { + this.Name = name; + } + public void Test(string strmora) + { + + Random random = new Random(); + + + if (random.Next(1, 4) == 1) + { + strmora = "石头"; + } + else if (random.Next(1, 4) == 2) + { + strmora = "布"; + } + else if (random.Next(1, 4) == 3) + { + strmora = "剪刀"; + } + + this.StrMora = strmora; + + + } + public void Write() + { + Test(strmora); + StrMora = strmora; + Console.WriteLine("{0}: 出拳 :{1}", Name, StrMora); + + + } + } +} diff --git "a/\345\276\220\351\252\217\351\271\217/Class.cs" "b/\345\276\220\351\252\217\351\271\217/Class.cs" new file mode 100644 index 0000000000000000000000000000000000000000..e9a39b3cc84372bf23a897e6e24c020b84392e92 --- /dev/null +++ "b/\345\276\220\351\252\217\351\271\217/Class.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Text; + +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\276\220\351\252\217\351\271\217/ConsoleApp1.csproj" "b/\345\276\220\351\252\217\351\271\217/ConsoleApp1.csproj" new file mode 100644 index 0000000000000000000000000000000000000000..c73e0d1692ab38cc8596bbd32ae080d903aaa778 --- /dev/null +++ "b/\345\276\220\351\252\217\351\271\217/ConsoleApp1.csproj" @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + diff --git "a/\345\276\220\351\252\217\351\271\217/Program.cs" "b/\345\276\220\351\252\217\351\271\217/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..cde0611f4c780c991ea4aa5b342cda85a8e4f62c --- /dev/null +++ "b/\345\276\220\351\252\217\351\271\217/Program.cs" @@ -0,0 +1,194 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + public enum Nmae + { + 刘大爷 = 1, + 曹老板, + 孙十万 + } + public enum act + { + 剪刀 = 1, + 石头, + 布 + } + class Program + { + public static object Computer { get; private set; } + + static void Main(string[] args) + { + 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(Nmae 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 gamebegin(Nmae 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 result(Name name, player P, int time, int[] Play, int[] Computer) + { + Console.WriteLine("***********************"); + Character character = new Character((name)nmae); + + 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+"胜利 我要把你的头盖骨当碗使"+"|"+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); + + 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("你们平局了,是真平局了"); + } + + } + } + + + } \ No newline at end of file diff --git "a/\345\276\220\351\252\217\351\271\217/actionabl.cs" "b/\345\276\220\351\252\217\351\271\217/actionabl.cs" new file mode 100644 index 0000000000000000000000000000000000000000..d4352923c8daea4c9800f1f237d8eb7458121459 --- /dev/null +++ "b/\345\276\220\351\252\217\351\271\217/actionabl.cs" @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ConsoleApp1 +{ + class actionabl + { + } +} diff --git "a/\345\276\220\351\252\217\351\271\217/player.cs" "b/\345\276\220\351\252\217\351\271\217/player.cs" new file mode 100644 index 0000000000000000000000000000000000000000..9e7896021a1d0a3cae754f2f89f522b71fb52e31 --- /dev/null +++ "b/\345\276\220\351\252\217\351\271\217/player.cs" @@ -0,0 +1,49 @@ +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; get; } + public player(string player) + { + this.Player = player; + + } + public int fingerGuess(int p) + { + + int Result; + + + switch (p) + { + case 1: + Console.WriteLine( Player +"出剪刀"); + Result = 1; + break; + + case 2: + Console.WriteLine(Player + "出石头"); + Result = 2; + break; + + case 3: + Console.WriteLine(Player + "出布"); + Result = 3; + break; + + default: + Result = 1; + break; + + + } + return Result; + } + } +} diff --git "a/\346\226\271\350\215\243\346\230\237/\347\214\234\346\213\263/Game.cs" "b/\346\226\271\350\215\243\346\230\237/\347\214\234\346\213\263/Game.cs" new file mode 100644 index 0000000000000000000000000000000000000000..75a41929b179066e8afe8d5f11e7d5f3b332bc61 --- /dev/null +++ "b/\346\226\271\350\215\243\346\230\237/\347\214\234\346\213\263/Game.cs" @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp4 +{ + class Game + { + public enum guess + { + 石头 = 1, + 剪刀 = 2, + 布 = 3 + } + + public string name { get; set; } + public string name1 { get; set; } + + public Game(string name, string name1) + { + this.name = name; + this.name1 = name1; + } + + public virtual guess Guess() + { + Random red = new Random(); + int key = red.Next(1, 4); + guess g = (guess)key; + return g; + } + } +} diff --git "a/\346\226\271\350\215\243\346\230\237/\347\214\234\346\213\263/Npc.cs" "b/\346\226\271\350\215\243\346\230\237/\347\214\234\346\213\263/Npc.cs" new file mode 100644 index 0000000000000000000000000000000000000000..11fe9ba512b070ac9b85d43304c027632c8929f8 --- /dev/null +++ "b/\346\226\271\350\215\243\346\230\237/\347\214\234\346\213\263/Npc.cs" @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp4 +{ + class Npc : Game + { + public Npc(string name, string name1) : base(name, name1) + { + + } + + + public void talk1() + { + Console.Write("{name1}: 出拳:"); + Console.WriteLine(Guess()); + } + + } +} diff --git "a/\346\226\271\350\215\243\346\230\237/\347\214\234\346\213\263/Player.cs" "b/\346\226\271\350\215\243\346\230\237/\347\214\234\346\213\263/Player.cs" new file mode 100644 index 0000000000000000000000000000000000000000..c4c7c4bd4600d3b1019edd8c1412aad7a57f2c7f --- /dev/null +++ "b/\346\226\271\350\215\243\346\230\237/\347\214\234\346\213\263/Player.cs" @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp4 +{ + class Player : Game + { + public Player(string name, string name1) : base(name, name1) + { + + } + public int key; + public void talk1() + { + Console.WriteLine("请出拳:{0}", Guess1()); + key = int.Parse(Console.ReadLine()); + Console.Write($"{0}: 出拳:",name); + Console.WriteLine(Guess()); + } + public override guess Guess() + { + + guess g = (guess)key; + return g; + } + static string Guess1() + { + string str = null; + int i = 1; + foreach (guess t in Enum.GetValues(typeof(guess))) + { + str += $"{i}、{t} "; + i++; + } + return str; + } + } +} diff --git "a/\346\226\271\350\215\243\346\230\237/\347\214\234\346\213\263/Program.cs" "b/\346\226\271\350\215\243\346\230\237/\347\214\234\346\213\263/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..2c9148408badd953171cd9609d479b8e3c65814e --- /dev/null +++ "b/\346\226\271\350\215\243\346\230\237/\347\214\234\346\213\263/Program.cs" @@ -0,0 +1,99 @@ +using ConsoleApp1; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp4 +{ + class Program + { + static void Main(string[] args) + { + + Console.WriteLine("------欢迎进入游戏世界------"); + 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.Write("请输入您的姓名:"); + string 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: + break; + } + } + + private static void Go(string a, string b) + { + Npc nPC = new Npc(a, b); + Player user = new Player(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.talk1(); + int f = (int)user.Guess(); + int i = (int)nPC.Guess(); + + NextRound(nPC,user); + } + else if (key == ('n' | 'N')) + { + + Environment.Exit(0); + NextRound(nPC, user); + + } + else + { + Console.WriteLine("选择出错!自动退出"); + Environment.Exit(0); + } + + } + + + public static void NextRound(Npc nPC, Player user) + { + Referee referee = new Referee(); + Console.WriteLine("是否开始下一轮(y/n)"); + char key = char.Parse(Console.ReadLine()); + if (key == ('y' | 'Y')) + { + user.talk1(); + nPC.talk1(); + NextRound(nPC, user); + } + else if (key == ('n' | 'N')) + { + referee.Date1(); + } + + + } + } +} diff --git "a/\346\226\271\350\215\243\346\230\237/\347\214\234\346\213\263/Referee.cs" "b/\346\226\271\350\215\243\346\230\237/\347\214\234\346\213\263/Referee.cs" new file mode 100644 index 0000000000000000000000000000000000000000..8c2d621761be67f94d7967d9c003ed1dd9d8370d --- /dev/null +++ "b/\346\226\271\350\215\243\346\230\237/\347\214\234\346\213\263/Referee.cs" @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Referee + { + + int sum1 = 0; + int sum2 = 0; + int sum3 = 0; + int sum4 = 0; + + public void Date(int a1, int a2) + { + if (a1 - a2 == -2 || a1 - a2 == 1) + { + Console.WriteLine("玩家胜利!"); + sum2++; + } + else if (a1 == a2) + { + Console.WriteLine("平局"); + sum3++; + } + else + { + Console.WriteLine("玩家失败!"); + sum4++; + } + sum1 = sum2 + sum3 + sum4; + + } + + + internal void Date1() + { + Console.WriteLine("你的胜场数:{0}", sum2); + Console.WriteLine("对手胜场数:{0}", sum4); + Console.WriteLine("平局场数:{0}", sum3); + Console.WriteLine("总场数:{0}", sum1); + if (sum2 > sum4) + { + Console.WriteLine("你赢了"); + } + else if (sum2 < sum4) + { + Console.WriteLine("你输了"); + } + else if (sum2 == sum4) + { + Console.WriteLine("平局"); + } + } + } +} diff --git "a/\346\226\271\350\215\243\346\230\237/\347\273\223\346\236\204\344\275\223/PersonClass.cs" "b/\346\226\271\350\215\243\346\230\237/\347\273\223\346\236\204\344\275\223/PersonClass.cs" new file mode 100644 index 0000000000000000000000000000000000000000..eda314159ad4a65946ab10f1e336fd8ba310b42d --- /dev/null +++ "b/\346\226\271\350\215\243\346\230\237/\347\273\223\346\236\204\344\275\223/PersonClass.cs" @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp5 +{ + class PersonClass + { + public string name; + public int telephone; + public string add; + + public PersonClass(string name, int telephone, string add) + { + this.name = name; + this.telephone = telephone; + this.add = add; + } + } +} diff --git "a/\346\226\271\350\215\243\346\230\237/\347\273\223\346\236\204\344\275\223/Program.cs" "b/\346\226\271\350\215\243\346\230\237/\347\273\223\346\236\204\344\275\223/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..49b6c2bfcd1379041d3fcccce5206420a4610cc0 --- /dev/null +++ "b/\346\226\271\350\215\243\346\230\237/\347\273\223\346\236\204\344\275\223/Program.cs" @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp5 +{ + class Program + { + public struct PersonStruct + { + public string name; + public int telephone; + public string add; + + public PersonStruct(string name, int telephone, string add) + { + this.name = name; + this.telephone = telephone; + this.add = add; + } + + } + + + + static void Main(string[] args) + { + PersonStruct p1 = new PersonStruct(); + p1.name = "张三"; + p1.telephone = 4548789; + p1.add = "龙岩"; + + PersonStruct p2 = new PersonStruct(); + p2 = p1; + p2.name = "李四"; + Console.WriteLine("姓名:{0},电话:{1},地址:{2}", p1.name, p1.telephone, p1.add); + Console.WriteLine("姓名:{0},电话:{1},地址:{2}", p2.name, p2.telephone, p2.add); + + PersonStruct p3 = new PersonStruct("王五", 546765306, "泉州"); + + PersonClass p4 = new PersonClass(p3.name, p3.telephone, p3.add); + p4.name = "赵六"; + Console.WriteLine("姓名:{0},电话:{1},地址:{2}", p3.name, p3.telephone, p3.add); + Console.WriteLine("姓名:{0},电话:{1},地址:{2}", p4.name, p4.telephone, p4.add); + } + } +} diff --git "a/\346\226\275\346\261\237\345\263\260/Computer.cs" "b/\346\226\275\346\261\237\345\263\260/Computer.cs" new file mode 100644 index 0000000000000000000000000000000000000000..aeddedabdb28ab854c29ba702deed90c2e76d91a --- /dev/null +++ "b/\346\226\275\346\261\237\345\263\260/Computer.cs" @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp5 +{ + class Computer:Father + { + Random random = new Random(); + private int ran; + public int Ran { get => ran; set => ran = value; } + public void CompetreHand(int num) + { + Ran = random.Next(1, 4); + switch (Ran) + { + case 1: + Console.WriteLine((Hero)num + " :出拳: "+ (Rule)Ran); + break; + case 2: + Console.WriteLine((Hero)num + " :出拳: " + (Rule)Ran); + break; + case 3: + Console.WriteLine((Hero)num + " :出拳: " + (Rule)Ran); + break; + default: + break; + } + } + } +} diff --git "a/\346\226\275\346\261\237\345\263\260/Father.cs" "b/\346\226\275\346\261\237\345\263\260/Father.cs" new file mode 100644 index 0000000000000000000000000000000000000000..7dbcb7894e40efdebf74e468f7489b44eff5ed1e --- /dev/null +++ "b/\346\226\275\346\261\237\345\263\260/Father.cs" @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +enum Hero +{ + 刘备 = 1, + 孙权, + 曹操 +} +enum Rule +{ + 剪刀 = 1, + 石头, + 布 +} +namespace ConsoleApp5 +{ + class Father + { + + public int cname1; + public string pname1; + + public int Cname1 { get => cname1; set => cname1 = value; } + public string Pname1 { get => pname1; set => pname1 = value; } + + + public void GameChoose() + { + Console.WriteLine("请选择对方的角色 《1.刘备 2.孙权 3.曹操》"); + Cname1 = int.Parse(Console.ReadLine()); + Console.WriteLine("请输入你的姓名:"); + this.pname1 = Console.ReadLine(); + Console.WriteLine(Pname1 + " vs " + (Hero)Cname1 + " 对战"); + Console.WriteLine("开始游戏吗?(y/n)"); + } + + } +} diff --git "a/\346\226\275\346\261\237\345\263\260/Judgement.cs" "b/\346\226\275\346\261\237\345\263\260/Judgement.cs" new file mode 100644 index 0000000000000000000000000000000000000000..a6eac3b6b626ac39bb8d1c4a3d70624785f9e1af --- /dev/null +++ "b/\346\226\275\346\261\237\345\263\260/Judgement.cs" @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp5 +{ + class Judgement + { + private static int Pscore = 0; + private static int Cscore = 0; + private static int equal = 0; + private static int count1 = 0; + + public static int Pscore1 { get => Pscore; set => Pscore = value; } + public static int Cscore1 { get => Cscore; set => Cscore = value; } + public static int Equal { get => equal; set => equal = value; } + public static int Count1 { get => count1; set => count1 = value; } + + public static void Judge1(int num1,int num2,string name) + { + if (num1 - num2 == 1||num1-num2 == -2) + { + Console.WriteLine("恭喜,"+ name + " 赢了"); + Pscore1++; + }else if (num1 == num2) + { + Console.WriteLine("和局!真衰,等着瞧吧!!!"); + Equal++; + } + else + { + Console.WriteLine("笨蛋," + name + " 输了"); + Cscore1++; + } + Count1 = Pscore1 + Cscore1 + Equal; + } + + + } +} diff --git "a/\346\226\275\346\261\237\345\263\260/Player.cs" "b/\346\226\275\346\261\237\345\263\260/Player.cs" new file mode 100644 index 0000000000000000000000000000000000000000..39b069d9bf6c1f81702cac5cf67aceb33017eefe --- /dev/null +++ "b/\346\226\275\346\261\237\345\263\260/Player.cs" @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp5 +{ + class Player : Father + { + private int playerhand; + public int Playerhand { get => playerhand; set => playerhand = value; } + public void PlayerHand(string name) + { + aa: + Playerhand = int.Parse(Console.ReadLine()); + switch (Playerhand) + { + case 1: + + Console.WriteLine(name + " : 出拳: " + (Rule)Playerhand); + + break; + case 2: + + Console.WriteLine(name + " : 出拳: " + (Rule)Playerhand); + + break; + case 3: + + Console.WriteLine(name + " : 出拳: " + (Rule)Playerhand); + break; + default: + Console.WriteLine("输入错误请重新输入"); + goto aa; + break; + } + } + } +} diff --git "a/\346\226\275\346\261\237\345\263\260/Program.cs" "b/\346\226\275\346\261\237\345\263\260/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b1911111f0c3cef9c7a1f15ab111487317befbfc --- /dev/null +++ "b/\346\226\275\346\261\237\345\263\260/Program.cs" @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp5 +{ + class Program : Father + { + static void Main(string[] args) + { + Father father = new Father(); + GameTop(); + father.GameChoose(); + Ready(); + aa: + Console.WriteLine("请出拳: 1.剪刀 2.石头 3.布(输入数字代替)"); + Player player = new Player(); + player.PlayerHand(father.pname1); + Computer computer = new Computer(); + computer.CompetreHand(father.cname1); + Judgement judgement = new Judgement(); + Judgement.Judge1(player.Playerhand,computer.Ran,father.pname1) ; + cc: + Console.WriteLine("是否开始下一轮《 y / n 》"); + bb: + char c = char.Parse(Console.ReadLine()); + if (c=='y') + { + goto aa; + } + else if (c == 'n'){ + Console.WriteLine("退出系统"); + } + else + { + Console.WriteLine("仅能输入y和n,请重新输入"); + goto bb; + } + GameOver(father.Pname1,father.Cname1,Judgement.Pscore1, Judgement.Cscore1, Judgement.Count1,Judgement.Equal); + goto cc; + Console.ReadKey(); + } + public static void GameTop() + { + Console.ForegroundColor = ConsoleColor.Green; + Console.WriteLine("-----------------欢迎进入游戏世界-----------------"); + Console.WriteLine("***************************************************"); + Console.WriteLine("*******************猜拳,开始**********************"); + Console.WriteLine("***************************************************"); + Console.WriteLine("出拳规则 : 1.剪刀 2.石头 3.布"); + } + public static void Ready() + { + aa: + char ready = char.Parse(Console.ReadLine()); + switch (ready) + { + case 'y': + + break; + case 'n': + Ready(); + break; + default: + Console.WriteLine("输入异常,请重新输入"); + goto aa; + break; + } + + + } + public static void GameOver(string name,int num,int a,int b,int c,int d) + { + Console.WriteLine("====================="); + Console.WriteLine((Hero)num+" vs "+ name); + Console.WriteLine("姓名 得分"); + Console.WriteLine(name+ " "+a); + Console.WriteLine((Hero)num + " "+b); + Console.WriteLine("一共对局"+c); + Console.WriteLine("一共和了"+d); + if (a>b) + { + Console.WriteLine("结果: "+name+ "赢 "+ (Hero)num + " 笨蛋"); + }else if (a name; set => name = value; } + public int Num { get => num; set => num = value; } + public string Address { get => address; set => address = value; } + } +} diff --git "a/\346\226\275\346\261\237\345\263\260/jiegou2.cs" "b/\346\226\275\346\261\237\345\263\260/jiegou2.cs" new file mode 100644 index 0000000000000000000000000000000000000000..1f3fe7f4a592bc41494df1d70808f91fac3e11af --- /dev/null +++ "b/\346\226\275\346\261\237\345\263\260/jiegou2.cs" @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +//定义一个结构体,名为PersonStruct,有三个成员变量:姓名、电话、地址, +//在主方法中,创建一个PersonStruct结构体对象p1,为p1的成员变量赋值。 +//再声明一个PersonStruct结构体变量p2,把p1赋值给p2,改变p2的姓名,打印p1的内容。 +namespace ConsoleApp2 +{ + class Program + { + struct PersonStruct + { + public string name; + public int num; + public string address; + public PersonStruct(string name,int num,string address) + { + this.name = name; + this.num = num; + this.address = address; + } + } + static void Main(string[] args) + { + PersonStruct p1 = new PersonStruct("张三",123,"图书馆"); + PersonStruct p2=p1; + p2.name = "李四"; + Console.WriteLine("结构体:{0},{1},{2}",p1.name,p1.num,p1.address); + //在主方法中,创建一个PersonClass对象p3,为p3的成员变量赋值。 + PersonClass P3 = new PersonClass("张三", 123, "图书馆"); + PersonClass p4 = P3; + p4.Name = "李四"; + Console.WriteLine("类:{0},{1},{2}",P3.Name,P3.Num,P3.Address); + Console.ReadKey(); + } + } +} diff --git "a/\346\234\261\345\245\207\344\274\237/Program.cs" "b/\346\234\261\345\245\207\344\274\237/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..8d568abac75481d2807afabeb1fa61655c4dbe15 --- /dev/null +++ "b/\346\234\261\345\245\207\344\274\237/Program.cs" @@ -0,0 +1,144 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Program + { + + enum enrole + { + 刘备 = 1, + 孙权 = 2, + 曹操 = 3 + } + enum enMora + { + 石头 = 1, + 剪刀 = 2, + 布 = 3 + } + static void Main(string[] args) + { + //人物类 出的选型类 + + Console.WriteLine("-----------欢迎进入游戏世界-----------" + "\n"); + Console.WriteLine("************************"); + Console.WriteLine("********猜拳开始********"); + Console.WriteLine("************************"); + Console.WriteLine("出拳规则:1.剪刀2.石头3.布"); + Console.WriteLine("请选择对方的角色(1:刘备2.孙权3.曹操)"); + int numname = int.Parse(Console.ReadLine()); + string npcstr = Enum.GetName(typeof(enrole), numname); //NPC姓名 npcstr + + Role role = new Role(npcstr); //获取名字后传入类重写 + Console.WriteLine("请输入您的姓名"); // 玩家姓名 playname + string playname = Console.ReadLine(); + + Console.WriteLine(playname + " VS " + npcstr); + + Console.WriteLine("是否开始游戏(y/n)"); + char char1 = Convert.ToChar(Console.ReadLine()); + if (char1 == 'y' || char1 == 'Y') + { + WinMora(role, npcstr, playname); + + } + else if(char1 == 'n' || char1 == 'N') + { + Console.WriteLine("退出游戏"); + } + Console.WriteLine("要开始下一局游戏吗?(y/n)"); + char char3 = Convert.ToChar(Console.ReadLine()); + if (char3 == 'y' || char3 == 'Y') + { + WinMora(role, npcstr, playname); + + } + else if (char3 == 'n' || char3 == 'N') + { + Console.WriteLine("退出程序"); + System.Environment.Exit(0); + } + } + + private static void WinMora(Role role, string npcstr, string playname) + { + + + int draw = 0; + int NPCwin = 0; + int Playwin = 0; + + while (true) + { + Console.WriteLine("请出拳1.石头2.剪刀3.布请输入数字(请输入相应的数字)"); + int Moranum = int.Parse(Console.ReadLine()); + string playMora = Enum.GetName(typeof(enMora), Moranum); //获取用户输入的数字转化为相应的枚举里的值 + + Console.WriteLine(playname + " : 出拳: " + playMora); + role.Write(); + + if (role.StrMora == playMora) + { + Console.WriteLine("平局,放你一马"); + draw = draw + 1; + } + else if (playMora == "石头" && role.StrMora == "剪刀" || playMora == "布" && role.StrMora == "石头" || playMora == "剪刀" && role.StrMora == "布") + { + Console.WriteLine("恭喜您,勇夺三军,天下无双"); + Playwin = Playwin + 1; + } + else if (role.StrMora == "剪刀" && playMora == "布" || role.StrMora == "石头" && playMora == "剪刀" || role.StrMora == "布" && playMora == "石头") + { + Console.WriteLine("天啦噜,难以置信,这也会输"); + NPCwin = NPCwin + 1; + } + else if (playMora != "石头" || playMora != "剪刀" || playMora != "布") + { + NPCwin = NPCwin + 1; + Console.WriteLine("玩家,出拳不符合规则默认判负"); + } + + Console.WriteLine("是否开始下一局(y/n)"); + char char2 = Convert.ToChar(Console.ReadLine()); + if (char2 == 'y' || char2 == 'Y') + { + + } + else if(char2 == 'n' || char2 == 'N') + { + Console.WriteLine("结束游戏"); + Console.WriteLine("==========================="); + Console.WriteLine(playname + " VS " + npcstr); + Console.WriteLine("对战次数" + (Playwin + NPCwin + draw)); + Console.WriteLine("姓名 得分"); + Console.WriteLine($"{playname} {Playwin}"); + Console.WriteLine($"{npcstr} {NPCwin}"); + if (Playwin > NPCwin) + { + Console.WriteLine( "玩家 "+playname+" 胜出,举世同庆"); + } + else if (NPCwin > Playwin) + { + Console.WriteLine( "电脑"+ npcstr+"胜出,棋差一手"); + } + else + { + Console.WriteLine("平局"); + } + break; + } + + + } + } + } + + +} + + diff --git "a/\346\234\261\345\245\207\344\274\237/Role.cs" "b/\346\234\261\345\245\207\344\274\237/Role.cs" new file mode 100644 index 0000000000000000000000000000000000000000..2970a348aa51a9de886523e6d5e30f4896d4161f --- /dev/null +++ "b/\346\234\261\345\245\207\344\274\237/Role.cs" @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Role + { + private string name; + private string strmora; + public string Name { get; set; } + public string StrMora + { + get { return this.strmora; } + set { this.strmora=value; } + + } + + public Role(string name) + { + this.Name = name; + } + public void Test(string strmora) + { + + Random random = new Random(); + + + if (random.Next(1, 4) == 1) + { + strmora = "石头"; + } + else if (random.Next(1, 4) == 2) + { + strmora = "布"; + } + else if (random.Next(1, 4) == 3) + { + strmora = "剪刀"; + } + + this.StrMora = strmora; + + + } + public void Write() + { + Test(strmora); + StrMora = strmora; + Console.WriteLine("{0}: 出拳 :{1}",Name, StrMora); + + + } + + } +} diff --git "a/\346\235\216\345\255\220\346\272\220/Program.cs" "b/\346\235\216\345\255\220\346\272\220/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..58342bfae6c1e807c72b1097eea5f015921b2964 --- /dev/null +++ "b/\346\235\216\345\255\220\346\272\220/Program.cs" @@ -0,0 +1,129 @@ +using ConsoleApp2; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp +{ + class Program + { + + enum enrole + { + 刘备 = 1, + 曹操 = 2, + 孙权 = 3 + } + enum enMora + { + 石头 = 1, + 剪刀 = 2, + 布 = 3 + } + static void Main(string[] args) + { + Console.WriteLine("欢迎来到游戏世界" + "\n"); + Console.WriteLine("猜拳开始"); + Console.WriteLine("出拳规则:1、石头 2、剪刀 3、布"); + Console.WriteLine("请选择对方的角色(1、刘备 2 、曹操 3、孙权"); + int numname = int.Parse(Console.ReadLine()); + string npcstr = Enum.GetName(typeof(enrole), numname); + Role role = new Role(npcstr); + Console.WriteLine("请输入您的名字"); + string playname = Console.ReadLine(); + Console.WriteLine(playname + "Vs" + npcstr); + Console.WriteLine("是否开始游戏(Y/N)"); + char char1 = Convert.ToChar(Console.ReadLine()); + if (char1 == 'Y' || char1 == 'y') + { + WinMora(role, npcstr, playname); + } + else if (char1 == 'N' || char1 == 'n') + { + Console.WriteLine("退出游戏"); + } + Console.WriteLine("要开始新的游戏吗?(Y/N)"); + char char2 = Convert.ToChar(Console.ReadLine()); + if (char2 == 'Y' || char2 == 'y') + { + WinMora(role, npcstr, playname); + + } + else if (char2 == 'N' || char2 == 'n') + { + Console.WriteLine("退出程序"); + System.Environment.Exit(0); + } + } + + private static void WinMora(Role role, string npcstr, string playname) + { + int draw = 0; + int NPCwin = 0; + int Playwin = 0; + + while (true) + { + Console.WriteLine("请出拳1.石头2.剪刀3.布请输入数字(请输入相应的数字)"); + int Moranum = int.Parse(Console.ReadLine()); + string playMora = Enum.GetName(typeof(enMora), Moranum); //获取用户输入的数字转化为相应的枚举里的值 + + Console.WriteLine(playname + " : 出拳: " + playMora); + role.Write(); + + if (role.StrMora == playMora) + { + Console.WriteLine("平局,放你一马"); + draw = draw + 1; + } + else if (playMora == "石头" && role.StrMora == "剪刀" || playMora == "布" && role.StrMora == "石头" || playMora == "剪刀" && role.StrMora == "布") + { + Console.WriteLine("恭喜您,勇夺三军,天下无双"); + Playwin = Playwin + 1; + } + else if (role.StrMora == "剪刀" && playMora == "布" || role.StrMora == "石头" && playMora == "剪刀" || role.StrMora == "布" && playMora == "石头") + { + Console.WriteLine("天啦噜,难以置信,这也会输"); + NPCwin = NPCwin + 1; + } + else if (playMora != "石头" || playMora != "剪刀" || playMora != "布") + { + NPCwin = NPCwin + 1; + Console.WriteLine("玩家,出拳不符合规则默认判负"); + } + + Console.WriteLine("是否开始下一局(y/n)"); + char char2 = Convert.ToChar(Console.ReadLine()); + if (char2 == 'y' || char2 == 'Y') + { + + } + else if (char2 == 'n' || char2 == 'N') + { + Console.WriteLine("结束游戏"); + Console.WriteLine("==========================="); + Console.WriteLine(playname + " VS " + npcstr); + Console.WriteLine("对战次数" + (Playwin + NPCwin + draw)); + Console.WriteLine("姓名 得分"); + Console.WriteLine($"{playname} {Playwin}"); + Console.WriteLine($"{npcstr} {NPCwin}"); + if (Playwin > NPCwin) + { + Console.WriteLine("玩家 " + playname + " 胜出,举世同庆"); + } + else if (NPCwin > Playwin) + { + Console.WriteLine("电脑" + npcstr + "胜出,棋差一手"); + } + else + { + Console.WriteLine("平局"); + } + break; + } + } + } + } +} diff --git "a/\346\235\216\345\255\220\346\272\220/Role.cs" "b/\346\235\216\345\255\220\346\272\220/Role.cs" new file mode 100644 index 0000000000000000000000000000000000000000..79b3286b21420bcd3631043ac6b614db2be3a227 --- /dev/null +++ "b/\346\235\216\345\255\220\346\272\220/Role.cs" @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Role + { + private string name; + private string strmora; + public string Name { get; set; } + public string StrMora + { + get { return this.strmora; } + set { this.strmora = value; } + } + + public Role(string name) + { + this.Name = name; + } + public void Test(string strmora) + { + Random random = new Random(); + + if (random.Next(1, 4) == 1) + { + strmora = "石头"; + } + else if (random.Next(1, 4) == 2) + { + strmora = "布"; + } + else if (random.Next(1, 4) == 3) + { + strmora = "剪刀"; + } + this.StrMora = strmora; + } + public void Write() + { + Test(strmora); + StrMora = strmora; + Console.WriteLine("{0}: 出手 :{1}", Name, StrMora); + } + + } +} diff --git "a/\346\235\216\346\230\214\345\256\235/\347\214\234\346\213\263/Computer.cs" "b/\346\235\216\346\230\214\345\256\235/\347\214\234\346\213\263/Computer.cs" new file mode 100644 index 0000000000000000000000000000000000000000..aeddedabdb28ab854c29ba702deed90c2e76d91a --- /dev/null +++ "b/\346\235\216\346\230\214\345\256\235/\347\214\234\346\213\263/Computer.cs" @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp5 +{ + class Computer:Father + { + Random random = new Random(); + private int ran; + public int Ran { get => ran; set => ran = value; } + public void CompetreHand(int num) + { + Ran = random.Next(1, 4); + switch (Ran) + { + case 1: + Console.WriteLine((Hero)num + " :出拳: "+ (Rule)Ran); + break; + case 2: + Console.WriteLine((Hero)num + " :出拳: " + (Rule)Ran); + break; + case 3: + Console.WriteLine((Hero)num + " :出拳: " + (Rule)Ran); + break; + default: + break; + } + } + } +} diff --git "a/\346\235\216\346\230\214\345\256\235/\347\214\234\346\213\263/Father.cs" "b/\346\235\216\346\230\214\345\256\235/\347\214\234\346\213\263/Father.cs" new file mode 100644 index 0000000000000000000000000000000000000000..7dbcb7894e40efdebf74e468f7489b44eff5ed1e --- /dev/null +++ "b/\346\235\216\346\230\214\345\256\235/\347\214\234\346\213\263/Father.cs" @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +enum Hero +{ + 刘备 = 1, + 孙权, + 曹操 +} +enum Rule +{ + 剪刀 = 1, + 石头, + 布 +} +namespace ConsoleApp5 +{ + class Father + { + + public int cname1; + public string pname1; + + public int Cname1 { get => cname1; set => cname1 = value; } + public string Pname1 { get => pname1; set => pname1 = value; } + + + public void GameChoose() + { + Console.WriteLine("请选择对方的角色 《1.刘备 2.孙权 3.曹操》"); + Cname1 = int.Parse(Console.ReadLine()); + Console.WriteLine("请输入你的姓名:"); + this.pname1 = Console.ReadLine(); + Console.WriteLine(Pname1 + " vs " + (Hero)Cname1 + " 对战"); + Console.WriteLine("开始游戏吗?(y/n)"); + } + + } +} diff --git "a/\346\235\216\346\230\214\345\256\235/\347\214\234\346\213\263/Judgement.cs" "b/\346\235\216\346\230\214\345\256\235/\347\214\234\346\213\263/Judgement.cs" new file mode 100644 index 0000000000000000000000000000000000000000..a6eac3b6b626ac39bb8d1c4a3d70624785f9e1af --- /dev/null +++ "b/\346\235\216\346\230\214\345\256\235/\347\214\234\346\213\263/Judgement.cs" @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp5 +{ + class Judgement + { + private static int Pscore = 0; + private static int Cscore = 0; + private static int equal = 0; + private static int count1 = 0; + + public static int Pscore1 { get => Pscore; set => Pscore = value; } + public static int Cscore1 { get => Cscore; set => Cscore = value; } + public static int Equal { get => equal; set => equal = value; } + public static int Count1 { get => count1; set => count1 = value; } + + public static void Judge1(int num1,int num2,string name) + { + if (num1 - num2 == 1||num1-num2 == -2) + { + Console.WriteLine("恭喜,"+ name + " 赢了"); + Pscore1++; + }else if (num1 == num2) + { + Console.WriteLine("和局!真衰,等着瞧吧!!!"); + Equal++; + } + else + { + Console.WriteLine("笨蛋," + name + " 输了"); + Cscore1++; + } + Count1 = Pscore1 + Cscore1 + Equal; + } + + + } +} diff --git "a/\346\235\216\346\230\214\345\256\235/\347\214\234\346\213\263/Player.cs" "b/\346\235\216\346\230\214\345\256\235/\347\214\234\346\213\263/Player.cs" new file mode 100644 index 0000000000000000000000000000000000000000..39b069d9bf6c1f81702cac5cf67aceb33017eefe --- /dev/null +++ "b/\346\235\216\346\230\214\345\256\235/\347\214\234\346\213\263/Player.cs" @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp5 +{ + class Player : Father + { + private int playerhand; + public int Playerhand { get => playerhand; set => playerhand = value; } + public void PlayerHand(string name) + { + aa: + Playerhand = int.Parse(Console.ReadLine()); + switch (Playerhand) + { + case 1: + + Console.WriteLine(name + " : 出拳: " + (Rule)Playerhand); + + break; + case 2: + + Console.WriteLine(name + " : 出拳: " + (Rule)Playerhand); + + break; + case 3: + + Console.WriteLine(name + " : 出拳: " + (Rule)Playerhand); + break; + default: + Console.WriteLine("输入错误请重新输入"); + goto aa; + break; + } + } + } +} diff --git "a/\346\235\216\346\230\214\345\256\235/\347\214\234\346\213\263/Program.cs" "b/\346\235\216\346\230\214\345\256\235/\347\214\234\346\213\263/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b1911111f0c3cef9c7a1f15ab111487317befbfc --- /dev/null +++ "b/\346\235\216\346\230\214\345\256\235/\347\214\234\346\213\263/Program.cs" @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp5 +{ + class Program : Father + { + static void Main(string[] args) + { + Father father = new Father(); + GameTop(); + father.GameChoose(); + Ready(); + aa: + Console.WriteLine("请出拳: 1.剪刀 2.石头 3.布(输入数字代替)"); + Player player = new Player(); + player.PlayerHand(father.pname1); + Computer computer = new Computer(); + computer.CompetreHand(father.cname1); + Judgement judgement = new Judgement(); + Judgement.Judge1(player.Playerhand,computer.Ran,father.pname1) ; + cc: + Console.WriteLine("是否开始下一轮《 y / n 》"); + bb: + char c = char.Parse(Console.ReadLine()); + if (c=='y') + { + goto aa; + } + else if (c == 'n'){ + Console.WriteLine("退出系统"); + } + else + { + Console.WriteLine("仅能输入y和n,请重新输入"); + goto bb; + } + GameOver(father.Pname1,father.Cname1,Judgement.Pscore1, Judgement.Cscore1, Judgement.Count1,Judgement.Equal); + goto cc; + Console.ReadKey(); + } + public static void GameTop() + { + Console.ForegroundColor = ConsoleColor.Green; + Console.WriteLine("-----------------欢迎进入游戏世界-----------------"); + Console.WriteLine("***************************************************"); + Console.WriteLine("*******************猜拳,开始**********************"); + Console.WriteLine("***************************************************"); + Console.WriteLine("出拳规则 : 1.剪刀 2.石头 3.布"); + } + public static void Ready() + { + aa: + char ready = char.Parse(Console.ReadLine()); + switch (ready) + { + case 'y': + + break; + case 'n': + Ready(); + break; + default: + Console.WriteLine("输入异常,请重新输入"); + goto aa; + break; + } + + + } + public static void GameOver(string name,int num,int a,int b,int c,int d) + { + Console.WriteLine("====================="); + Console.WriteLine((Hero)num+" vs "+ name); + Console.WriteLine("姓名 得分"); + Console.WriteLine(name+ " "+a); + Console.WriteLine((Hero)num + " "+b); + Console.WriteLine("一共对局"+c); + Console.WriteLine("一共和了"+d); + if (a>b) + { + Console.WriteLine("结果: "+name+ "赢 "+ (Hero)num + " 笨蛋"); + }else if (a name; set => name = value; } + public int Num { get => num; set => num = value; } + public string Address { get => address; set => address = value; } + } +} diff --git "a/\346\235\216\346\230\214\345\256\235/\347\273\223\346\236\204\344\275\223/\347\273\223\346\236\204\344\275\223\347\261\273 (2).cs" "b/\346\235\216\346\230\214\345\256\235/\347\273\223\346\236\204\344\275\223/\347\273\223\346\236\204\344\275\223\347\261\273 (2).cs" new file mode 100644 index 0000000000000000000000000000000000000000..1f3fe7f4a592bc41494df1d70808f91fac3e11af --- /dev/null +++ "b/\346\235\216\346\230\214\345\256\235/\347\273\223\346\236\204\344\275\223/\347\273\223\346\236\204\344\275\223\347\261\273 (2).cs" @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +//定义一个结构体,名为PersonStruct,有三个成员变量:姓名、电话、地址, +//在主方法中,创建一个PersonStruct结构体对象p1,为p1的成员变量赋值。 +//再声明一个PersonStruct结构体变量p2,把p1赋值给p2,改变p2的姓名,打印p1的内容。 +namespace ConsoleApp2 +{ + class Program + { + struct PersonStruct + { + public string name; + public int num; + public string address; + public PersonStruct(string name,int num,string address) + { + this.name = name; + this.num = num; + this.address = address; + } + } + static void Main(string[] args) + { + PersonStruct p1 = new PersonStruct("张三",123,"图书馆"); + PersonStruct p2=p1; + p2.name = "李四"; + Console.WriteLine("结构体:{0},{1},{2}",p1.name,p1.num,p1.address); + //在主方法中,创建一个PersonClass对象p3,为p3的成员变量赋值。 + PersonClass P3 = new PersonClass("张三", 123, "图书馆"); + PersonClass p4 = P3; + p4.Name = "李四"; + Console.WriteLine("类:{0},{1},{2}",P3.Name,P3.Num,P3.Address); + Console.ReadKey(); + } + } +} diff --git "a/\346\235\250\344\270\260\350\261\252/\347\214\234\346\213\263\346\270\270\346\210\217/Judgment.cs" "b/\346\235\250\344\270\260\350\261\252/\347\214\234\346\213\263\346\270\270\346\210\217/Judgment.cs" new file mode 100644 index 0000000000000000000000000000000000000000..182875c08e13b27cc0c103d36f8bf178865f97fd --- /dev/null +++ "b/\346\235\250\344\270\260\350\261\252/\347\214\234\346\213\263\346\270\270\346\210\217/Judgment.cs" @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp14 +{ + class Judgment + { + int sum1 = 0; + int sum2 = 0; + int sum3 = 0; + int sum4 = 0; + + public void Date(int p1, int p2) + { + if (p1 - p2 == -2 || p1 - p2 == 1) + { + Console.WriteLine("玩家胜利!"); + sum2++; + } + else if (p1 == p2) + { + Console.WriteLine("平局"); + sum3++; + } + else + { + Console.WriteLine("玩家失败!"); + sum4++; + } + sum1 = sum2 + sum3 + sum4; + + } + + + internal void Date1() + { + Console.WriteLine("你的胜场数:{0}", sum2); + Console.WriteLine("对手胜场数:{0}", sum4); + Console.WriteLine("平局场数:{0}", sum3); + Console.WriteLine("总场数:{0}", sum1); + if (sum2 > sum4) + { + Console.WriteLine("你赢了"); + } + else if (sum2 < sum4) + { + Console.WriteLine("你输了"); + } + else if (sum2 == sum4) + { + Console.WriteLine("平局"); + } + } + } +} \ No newline at end of file diff --git "a/\346\235\250\344\270\260\350\261\252/\347\214\234\346\213\263\346\270\270\346\210\217/Me.cs" "b/\346\235\250\344\270\260\350\261\252/\347\214\234\346\213\263\346\270\270\346\210\217/Me.cs" new file mode 100644 index 0000000000000000000000000000000000000000..e2e5257ae0c5763fc3c608ecc9eab900feaeaa37 --- /dev/null +++ "b/\346\235\250\344\270\260\350\261\252/\347\214\234\346\213\263\346\270\270\346\210\217/Me.cs" @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp14 +{ + class Me + { + private string name; + + public Me(string name) + { + this.name = name; + } + + public string Name { get => name; set => name = value; } + + public int Test1() + { + Console.WriteLine("请你选择出拳:1.剪刀 2.石头 3.布"); + int a = int.Parse(Console.ReadLine()); + switch (a) + { + case 1: + Console.WriteLine("{0}出了一个剪刀",name); + break; + case 2: + Console.WriteLine("{0}出了一个石头", name); + break; + case 3: + Console.WriteLine("{0}出了一个布",name); + break; + } + + return a; + } + } +} diff --git "a/\346\235\250\344\270\260\350\261\252/\347\214\234\346\213\263\346\270\270\346\210\217/Npc.cs" "b/\346\235\250\344\270\260\350\261\252/\347\214\234\346\213\263\346\270\270\346\210\217/Npc.cs" new file mode 100644 index 0000000000000000000000000000000000000000..402cf20e31a597d6c286995b12dafd98207c665c --- /dev/null +++ "b/\346\235\250\344\270\260\350\261\252/\347\214\234\346\213\263\346\270\270\346\210\217/Npc.cs" @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp14 +{ + class Npc : Me + { + private string name1; + + public Npc(string name, string name1) : base(name) + { + this.Name1 = name1; + + } + + public string Name1 { get => name1; set => name1 = value; } + + public int NPC1() + { + Random random = new Random(); + int result = random.Next(1, 4); + string str = Convert.ToString(result); + switch (result) + { + case 1: + str = "剪刀"; + break; + case 2: + str = "石头"; + break; + case 3: + str = "布"; + break; + } + Console.WriteLine("{0}出了一个{1}",name1,str); + return result; + } + } +} \ No newline at end of file diff --git "a/\346\235\250\344\270\260\350\261\252/\347\214\234\346\213\263\346\270\270\346\210\217/Program.cs" "b/\346\235\250\344\270\260\350\261\252/\347\214\234\346\213\263\346\270\270\346\210\217/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..1c9a9bf48c5b8883b41f24f3319615eacf148fc2 --- /dev/null +++ "b/\346\235\250\344\270\260\350\261\252/\347\214\234\346\213\263\346\270\270\346\210\217/Program.cs" @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp14 +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine(" 开发人员:杨丰豪"); + Console.WriteLine(); + Console.WriteLine("------------欢 迎 进 入 三 国 猜 拳 游 戏-----------"); + Console.WriteLine("****************************************************"); + Console.WriteLine("********************猜拳开始************************"); + Console.WriteLine("****************************************************"); + Console.WriteLine(); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Console.WriteLine(); + Console.WriteLine("请输入你的名字"); + string name = Console.ReadLine(); + Me me = new Me(name); + + Judgment judgment = new Judgment(); + Console.WriteLine("请选择你对战的角色:1.刘备 2.孙权 3.曹操"); + int a = int.Parse(Console.ReadLine()); + string str = Convert.ToString(a); + switch (str) + { + case "1": + str = "刘备"; + break; + case "2": + str = "孙权"; + break; + case "3": + str = "曹操"; + break; + default: + break; + } + + Npc npc = new Npc(name,str); + switch (a) + { + case 1: + Console.WriteLine("{0} vs 刘备",name); + dong(me,npc,judgment); + break; + case 2: + Console.WriteLine("{0} vs 孙权", name); + dong(me, npc, judgment); + break; + case 3: + Console.WriteLine("{0} vs 曹操", name); + dong(me, npc, judgment); + break; + default: + break; + + } + + } + public static void dong(Me me,Npc npc,Judgment judgment) + { + + Console.WriteLine("游戏开始吗?"); + string str = Console.ReadLine(); + switch (str) + { + case "y": + dong2(me, npc, judgment); + break; + case "n": + + break; + } + } + public static void dong2(Me me, Npc npc, Judgment judgment) { + while (true) + { + int p1 = me.Test1(); + int p2 = npc.NPC1(); + judgment.Date(p1,p2); + Console.WriteLine("是否进行下一轮?"); + string str = Console.ReadLine(); + switch (str) + { + case "y": + dong2(me, npc, judgment); + break; + case "n": + judgment.Date1(); + break; + } + break; + } + } + } + } diff --git "a/\346\235\250\344\270\260\350\261\252/\347\273\223\346\236\204\344\275\223/PersonClass.cs" "b/\346\235\250\344\270\260\350\261\252/\347\273\223\346\236\204\344\275\223/PersonClass.cs" new file mode 100644 index 0000000000000000000000000000000000000000..785a986cde9a5329b0353869811cc614f272874c --- /dev/null +++ "b/\346\235\250\344\270\260\350\261\252/\347\273\223\346\236\204\344\275\223/PersonClass.cs" @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp12 +{ + class PersonClass + { + + public string name; + public int tel; + public string address; + + public PersonClass(string name, int tel, string address) + { + this.name = name; + this.tel = tel; + this.address = address; + } + + } +} diff --git "a/\346\235\250\344\270\260\350\261\252/\347\273\223\346\236\204\344\275\223/Program.cs" "b/\346\235\250\344\270\260\350\261\252/\347\273\223\346\236\204\344\275\223/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..13b82a1ee62529da97f5bc6ba5f735dc7c0807de --- /dev/null +++ "b/\346\235\250\344\270\260\350\261\252/\347\273\223\346\236\204\344\275\223/Program.cs" @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp12 +{ + class Program + { + public struct PersonStruct + { + public string name; + public int tel; + public string address; + + public PersonStruct(string name,int tel,string address) + { + this.name = name; + this.tel = tel; + this.address = address; + } + } + static void Main(string[] args) + { + PersonStruct p1 = new PersonStruct(); + p1.name = "小韦"; + p1.tel =1557853212; + p1.address = "福建省闽大"; + + PersonStruct p2 = new PersonStruct(); + p2 = p1; + p2.name = "小东"; + Console.WriteLine("姓名:{0},电话:{1},地址:{2}",p1.name,p1.tel,p1.address); + + Console.WriteLine("姓名:{0},电话:{1},地址:{2}",p2.name,p2.tel,p2.address); + + PersonClass p3 = new PersonClass("小鑫",1557853201,"福建龙岩"); + PersonClass p4 = new PersonClass(p3.name, p3.tel, p3.address); + p4.name = "小宝"; + Console.WriteLine("姓名:{0},电话:{1},地址:{2}", p3.name, p3.tel, p3.address); + Console.WriteLine("姓名:{0},电话:{1},地址:{2}", p4.name, p4.tel, p4.address); + + } + } +} diff --git "a/\346\235\250\345\270\206/.keep" "b/\346\235\250\345\270\206/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\346\235\250\345\270\206/\347\237\263\345\244\264\345\211\252\345\210\200\345\270\203/NPC.cs" "b/\346\235\250\345\270\206/\347\237\263\345\244\264\345\211\252\345\210\200\345\270\203/NPC.cs" new file mode 100644 index 0000000000000000000000000000000000000000..3b64e2e955f864e9b13f9b8baa1fd994e4815594 --- /dev/null +++ "b/\346\235\250\345\270\206/\347\237\263\345\244\264\345\211\252\345\210\200\345\270\203/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 + { + private string name; + + public string Name { get => name; set => name = value; } + + public NPC(string name) + { + this.name = name; + } + + public NPC() + { + + } + + public void Move(string name, int b) + { + switch (b) + { + case 1: + Console.WriteLine("{0}出石头", name); + break; + case 2: + Console.WriteLine("{0}出剪刀", name); + break; + case 3: + Console.WriteLine("{0}出布", name); + break; + } + } + } +} diff --git "a/\346\235\250\345\270\206/\347\237\263\345\244\264\345\211\252\345\210\200\345\270\203/Player.cs" "b/\346\235\250\345\270\206/\347\237\263\345\244\264\345\211\252\345\210\200\345\270\203/Player.cs" new file mode 100644 index 0000000000000000000000000000000000000000..3328d77d7b0488b3c249f924c2f088cb9725e6a1 --- /dev/null +++ "b/\346\235\250\345\270\206/\347\237\263\345\244\264\345\211\252\345\210\200\345\270\203/Player.cs" @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp3 +{ + class Player + { + + private string name; + + public Player(string name) + { + this.name = name; + } + public Player() + { + + } + + public string Name { get => name; set => name = value; } + + + public int Move() + { + Console.WriteLine("请出拳:1、石头 2、剪刀 3、布"); + int a = int.Parse(Console.ReadLine()); + return a; + } + } +} diff --git "a/\346\235\250\345\270\206/\347\237\263\345\244\264\345\211\252\345\210\200\345\270\203/Program.cs" "b/\346\235\250\345\270\206/\347\237\263\345\244\264\345\211\252\345\210\200\345\270\203/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..6e266df1ff94f6c4df099de87553e5361afe5c9c --- /dev/null +++ "b/\346\235\250\345\270\206/\347\237\263\345\244\264\345\211\252\345\210\200\345\270\203/Program.cs" @@ -0,0 +1,156 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp3 +{ + class Program + { + static Random r = new Random(); + static Referee referee = new Referee(); + static NPC npc = new NPC(); + static Player player = new Player(); + + static int PlayerSum = 0; + static int NPCSum = 0; + static int Sum = 1; + + static NPC npc1 = new NPC("刘备"); + static NPC npc2 = new NPC("孙权"); + static NPC npc3 = new NPC("曹操"); + static void Main(string[] args) + { + ASD(); + } + static void ASD() + { + Console.WriteLine("************************************"); + Console.WriteLine("*************猜拳,开始*************"); + Console.WriteLine("************************************"); + Console.WriteLine("出拳规则:1、石头 2、剪刀 3、布"); + Console.WriteLine("请选择对手:1、刘备 2、孙权 3、曹操"); + int a = int.Parse(Console.ReadLine()); + Console.WriteLine("请输入您的姓名:"); + string name = Console.ReadLine(); + star(a, name); + } + static void star(int a , string name) + { + while (true) + { + Player player1 = new Player(name); + + switch (a) + { + case 1: + Console.WriteLine("{0} VS {1}", name, npc1.Name); + VS(player1.Name, npc1.Name, player1); + break; + case 2: + Console.WriteLine("{0} VS {1}", name, npc2.Name); + VS(player1.Name, npc1.Name, player1); + break; + case 3: + Console.WriteLine("{0} VS {1}", name, npc3.Name); + VS(player1.Name, npc1.Name, player1); + break; + } + } + + } + static void VS(string name, string NPC, Player player1) + { + int a = player.Move(); + int b = r.Next(1, 4); + while (true) + { + + } + switch (a) + { + case 1: + Console.WriteLine("{0}出石头", player1.Name); + npc.Move(NPC, b); + + break; + case 2: + Console.WriteLine("{0}出剪刀", player1.Name); + npc.Move(NPC, b); + + break; + case 3: + Console.WriteLine("{0}出布", player1.Name); + npc.Move(NPC, b); + + break; + } + if (a == b) + { + Console.WriteLine("平局!"); + } + else if (a == 1 && b == 2 || a == 2 && b == 3 || a == 3 && b == 1) + { + Console.WriteLine("{0}获胜!", player1.Name); + PlayerSum = PlayerSum + 1; + } + else if (a == 1 && b == 3 || a == 2 && b == 1 || a == 3 && b == 2) + { + Console.WriteLine("{0]获胜!", npc.Name); + NPCSum = NPCSum + 1; + } + Console.WriteLine("是否开始下一轮游戏?(y/n)"); + string m = Console.ReadLine(); + if (m == "y") + { + star(a,name); + Sum = Sum + 1; + } + else if( m == "n") + { + Console.WriteLine("======================="); + Console.WriteLine("{0} VS {1}", name, npc1.Name); + Console.WriteLine("对战次数{0}",Sum); + Console.WriteLine("姓名:{0} 得分: {1}",name,PlayerSum); + Console.WriteLine("姓名:{0} 得分: {1}", npc1.Name, NPCSum); + + if (NPCSum > PlayerSum) + { + Console.WriteLine("结果:{0}获胜!", npc1.Name); + } + else if (NPCSum == PlayerSum) + { + Console.WriteLine("结果:平局!"); + } + else + { + Console.WriteLine("结果:{0}获胜!", name); + } + Exit(); + } + else + { + Console.WriteLine("输入错误!"); + } + } + + static void Exit() + { + Console.WriteLine("是否开始下一局游戏?(y/n)"); + string n = Console.ReadLine(); + if (n == "y") + { + ASD(); + PlayerSum = 0; + NPCSum = 0; + Sum = 1; + } + else if (n == "n") + { + Console.WriteLine("游戏结束,按下任意键退出!"); + System.Environment.Exit(0); + } + } + } +} diff --git "a/\346\235\250\345\270\206/\347\237\263\345\244\264\345\211\252\345\210\200\345\270\203/Referee.cs" "b/\346\235\250\345\270\206/\347\237\263\345\244\264\345\211\252\345\210\200\345\270\203/Referee.cs" new file mode 100644 index 0000000000000000000000000000000000000000..06dcec64981b35df0acbc614363a19a1c57721c6 --- /dev/null +++ "b/\346\235\250\345\270\206/\347\237\263\345\244\264\345\211\252\345\210\200\345\270\203/Referee.cs" @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp3 +{ + class Referee + { + public void Battle(int a, int b, string name, string name1, int PlayerSum, int NPCSum) + { + + if (a == b) + { + Console.WriteLine("平局!"); + } + else if (a == 1 && b == 2 || a == 2 && b == 3 || a == 3 && b == 1) + { + Console.WriteLine("{0}获胜!", name); + PlayerSum = PlayerSum + 1; + } + else if (a == 1 && b == 3 || a == 2 && b == 1 || a == 3 && b == 2) + { + Console.WriteLine("{0]获胜!", name1); + NPCSum = NPCSum + 1; + } + } + } +} diff --git "a/\346\235\250\345\270\206/\347\273\223\346\236\204\344\275\223\344\275\234\344\270\232/ASD.cs" "b/\346\235\250\345\270\206/\347\273\223\346\236\204\344\275\223\344\275\234\344\270\232/ASD.cs" new file mode 100644 index 0000000000000000000000000000000000000000..dd8cb4006ee76aa93efc3f0d29c46ad8c83d1257 --- /dev/null +++ "b/\346\235\250\345\270\206/\347\273\223\346\236\204\344\275\223\344\275\234\344\270\232/ASD.cs" @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + + + + class ASD + { + private string name; + private int tel; + private string addess; + + public string Name { get => name; set => name = value; } + public int Tel { get => tel; set => tel = value; } + public string Addess { get => addess; set => addess = value; } + + + public ASD(string name, int tel, string addess) + { + Name = name; + Tel = tel; + Addess = addess; + } + } +} diff --git "a/\346\235\250\345\270\206/\347\273\223\346\236\204\344\275\223\344\275\234\344\270\232/PersonClass.cs" "b/\346\235\250\345\270\206/\347\273\223\346\236\204\344\275\223\344\275\234\344\270\232/PersonClass.cs" new file mode 100644 index 0000000000000000000000000000000000000000..db893a75b3f9847a95664460793471bd82b89170 --- /dev/null +++ "b/\346\235\250\345\270\206/\347\273\223\346\236\204\344\275\223\344\275\234\344\270\232/PersonClass.cs" @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class PersonClass + { + private string name; + private int tel; + private string addess; + + public string Name { get => name; set => name = value; } + public int Tel { get => tel; set => tel = value; } + public string Addess { get => addess; set => addess = value; } + + public PersonClass(string name, int tel, string addess) + { + Name = name; + Tel = tel; + Addess = addess; + } + + + } +} diff --git "a/\346\235\250\345\270\206/\347\273\223\346\236\204\344\275\223\344\275\234\344\270\232/Program.cs" "b/\346\235\250\345\270\206/\347\273\223\346\236\204\344\275\223\344\275\234\344\270\232/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..1c39dead5960daedf4d54977e325f0bd3ed6b032 --- /dev/null +++ "b/\346\235\250\345\270\206/\347\273\223\346\236\204\344\275\223\344\275\234\344\270\232/Program.cs" @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Program + { + struct PersonStruct + { + public string name; + public int tel; + public string addess; + } + + static void Main(string[] args) + { + + PersonStruct p1 = new PersonStruct(); + p1.name = "张三"; + p1.tel = 123456; + p1.addess = "龙岩"; + + PersonStruct p2 = new PersonStruct(); + p2.name = "李四"; + p2.tel = p1.tel; + p2.addess = p1.addess; + + Console.WriteLine("姓名:{0},电话:{1},地址:{2}。",p1.name,p1.tel,p1.addess); + + PersonClass p3 = new PersonClass("王五",456789,"龙岩"); + + PersonClass p4 = new PersonClass("赵六", 456789, "龙岩"); + } + } +} diff --git "a/\346\236\227\344\275\263\345\205\203/\347\237\263\345\244\264\345\211\252\345\210\200\345\270\203\344\275\234\344\270\232/Program.cs" "b/\346\236\227\344\275\263\345\205\203/\347\237\263\345\244\264\345\211\252\345\210\200\345\270\203\344\275\234\344\270\232/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b38751b417c5edda6eacd5594411b3a2c1f1deaa --- /dev/null +++ "b/\346\236\227\344\275\263\345\205\203/\347\237\263\345\244\264\345\211\252\345\210\200\345\270\203\344\275\234\344\270\232/Program.cs" @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("---------欢迎进入游戏世界---------"); + Console.WriteLine("*******************"); + Console.WriteLine("*****猜拳,开始****"); + Console.WriteLine("*******************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Console.WriteLine("请选择对方角色:<1:刘备 2:孙权 3:曹操>"); + int key1 = int.Parse(Console.ReadLine()); + + switch (key1) + { + case 1: + Console.WriteLine("请输入您的姓名:"); + string name1 = Console.ReadLine(); + Console.WriteLine(name1+" vs 刘备 对战"); + while (true) + { + Console.WriteLine("开始游戏吗?"); + string key11 = Console.ReadLine(); + if (key11 == "y") + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布 (输入相应数字:)"); + int key111 = int.Parse(Console.ReadLine()); + if (key111 == 1) + { + Console.WriteLine(name1 + ": 出拳:剪刀"); + Console.WriteLine("刘备:出拳:石头"); + Console.WriteLine("笨蛋," + name1 + "输了"); + } + } + else if (key11 == "n") + { + break; + } + } + break; + default: + break; + } + } + } +} diff --git "a/\346\236\227\344\275\263\345\205\203/\347\273\223\346\236\204\344\275\223\344\275\234\344\270\232/PersonClass.cs" "b/\346\236\227\344\275\263\345\205\203/\347\273\223\346\236\204\344\275\223\344\275\234\344\270\232/PersonClass.cs" new file mode 100644 index 0000000000000000000000000000000000000000..2d2dbeede13e41e457c83e02c79bf56d020e42e6 --- /dev/null +++ "b/\346\236\227\344\275\263\345\205\203/\347\273\223\346\236\204\344\275\223\344\275\234\344\270\232/PersonClass.cs" @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp3 +{ + class PersonClass + { + public string name; + public int telephone; + public string adress; + + public string Name + { + get { return this.name; } + set { this.name = value; } + } + public int Telephone + { + get { return this.telephone; } + set { this.telephone = value; } + } + public string Adress + { + get { return this.adress; } + set { this.adress = value; } + } + public PersonClass() + { + + } + public PersonClass(string xingming, int dianhua, string dizhi) + { + this.Name = xingming; + this.Telephone = dianhua; + this.Adress = dizhi; + } + } +} diff --git "a/\346\236\227\344\275\263\345\205\203/\347\273\223\346\236\204\344\275\223\344\275\234\344\270\232/Program.cs" "b/\346\236\227\344\275\263\345\205\203/\347\273\223\346\236\204\344\275\223\344\275\234\344\270\232/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..fd243c47da3f6ceeb9090ef3cc79df22d5f6ab6d --- /dev/null +++ "b/\346\236\227\344\275\263\345\205\203/\347\273\223\346\236\204\344\275\223\344\275\234\344\270\232/Program.cs" @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +//定义一个结构体,名为PersonStruct,有三个成员变量:姓名、电话、地址, +//在主方法中,创建一个PersonStruct结构体对象p1,为p1的成员变量赋值。 +//再声明一个PersonStruct结构体变量p2,把p1赋值给p2,改变p2的姓名,打印p1的内容。 + +//定义一个类,名为PersonClass,有三个成员变量:姓名、电话、地址, +//在主方法中,创建一个PersonClass对象p3,为p3的成员变量赋值。 +//再声明一个PersonClass变量p4,把p3赋值给p4,改变p4的姓名,打印p3的内容。 + + +//观察打印结果,并在在注释中,说下你对此的认识(它们为什么会这样?) +namespace ConsoleApp3 +{ + class Program + { + struct PersonStruct + { + public String xingming; + public int dianhua; + public string dizhi; + + public PersonStruct(string xingming, int dianhua, string dizhi) + { + this.xingming = xingming; + this.dianhua = dianhua; + this.dizhi = dizhi; + } + } + static void Main(string[] args) + { + PersonStruct p1 = new PersonStruct("小一", 123456, "福建龙岩"); + PersonStruct p2 = new PersonStruct(); + p2 = p1; + p2.xingming = "小二"; + Console.WriteLine(p1.xingming + "\t"+p1.dianhua + "\t"+p1.dizhi); + Console.WriteLine(p2.xingming + "\t" + p2.dianhua + "\t" + p2.dizhi); + + Console.WriteLine("========================="); + + PersonClass p3 = new PersonClass("小三", 4563123, "福建泉州"); + PersonClass p4 = new PersonClass(); + p4 = p3; + p4.name = "小四"; + Console.WriteLine(p3.name+"\t"+p3.telephone+"\t"+p3.adress); + Console.WriteLine(p4.name + "\t" + p4.telephone + "\t" + p4.adress); + } + } +} diff --git "a/\346\242\201\345\220\257\351\221\253/Class1.cs" "b/\346\242\201\345\220\257\351\221\253/Class1.cs" new file mode 100644 index 0000000000000000000000000000000000000000..9cb0b10f06f88c575238d442d3f3e073c4bfc0f9 --- /dev/null +++ "b/\346\242\201\345\220\257\351\221\253/Class1.cs" @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + enum Name + { + 刘备 = 1, + 孙权, + 曹操 + } + enum GuessGame + { + 石头 = 1, + 剪刀, + 布 + } + + class Class1 + { + public string npcname; + public string usename; + + public void check() + { + Class1 class1 = new Class1(); + Type type = typeof(Name); + int e = 1; + Console.Write("出拳规则:"); + foreach (GuessGame item in System .Enum.GetValues(typeof(GuessGame))) + { + Console.Write(e+"."+item+" "); + e++; + } + Console.WriteLine(); + Console.WriteLine("请选择对方角色:1.刘备 2.孙权 3.曹操"); + int b = Convert.ToInt32(Console.ReadLine()); + class1.npcname = type.GetEnumName(b); + Console.WriteLine("请输入你的名字"); + class1.usename = Console.ReadLine(); + Console.WriteLine("{0} VS {1} 对战", class1.usename, class1.npcname); + + } + public virtual void npc() + { } + + + public virtual void use() + { } + + } +} diff --git "a/\346\242\201\345\220\257\351\221\253/Game.cs" "b/\346\242\201\345\220\257\351\221\253/Game.cs" new file mode 100644 index 0000000000000000000000000000000000000000..f10c3821302ca21f6892e17b1d46fc26b88958cb --- /dev/null +++ "b/\346\242\201\345\220\257\351\221\253/Game.cs" @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Game : Class1 + { + protected int npcNum; + protected int useNum; + protected string npcCheck; + protected string useCheck; + + + + public override void npc() + { + Class1 class1 = new Class1(); + Random ran = new Random(); + npcNum = ran.Next(3) + 1; + Type type = typeof(GuessGame); + npcCheck = type.GetEnumName(npcNum); + Console.WriteLine("{0}出拳:{1}", class1.npcname, npcCheck); + } + + public override void use() + { + Class1 class1 = new Class1(); + Console.WriteLine(base.usename); + Console.WriteLine("请出拳:1.石头 2.剪刀 3.布(输入相应数字)"); + useNum = Convert.ToInt32(Console.ReadLine()); + Type type = typeof(GuessGame); + useCheck = type.GetEnumName(useNum); + Console.WriteLine("{0}出拳:{1}", class1.usename, useCheck); + } + } +} diff --git "a/\346\242\201\345\220\257\351\221\253/Judge.cs" "b/\346\242\201\345\220\257\351\221\253/Judge.cs" new file mode 100644 index 0000000000000000000000000000000000000000..d6634685167e50504f372bce8dc55b3ef04dbac1 --- /dev/null +++ "b/\346\242\201\345\220\257\351\221\253/Judge.cs" @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Judge : Game + { + public int useMark = 0; + public int npcMark = 0; + + + + public void judge1() + { + Console.WriteLine(base.useNum); + if ((base.npcNum == 1 & useNum == 2) || (npcNum == 2 & useNum == 3) || (npcNum == 3 & useNum == 1)) + { + Console.WriteLine("{0}输了,啊?九折?", usename); + npcMark++; + } + else if ((npcNum == 2 & useNum == 1) || (npcNum == 3 & useNum == 2) || (npcNum == 1 & useNum == 3)) + { + Console.WriteLine("{0}赢了,我哭了", usename); + useMark++; + } + else if (npcNum == useNum) + { + Console.WriteLine("平局,不服再来"); + } + + } + + } +} diff --git "a/\346\242\201\345\220\257\351\221\253/Program.cs" "b/\346\242\201\345\220\257\351\221\253/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..100285c7923b7c0f9edecd96640f09a64ccb0262 --- /dev/null +++ "b/\346\242\201\345\220\257\351\221\253/Program.cs" @@ -0,0 +1,57 @@ +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) + { + Type type = typeof(Name); + Type type1 = typeof(GuessGame); + + Class1 class1 = new Class1(); + Game game = new Game(); + Judge judge = new Judge(); + YesNo yesNo = new YesNo(); + + Console.WriteLine("**********************************"); + Console.WriteLine("*********** 猜拳,开始 ***********"); + Console.WriteLine("**********************************"); + + class1.check();//选择npc与命名 + yesNo.Play();//是否开始游戏 + if (yesNo.falg) + { + while (yesNo.falg1)//是否继续 + { + game.use();//玩家出拳 + game.npc();//npc出拳 + judge.judge1();//判断输赢 + yesNo.coming();//是否继续 + } + } + + Console.WriteLine("=========结束========="); + Console.WriteLine("{0} VS {1} 对战", class1.usename, class1.npcname); + Console.WriteLine("姓名 得分"); + Console.WriteLine(class1.usename + " " + judge.useMark); + Console.WriteLine(class1.npcname + " " + judge.npcMark); + Console.WriteLine("结果:{0}赢,{1}是笨蛋", class1.usename, class1.npcname); + yesNo.Again(); + if (yesNo.falg2) + { + class1.check();//是否重开游戏 + } + else + { + Console.WriteLine("退出系统"); + } + } + + } +} diff --git "a/\346\242\201\345\220\257\351\221\253/YesNo.cs" "b/\346\242\201\345\220\257\351\221\253/YesNo.cs" new file mode 100644 index 0000000000000000000000000000000000000000..5d813ca63bbb7a34f42166c745cf752907dcd3da --- /dev/null +++ "b/\346\242\201\345\220\257\351\221\253/YesNo.cs" @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class YesNo + { + public Boolean falg = true; + public Boolean falg1 = true; + public Boolean falg2 = false; + public int index = 0; + public void Play() + { + Console.WriteLine("开始游戏吗?(y/n)"); + string check = Console.ReadLine(); + if (check.Equals("n")) + { + falg = false; + } + } + public void coming() + { + Console.WriteLine("是否开始下一轮?(y/n)"); + string check = Console.ReadLine(); + index++; + if (check.Equals("n")) + { + falg1 = false; + } + } + public void Again() + { + Console.WriteLine("继续游戏吗?(y/n)"); + string check = Console.ReadLine(); + if (check.Equals("y")) + { + falg2 = true; + } + } + } +} diff --git "a/\346\242\201\345\220\257\351\221\253/struct/PersonClass.cs" "b/\346\242\201\345\220\257\351\221\253/struct/PersonClass.cs" new file mode 100644 index 0000000000000000000000000000000000000000..0a113d340331b1c48ce1bf2b503e9e8203e1dd01 --- /dev/null +++ "b/\346\242\201\345\220\257\351\221\253/struct/PersonClass.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class PersonClass + { + private string name; + private int phone; + private string a; + + public string Name { get => name; set => name = value; } + public int Phone { get => phone; set => phone = value; } + public string A { get => a; set => a = value; } + + public PersonClass(string name, int phone, string a) + { + this.name = name; + this.phone = phone; + this.a = a; + } + } +} diff --git "a/\346\242\201\345\220\257\351\221\253/struct/Program.cs" "b/\346\242\201\345\220\257\351\221\253/struct/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..adf9ad645a58db522a4758ba9ed473a69e385b1c --- /dev/null +++ "b/\346\242\201\345\220\257\351\221\253/struct/Program.cs" @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + + class Program + { + //定义一个结构体,名为PersonStruct,有三个成员变量:姓名、电话、地址, + //在主方法中,创建一个PersonStruct结构体对象p1,为p1的成员变量赋值。 + //再声明一个PersonStruct结构体变量p2,把p1赋值给p2,改变p2的姓名,打印p1的内容。 + + //定义一个类,名为PersonClass,有三个成员变量:姓名、电话、地址, + //在主方法中,创建一个PersonClass对象p3,为p3的成员变量赋值。 + //再声明一个PersonClass变量p4,把p3赋值给p4,改变p4的姓名,打印p3的内容。 + struct PersonStruct + { + public string name; + public int phone; + public string a; + } + static void Main(string[] args) + { + PersonStruct p1; + p1.name = "杨"; + p1.phone=666; + p1.a = "家"; + PersonStruct p2 = p1; + + p2.name = "???"; + Console.WriteLine(p1.name); + + PersonClass p3 = new PersonClass("杨",999,"家"); + PersonClass p4 = p3; + p4.Name = "!!!"; + Console.WriteLine(p3.Name); + } + } +} diff --git "a/\346\270\251\345\271\277\347\224\237/Class1kobai.cs" "b/\346\270\251\345\271\277\347\224\237/Class1kobai.cs" new file mode 100644 index 0000000000000000000000000000000000000000..52d107fb5a9e58f2b80f65b993cb0d0e90d1a619 --- /dev/null +++ "b/\346\270\251\345\271\277\347\224\237/Class1kobai.cs" @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Class1kobai + { + public static void aa1(){ + Console.WriteLine("--------欢迎进入游戏世界--------"); + Console.WriteLine("****************"); + Console.WriteLine("***猜拳,开始***"); + Console.WriteLine("****************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + } + public static void aa2() { + + + Class1renwu m = new Class1renwu(); + } + } +} diff --git "a/\346\270\251\345\271\277\347\224\237/Class1renwu.cs" "b/\346\270\251\345\271\277\347\224\237/Class1renwu.cs" new file mode 100644 index 0000000000000000000000000000000000000000..39017369935866cfa6709baf1e7a286ad8d4ef92 --- /dev/null +++ "b/\346\270\251\345\271\277\347\224\237/Class1renwu.cs" @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Class1renwu:Program + { + private string name1; + private string name2; + private string name3; + + public string Name1 { get => name1; set => name1 = value; } + public string Name2 { get => name2; set => name2 = value; } + public string Name3 { get => name3; set => name3 = value; } + + public Class1renwu(string name1, string name2, string name3) + { + this.name1 = name1; + this.name2 = name2; + this.name3 = name3; + } + public Class1renwu() { + + } + + public static void bb2() { + int[] arr = new int[1]; + for (int i = 0; i < arr.Length; i++) + { + Random r = new Random(); + arr[i]=r.Next(1, 4); + for (int j = 0; j < i; j++) + { + if (arr[i]==arr[j]) + { + arr[i] = r.Next(1, 4); + } + } + Console.WriteLine(arr[i]); + if (arr[i] == 3) { + Console.WriteLine("布"); + + } else if(arr[i] == 2) + { + Console.WriteLine("石头"); + } + else { + Console.WriteLine("剪刀"); + } + } + } + } +} diff --git "a/\346\270\251\345\271\277\347\224\237/Program.cs" "b/\346\270\251\345\271\277\347\224\237/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b01efcae0fdd38aeae2835b660aff87fd0064f31 --- /dev/null +++ "b/\346\270\251\345\271\277\347\224\237/Program.cs" @@ -0,0 +1,149 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Program + { + enum renwu + { + 刘备=1, + 孙权, + 曹操 + + + } + enum youxi { + 剪刀=1, + 石头, + 布 + + + } + static void Main(string[] args) + { + Class1kobai kobai = new Class1kobai(); + Class1kobai.aa1(); + Console.WriteLine("请选择对方角色(1:刘备 2:孙权 3:曹操)"); + string a = Console.ReadLine(); + renwu jue = (renwu)Enum.Parse(typeof(renwu), a); + Console.WriteLine("请输入您的姓名:"); + string b = Console.ReadLine(); + switch (jue) + { + case renwu.刘备: + Console.WriteLine("{0} VS {1} 对战",b,jue); + Console.WriteLine("开始游戏吗?"); + string c = Console.ReadLine(); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布(输入相应数字:)"); + string x = Console.ReadLine(); + youxi youxi = (youxi)Enum.Parse(typeof(youxi), x); + Class1kobai.aa2(); + switch (youxi) + { + case Program.youxi.剪刀: + + Console.WriteLine("{0};出拳:{1}",b,youxi); + Console.WriteLine("{0};出拳:", jue); + Class1renwu.bb2(); + int sum1 = 1; + int sum2 = 2; + int sum3 = 3; + if () + { + + } + break; + case Program.youxi.石头: + + Console.WriteLine("{0};出拳:{1}", b, youxi); + Console.WriteLine("{0};出拳:", jue); + Class1renwu.bb2(); + break; + case Program.youxi.布: + + Console.WriteLine("{0};出拳:{1}", b, youxi); + Console.WriteLine("{0};出拳:", jue); + Class1renwu.bb2(); + break; + default: + break; + } + break; + case renwu.孙权: + Console.WriteLine("{0} VS {1} 对战", b, jue); + Console.WriteLine("开始游戏吗?"); + string d = Console.ReadLine(); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布(输入相应数字:)"); + string x2 = Console.ReadLine(); + youxi youxi2 = (youxi)Enum.Parse(typeof(youxi), x2); + Class1kobai.aa2(); + switch (youxi2) + { + case Program.youxi.剪刀: + + Console.WriteLine("{0};出拳:{1}", b, youxi2); + Console.WriteLine("{0};出拳:", jue); + Class1renwu.bb2(); + + break; + case Program.youxi.石头: + + Console.WriteLine("{0};出拳:{1}", b, youxi2); + Console.WriteLine("{0};出拳:", jue); + Class1renwu.bb2(); + break; + case Program.youxi.布: + + Console.WriteLine("{0};出拳:{1}", b, youxi2); + Console.WriteLine("{0};出拳:", jue); + Class1renwu.bb2(); + break; + default: + break; + } + break; + + case renwu.曹操: + Console.WriteLine("{0} VS {1} 对战", b, jue); + Console.WriteLine("开始游戏吗?"); + string f= Console.ReadLine(); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布(输入相应数字:)"); + string x3 = Console.ReadLine(); + youxi youxi3 = (youxi)Enum.Parse(typeof(youxi), x3); + Class1kobai.aa2(); + switch (youxi3) + { + case Program.youxi.剪刀: + + Console.WriteLine("{0};出拳:{1}", b, youxi3); + Console.WriteLine("{0};出拳:", jue); + Class1renwu.bb2(); + + break; + case Program.youxi.石头: + + Console.WriteLine("{0};出拳:{1}", b, youxi3); + Console.WriteLine("{0};出拳:", jue); + Class1renwu.bb2(); + break; + case Program.youxi.布: + + Console.WriteLine("{0};出拳:{1}", b, youxi3); + Console.WriteLine("{0};出拳:", jue); + Class1renwu.bb2(); + break; + default: + break; + } + break; + + default: + break; + } + } + } +} diff --git "a/\347\206\212\346\226\207\351\221\253/\347\214\234\346\213\263/Program.cs" "b/\347\206\212\346\226\207\351\221\253/\347\214\234\346\213\263/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..250ed2d748d5b69da8b2705bf039a4f0e337a482 --- /dev/null +++ "b/\347\206\212\346\226\207\351\221\253/\347\214\234\346\213\263/Program.cs" @@ -0,0 +1,421 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp5 +{ + class Program + { + enum Caiquan + { + 剪刀 = 1, + 石头 = 2, + 布 = 3 + } + + static void Main(string[] args) + { + + Random ran = new Random(); + Console.WriteLine("--------------- 欢 迎 进 入 游 戏 世 界 ---------------"); + Console.WriteLine("*********************"); + Console.WriteLine("******猜拳,开始*****"); + Console.WriteLine("*********************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Console.WriteLine("请选择对方角色<1:刘备 2:孙权 3:曹操>"); + int num = int.Parse(Console.ReadLine()); + switch (num) + { + case 1: + Console.WriteLine("你选择了刘备"); + Console.WriteLine("请输入您的姓名:"); + string name = Console.ReadLine(); + Console.WriteLine(name+" VS 刘备 对战"); + Console.WriteLine("开始游戏吗?"); + string a = Console.ReadLine(); + + + if (a == "yes") + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布 (输入相应数字:)"); + int num2 = int.Parse(Console.ReadLine()); + + switch (num2) + { + case 1: + int player = 1; + + Console.WriteLine(name+":出拳:剪刀"); + int b = ran.Next(0, 4); + string strPC = ""; + if (b == 1) + { + strPC = "剪刀"; + } + else if (b == 2) + { + strPC = "石头"; + } + else if (b == 3) + { + strPC = "布"; + } + Console.WriteLine("刘备 :出拳:"+strPC); + int pc = b; + if (player - pc == -2) + { + Console.WriteLine("恭喜," + name + "赢了"); + } + else if (player - pc == -1) + { + Console.WriteLine("八嘎," + name + "输了"); + } + else { + Console.WriteLine("出错"); + } + Console.WriteLine("是否开始下一轮?"); + break; + case 2: + int player2 = 2; + + Console.WriteLine(name + ":出拳:石头"); + int c = ran.Next(0, 4); + string strPC2 = ""; + if (c == 1) + { + strPC = "剪刀"; + } + else if (c == 2) + { + strPC = "石头"; + } + else if (c == 3) + { + strPC = "布"; + } + Console.WriteLine("刘备 :出拳:" + strPC2); + int pc2 = c; + if (player2 - pc2 == 1) + { + Console.WriteLine("恭喜," + name + "赢了"); + } + else if (player2 - pc2 == -1) + { + Console.WriteLine("八嘎," + name + "输了"); + } + else + { + Console.WriteLine("出错"); + } + Console.WriteLine("是否开始下一轮?"); + break; + case 3: + int player3 = 3; + + Console.WriteLine(name + ":出拳:布"); + int d = ran.Next(0, 4); + string strPC3 = ""; + if (d == 1) + { + strPC = "剪刀"; + } + else if (d== 2) + { + strPC = "石头"; + } + else if (d == 3) + { + strPC = "布"; + } + Console.WriteLine("刘备 :出拳:" + strPC3); + int pc3 = d; + if (player3 - pc3 == 1) + { + Console.WriteLine("恭喜," + name + "赢了"); + } + else if (player3 - pc3 == 2) + { + Console.WriteLine("八嘎," + name + "输了"); + } + else + { + Console.WriteLine("出错"); + } + Console.WriteLine("是否开始下一轮?"); + break; + default: + break; + } + } else if (a=="no") + { + Console.WriteLine("系统退出"); + break; + } + break; + case 2: + Console.WriteLine("你选择了孙权"); + Console.WriteLine("请输入您的姓名:"); + string name2 = Console.ReadLine(); + Console.WriteLine(name2 + " VS 孙权 对战"); + Console.WriteLine("开始游戏吗?"); + string e = Console.ReadLine(); + + + if (e == "yes") + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布 (输入相应数字:)"); + int num2 = int.Parse(Console.ReadLine()); + + switch (num2) + { + case 1: + int player = 1; + + Console.WriteLine(name2 + ":出拳:剪刀"); + int b = ran.Next(0, 4); + string strPC = ""; + if (b == 1) + { + strPC = "剪刀"; + } + else if (b == 2) + { + strPC = "石头"; + } + else if (b == 3) + { + strPC = "布"; + } + Console.WriteLine("孙权 :出拳:" + strPC); + int pc = b; + if (player - pc == -2) + { + Console.WriteLine("恭喜," + name2 + "赢了"); + } + else if (player - pc == -1) + { + Console.WriteLine("八嘎," + name2 + "输了"); + } + else + { + Console.WriteLine("出错"); + } + Console.WriteLine("是否开始下一轮?"); + break; + case 2: + int player2 = 2; + + Console.WriteLine(name2 + ":出拳:石头"); + int c = ran.Next(0, 4); + string strPC2 = ""; + if (c == 1) + { + strPC = "剪刀"; + } + else if (c == 2) + { + strPC = "石头"; + } + else if (c == 3) + { + strPC = "布"; + } + Console.WriteLine("孙权 :出拳:" + strPC2); + int pc2 = c; + if (player2 - pc2 == 1) + { + Console.WriteLine("恭喜," + name2 + "赢了"); + } + else if (player2 - pc2 == -1) + { + Console.WriteLine("八嘎," + name2 + "输了"); + } + else + { + Console.WriteLine("出错"); + } + Console.WriteLine("是否开始下一轮?"); + break; + case 3: + int player3 = 3; + + Console.WriteLine(name2 + ":出拳:布"); + int d = ran.Next(0, 4); + string strPC3 = ""; + if (d == 1) + { + strPC = "剪刀"; + } + else if (d == 2) + { + strPC = "石头"; + } + else if (d == 3) + { + strPC = "布"; + } + Console.WriteLine("孙权 :出拳:" + strPC3); + int pc3 = d; + if (player3 - pc3 == 1) + { + Console.WriteLine("恭喜," + name2 + "赢了"); + } + else if (player3 - pc3 == 2) + { + Console.WriteLine("八嘎," + name2 + "输了"); + } + else + { + Console.WriteLine("出错"); + } + Console.WriteLine("是否开始下一轮?"); + break; + default: + break; + } + } + else if (e == "no") + { + Console.WriteLine("系统退出"); + break; + } + break; + case 3: + Console.WriteLine("你选择了曹操"); + Console.WriteLine("请输入您的姓名:"); + string name3 = Console.ReadLine(); + Console.WriteLine(name3 + " VS 曹操 对战"); + Console.WriteLine("开始游戏吗?"); + string r = Console.ReadLine(); + + + if (r == "yes") + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布 (输入相应数字:)"); + int num2 = int.Parse(Console.ReadLine()); + + switch (num2) + { + case 1: + int player = 1; + + Console.WriteLine(name3 + ":出拳:剪刀"); + int b = ran.Next(0, 4); + string strPC = ""; + if (b == 1) + { + strPC = "剪刀"; + } + else if (b == 2) + { + strPC = "石头"; + } + else if (b == 3) + { + strPC = "布"; + } + Console.WriteLine("曹操 :出拳:" + strPC); + int pc = b; + if (player - pc == -2) + { + Console.WriteLine("恭喜," + name3+ "赢了"); + } + else if (player - pc == -1) + { + Console.WriteLine("八嘎," + name3+ "输了"); + } + else + { + Console.WriteLine("出错"); + } + Console.WriteLine("是否开始下一轮?"); + break; + case 2: + int player2 = 2; + + Console.WriteLine(name3 + ":出拳:石头"); + int c = ran.Next(0, 4); + string strPC2 = ""; + if (c == 1) + { + strPC = "剪刀"; + } + else if (c == 2) + { + strPC = "石头"; + } + else if (c == 3) + { + strPC = "布"; + } + Console.WriteLine("曹操:出拳:" + strPC2); + int pc2 = c; + if (player2 - pc2 == 1) + { + Console.WriteLine("恭喜," + name3 + "赢了"); + } + else if (player2 - pc2 == -1) + { + Console.WriteLine("八嘎," + name3 + "输了"); + } + else + { + Console.WriteLine("出错"); + } + Console.WriteLine("是否开始下一轮?"); + break; + case 3: + int player3 = 3; + + Console.WriteLine(name3 + ":出拳:布"); + int d = ran.Next(0, 4); + string strPC3 = ""; + if (d == 1) + { + strPC = "剪刀"; + } + else if (d == 2) + { + strPC = "石头"; + } + else if (d == 3) + { + strPC = "布"; + } + Console.WriteLine("曹操 :出拳:" + strPC3); + int pc3 = d; + if (player3 - pc3 == 1) + { + Console.WriteLine("恭喜," + name3 + "赢了"); + } + else if (player3 - pc3 == 2) + { + Console.WriteLine("八嘎," + name3+ "输了"); + } + else + { + Console.WriteLine("出错"); + } + Console.WriteLine("是否开始下一轮?"); + break; + default: + break; + } + } + else if (r == "no") + { + Console.WriteLine("系统退出"); + break; + } + break; + break; + break; + default: + break; + } + } + + } +} diff --git "a/\347\206\212\346\226\207\351\221\253/\347\273\223\346\236\204\344\275\223/PersonClass.cs" "b/\347\206\212\346\226\207\351\221\253/\347\273\223\346\236\204\344\275\223/PersonClass.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b7537765dd941926f9f6c58b5df8e45b0246bdbc --- /dev/null +++ "b/\347\206\212\346\226\207\351\221\253/\347\273\223\346\236\204\344\275\223/PersonClass.cs" @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp4 +{ + class PersonClass + { + public PersonClass() + { + } + private string name; + private string telephone; + private string area; + public PersonClass(string name, string telephone,string area) + { + this.name = name; + this.telephone = telephone; + this.area = area; + } + public string Name { get => name; set => name = value; } + public string Telephone { get => telephone; set => telephone = value; } + public string Area { get => area; set => area = value; } + } +} diff --git "a/\347\206\212\346\226\207\351\221\253/\347\273\223\346\236\204\344\275\223/Program.cs" "b/\347\206\212\346\226\207\351\221\253/\347\273\223\346\236\204\344\275\223/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..e89c3d2d45340834a8664a391ad913bc77d98b9d --- /dev/null +++ "b/\347\206\212\346\226\207\351\221\253/\347\273\223\346\236\204\344\275\223/Program.cs" @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp4 +{ + class Program + { + public struct PersonStruct + { + public string name; + public string telephone; + public string area; + } + static void Main(string[] args) + { + PersonStruct p1 = new PersonStruct(); + p1.name = "卢本伟"; + p1.telephone = "13174560712"; + p1.area = "地球"; + + PersonStruct p2 = new PersonStruct(); + p2 = p1; + p2.name = "刘谋"; + Console.WriteLine("p1.name="+p1.name+"\t" + + "p1.telephone=" + +p1.telephone+"\t"+"p1.area="+p1.area); + + PersonClass p3 = new PersonClass(); + p3.Name = "粉红豹"; + p3.Telephone = "110"; + p3.Area = "你心里"; + + PersonClass p4 = new PersonClass(); + p4 = p3; + p4.Name = "粉红豹无了"; + Console.WriteLine("p3.name=" + p3.Name + "\t" + + "p3.telephone=" + + p3.Telephone + "\t" + "p3.area=" + p3.Area); + + } + } +} diff --git "a/\347\216\213\351\200\270\351\243\236/Program.cs" "b/\347\216\213\351\200\270\351\243\236/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..048662d7f9d170344dc2579be9df54fcedad01ad --- /dev/null +++ "b/\347\216\213\351\200\270\351\243\236/Program.cs" @@ -0,0 +1,286 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 剪刀石头布 +{ + class Program + { + static void Main(string[] args) + { + comper comper = new comper(); + + + string cc = "曹操"; + string lb = "刘备"; + string sq = "孙权"; + Console.WriteLine("*********猜拳开始***********"); + Console.WriteLine("出拳规则:1.剪刀2.石头3.布(输入相对应数字)"); + Console.WriteLine("请选择对象角色1.刘备2.孙权3.曹操"); + int num = int.Parse(Console.ReadLine()); + switch (num) + { + case 1: + Console.WriteLine("请输入你的姓名"); + string name = Console.ReadLine(); + Console.WriteLine(name+"vs 刘备 对战"); + Console.WriteLine("开始对战吗?(y/n)"); + string kaishi = Console.ReadLine(); + if (kaishi == "y") + { + while (true) + { + Console.WriteLine("请出拳:1.剪刀2.石头3.布(输入相对应数字)"); + int a = int.Parse(Console.ReadLine()); + switch (a) + { + case 1: + Console.WriteLine(name + ":出拳:剪刀"); + Console.WriteLine("刘备:" + "出拳 :" + comper.ShowFist()); + if (comper.ShowFist() == "剪刀") + { + Console.WriteLine("平局"); + } + else if (comper.ShowFist() == "石头") + { + Console.WriteLine("刘备胜"); + } + else if (comper.ShowFist() == "布") + { + Console.WriteLine(name + "胜"); + } + break; + case 2: + Console.WriteLine(name + ":出拳:石头"); + Console.WriteLine("刘备:" + "出拳 :" + comper.ShowFist()); + if (comper.ShowFist() == "剪刀") + { + Console.WriteLine(name + "胜"); + } + else if (comper.ShowFist() == "石头") + { + Console.WriteLine("平局"); + } + else if (comper.ShowFist() == "布") + { + Console.WriteLine("刘备胜"); + } + break; + case 3: + Console.WriteLine(name + ":出拳:布"); + Console.WriteLine("刘备:" + "出拳 :" + comper.ShowFist()); + if (comper.ShowFist() == "剪刀") + { + Console.WriteLine("刘备胜"); + } + else if (comper.ShowFist() == "石头") + { + Console.WriteLine(name + "胜"); + } + else if (comper.ShowFist() == "布") + { + Console.WriteLine("平局"); + } + break; + + } + Console.WriteLine("是否继续()y/n"); + string jixu = Console.ReadLine(); + if (jixu=="n") + { + break; + } + } + } + + + + else if (kaishi == "n") + { + + } + else + { + Console.WriteLine("错了,不打就算了"); + } + break; + + + case 2: + Console.WriteLine("请输入你的姓名"); + string name2 = Console.ReadLine(); + Console.WriteLine(name2 + "vs 孙权 对战"); + Console.WriteLine("开始对战吗?(y/n)"); + string kaishi2 = Console.ReadLine(); + if (kaishi2 == "y") + { + while (true) + { + + + Console.WriteLine("请出拳:1.剪刀2.石头3.布(输入相对应数字)"); + int a = int.Parse(Console.ReadLine()); + switch (a) + { + case 1: + Console.WriteLine(name2 + ":出拳:剪刀"); + Console.WriteLine("孙权:" + "出拳 :" + comper.ShowFist()); + if (comper.ShowFist() == "剪刀") + { + Console.WriteLine("平局"); + } + else if (comper.ShowFist() == "石头") + { + Console.WriteLine("孙权"); + } + else if (comper.ShowFist() == "布") + { + Console.WriteLine(name2 + "胜"); + } + break; + case 2: + Console.WriteLine(name2 + ":出拳:石头"); + Console.WriteLine("孙权:" + "出拳 :" + comper.ShowFist()); + if (comper.ShowFist() == "剪刀") + { + Console.WriteLine(name2 + "胜"); + } + else if (comper.ShowFist() == "石头") + { + Console.WriteLine("平局"); + } + else if (comper.ShowFist() == "布") + { + Console.WriteLine("孙权胜"); + } + break; + case 3: + Console.WriteLine(name2 + ":出拳:布"); + Console.WriteLine("孙权:" + "出拳 :" + comper.ShowFist()); + if (comper.ShowFist() == "剪刀") + { + Console.WriteLine("孙权胜"); + } + else if (comper.ShowFist() == "石头") + { + Console.WriteLine(name2 + "胜"); + } + else if (comper.ShowFist() == "布") + { + Console.WriteLine("平局"); + } + break; + + } + Console.WriteLine("是否继续()y/n"); + string jixu = Console.ReadLine(); + if (jixu == "n") + { + break; + } + } + } + else if (kaishi2 == "n") + { + + } + else + { + Console.WriteLine("错了,不打就算了"); + } + break; + + break; + case 3: + Console.WriteLine("请输入你的姓名"); + string name3 = Console.ReadLine(); + Console.WriteLine(name3 + "vs 曹操 对战"); + Console.WriteLine("开始对战吗?(y/n)"); + string kaishi3 = Console.ReadLine(); + if (kaishi3 == "y") + { + while (true) + { + + + Console.WriteLine("请出拳:1.剪刀2.石头3.布(输入相对应数字)"); + int a = int.Parse(Console.ReadLine()); + switch (a) + { + case 1: + Console.WriteLine(name3 + ":出拳:剪刀"); + Console.WriteLine("曹操:" + "出拳 :" + comper.ShowFist()); + if (comper.ShowFist() == "剪刀") + { + Console.WriteLine("平局"); + } + else if (comper.ShowFist() == "石头") + { + Console.WriteLine("曹操胜"); + } + else if (comper.ShowFist() == "布") + { + Console.WriteLine(name3 + "胜"); + } + break; + case 2: + Console.WriteLine(name3 + ":出拳:石头"); + Console.WriteLine("曹操:" + "出拳 :" + comper.ShowFist()); + if (comper.ShowFist() == "剪刀") + { + Console.WriteLine(name3 + "胜"); + } + else if (comper.ShowFist() == "石头") + { + Console.WriteLine("平局"); + } + else if (comper.ShowFist() == "布") + { + Console.WriteLine("曹操胜"); + } + break; + case 3: + Console.WriteLine(name3 + ":出拳:布"); + Console.WriteLine("曹操:" + "出拳 :" + comper.ShowFist()); + if (comper.ShowFist() == "剪刀") + { + Console.WriteLine("曹操胜"); + } + else if (comper.ShowFist() == "石头") + { + Console.WriteLine(name3 + "胜"); + } + else if (comper.ShowFist() == "布") + { + Console.WriteLine("平局"); + } + break; + } + Console.WriteLine("是否继续()y/n"); + string jixu = Console.ReadLine(); + if (jixu == "n") + { + break; + } + } + + + } + else if (kaishi3 == "n") + { + + } + else + { + Console.WriteLine("错了,不打就算了"); + } + break; + + default: + break; + } + } + } +} diff --git "a/\347\216\213\351\200\270\351\243\236/comper.cs" "b/\347\216\213\351\200\270\351\243\236/comper.cs" new file mode 100644 index 0000000000000000000000000000000000000000..0c46a5c435ec3fddaa985178fd0f59970a9335ff --- /dev/null +++ "b/\347\216\213\351\200\270\351\243\236/comper.cs" @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 剪刀石头布 +{ + class comper + { + public string com + { + get; + set; + } + + + public string ShowFist() + { + Random rnd = new Random(); + int fist = rnd.Next(1, 4); + if (fist==1) + { + com = "剪刀"; + } + else if (fist==2) + { + com = "石头"; + } + else if (true) + { + com = "布"; + } + return com; + } + } +} diff --git "a/\347\275\227\344\273\225\345\244\251/Chp02.csproj" "b/\347\275\227\344\273\225\345\244\251/Chp02.csproj" new file mode 100644 index 0000000000000000000000000000000000000000..69ca2498a085e84ef63a0647a7d10b66a2004c17 --- /dev/null +++ "b/\347\275\227\344\273\225\345\244\251/Chp02.csproj" @@ -0,0 +1,56 @@ + + + + + Debug + AnyCPU + {AA5821C2-A837-424C-9E74-141BF4D97F9B} + Exe + Chp02 + Chp02 + v4.7.2 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/\347\275\227\344\273\225\345\244\251/Comperter.cs" "b/\347\275\227\344\273\225\345\244\251/Comperter.cs" new file mode 100644 index 0000000000000000000000000000000000000000..4e0d5352fc648878bf7d3520bb1129f43a4f0386 --- /dev/null +++ "b/\347\275\227\344\273\225\345\244\251/Comperter.cs" @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Computer + { + enum box + { 剪刀 = 1, 石头, 布 } + public int sj() + { + Random ra = new Random(); + int a = ra.Next(1,4); + return a; + } + } +} + + + + + diff --git "a/\347\275\227\344\273\225\345\244\251/Judgment.cs" "b/\347\275\227\344\273\225\345\244\251/Judgment.cs" new file mode 100644 index 0000000000000000000000000000000000000000..4e0061a7e35075c274b69c78a9f61a61b0e07f72 --- /dev/null +++ "b/\347\275\227\344\273\225\345\244\251/Judgment.cs" @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Judgment + { + enum box + { 剪刀 = 1, 石头, 布 } + + private string perName; + private string computerName; + private int perNum; + private int comNum; + + + public string PerName { get => perName; set => perName = value; } + public string ComputerName { get => computerName; set => computerName = value; } + public int PerNum { get => perNum; set => perNum = value; } + public int ComNum { get => comNum; set => comNum = value; } + + public void ju() + { + if (perNum>comNum) + { + Console.WriteLine("{0} 出拳:{1}",this.perName,(box)(this.perNum)); + Console.WriteLine("{0} 出拳:{1}", this.computerName, (box)(this.ComNum)); + Console.WriteLine("{0}输了",this.computerName); + } + else if (perNum j.ComNum) + { + + a++; + + } + else if (j.PerNum < j.ComNum) + { + b++; + } + else + { + + } + sa(j, p, comparer); + } + else + { + Console.WriteLine("{0} VS {1}", j.PerName, j.ComputerName); + Console.WriteLine("对战次数:{0}", sum); + Console.WriteLine(); + Console.WriteLine("姓名 得分"); + Console.WriteLine("{0} {1}", j.PerName, a); + Console.WriteLine("{0} {1}", j.ComputerName, b); + if (a > b) + { + Console.WriteLine("结果:{0} 赢了", j.PerName); + + + } + else + { + Console.WriteLine("结果:{0} 赢了", j.ComputerName); + } + } + } + + } +} diff --git "a/\347\275\227\346\265\252\345\255\220/.keep" "b/\347\275\227\346\265\252\345\255\220/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\275\227\346\265\252\345\255\220/Program.cs" "b/\347\275\227\346\265\252\345\255\220/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..8d568abac75481d2807afabeb1fa61655c4dbe15 --- /dev/null +++ "b/\347\275\227\346\265\252\345\255\220/Program.cs" @@ -0,0 +1,144 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Program + { + + enum enrole + { + 刘备 = 1, + 孙权 = 2, + 曹操 = 3 + } + enum enMora + { + 石头 = 1, + 剪刀 = 2, + 布 = 3 + } + static void Main(string[] args) + { + //人物类 出的选型类 + + Console.WriteLine("-----------欢迎进入游戏世界-----------" + "\n"); + Console.WriteLine("************************"); + Console.WriteLine("********猜拳开始********"); + Console.WriteLine("************************"); + Console.WriteLine("出拳规则:1.剪刀2.石头3.布"); + Console.WriteLine("请选择对方的角色(1:刘备2.孙权3.曹操)"); + int numname = int.Parse(Console.ReadLine()); + string npcstr = Enum.GetName(typeof(enrole), numname); //NPC姓名 npcstr + + Role role = new Role(npcstr); //获取名字后传入类重写 + Console.WriteLine("请输入您的姓名"); // 玩家姓名 playname + string playname = Console.ReadLine(); + + Console.WriteLine(playname + " VS " + npcstr); + + Console.WriteLine("是否开始游戏(y/n)"); + char char1 = Convert.ToChar(Console.ReadLine()); + if (char1 == 'y' || char1 == 'Y') + { + WinMora(role, npcstr, playname); + + } + else if(char1 == 'n' || char1 == 'N') + { + Console.WriteLine("退出游戏"); + } + Console.WriteLine("要开始下一局游戏吗?(y/n)"); + char char3 = Convert.ToChar(Console.ReadLine()); + if (char3 == 'y' || char3 == 'Y') + { + WinMora(role, npcstr, playname); + + } + else if (char3 == 'n' || char3 == 'N') + { + Console.WriteLine("退出程序"); + System.Environment.Exit(0); + } + } + + private static void WinMora(Role role, string npcstr, string playname) + { + + + int draw = 0; + int NPCwin = 0; + int Playwin = 0; + + while (true) + { + Console.WriteLine("请出拳1.石头2.剪刀3.布请输入数字(请输入相应的数字)"); + int Moranum = int.Parse(Console.ReadLine()); + string playMora = Enum.GetName(typeof(enMora), Moranum); //获取用户输入的数字转化为相应的枚举里的值 + + Console.WriteLine(playname + " : 出拳: " + playMora); + role.Write(); + + if (role.StrMora == playMora) + { + Console.WriteLine("平局,放你一马"); + draw = draw + 1; + } + else if (playMora == "石头" && role.StrMora == "剪刀" || playMora == "布" && role.StrMora == "石头" || playMora == "剪刀" && role.StrMora == "布") + { + Console.WriteLine("恭喜您,勇夺三军,天下无双"); + Playwin = Playwin + 1; + } + else if (role.StrMora == "剪刀" && playMora == "布" || role.StrMora == "石头" && playMora == "剪刀" || role.StrMora == "布" && playMora == "石头") + { + Console.WriteLine("天啦噜,难以置信,这也会输"); + NPCwin = NPCwin + 1; + } + else if (playMora != "石头" || playMora != "剪刀" || playMora != "布") + { + NPCwin = NPCwin + 1; + Console.WriteLine("玩家,出拳不符合规则默认判负"); + } + + Console.WriteLine("是否开始下一局(y/n)"); + char char2 = Convert.ToChar(Console.ReadLine()); + if (char2 == 'y' || char2 == 'Y') + { + + } + else if(char2 == 'n' || char2 == 'N') + { + Console.WriteLine("结束游戏"); + Console.WriteLine("==========================="); + Console.WriteLine(playname + " VS " + npcstr); + Console.WriteLine("对战次数" + (Playwin + NPCwin + draw)); + Console.WriteLine("姓名 得分"); + Console.WriteLine($"{playname} {Playwin}"); + Console.WriteLine($"{npcstr} {NPCwin}"); + if (Playwin > NPCwin) + { + Console.WriteLine( "玩家 "+playname+" 胜出,举世同庆"); + } + else if (NPCwin > Playwin) + { + Console.WriteLine( "电脑"+ npcstr+"胜出,棋差一手"); + } + else + { + Console.WriteLine("平局"); + } + break; + } + + + } + } + } + + +} + + diff --git "a/\347\275\227\346\265\252\345\255\220/Role.cs" "b/\347\275\227\346\265\252\345\255\220/Role.cs" new file mode 100644 index 0000000000000000000000000000000000000000..2970a348aa51a9de886523e6d5e30f4896d4161f --- /dev/null +++ "b/\347\275\227\346\265\252\345\255\220/Role.cs" @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Role + { + private string name; + private string strmora; + public string Name { get; set; } + public string StrMora + { + get { return this.strmora; } + set { this.strmora=value; } + + } + + public Role(string name) + { + this.Name = name; + } + public void Test(string strmora) + { + + Random random = new Random(); + + + if (random.Next(1, 4) == 1) + { + strmora = "石头"; + } + else if (random.Next(1, 4) == 2) + { + strmora = "布"; + } + else if (random.Next(1, 4) == 3) + { + strmora = "剪刀"; + } + + this.StrMora = strmora; + + + } + public void Write() + { + Test(strmora); + StrMora = strmora; + Console.WriteLine("{0}: 出拳 :{1}",Name, StrMora); + + + } + + } +} diff --git "a/\350\224\241\344\270\234\347\224\237/.keep" "b/\350\224\241\344\270\234\347\224\237/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\350\224\241\344\270\234\347\224\237/Program.cs" "b/\350\224\241\344\270\234\347\224\237/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..abd9f944c1474599544da21c1f1b680889143010 --- /dev/null +++ "b/\350\224\241\344\270\234\347\224\237/Program.cs" @@ -0,0 +1,222 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Program + { + static int sum; + static int shu; + static int ying; + static int ping; + struct juese + { + public string name; + public string name1; + public string name2; + + } + struct caijuan + { + public string jiandao; + public string shitou; + public string bu; + + } + + static void Main(string[] args) + { + + Text1(); + } + public static void Text1() + { + Console.WriteLine("游戏开始"); + caijuan cq = new caijuan(); + cq.shitou = "石头"; + cq.jiandao = "剪刀"; + cq.bu = "布"; + juese js = new juese(); + js.name = "黑"; + js.name1 = "白"; + js.name2 = "空"; + + Console.WriteLine("出拳规则:{0},{1},{2}", cq.shitou, cq.jiandao, cq.bu); + Console.WriteLine("请选择对方角色:{0},{1},{2}", js.name, js.name1, js.name2); + string key = Console.ReadLine(); + Console.WriteLine("请输入你的姓名"); + string ming = Console.ReadLine(); + switch (key) + { + case "黑": + Text2(); + break; + case "白": + Text2(); + break; + case "空": + Text2(); + break; + default: + Text2(); + break; + } + + } + public static void Text6() + { + Console.WriteLine("是否开始下一轮"); + int a = int.Parse(Console.ReadLine()); + switch (a) + { + case 1: + Text2(); + break; + case 2: + Console.WriteLine("次数{0}", sum); + Console.WriteLine("赢次数{0}", ying); + Console.WriteLine("输次数{0}", shu); + Console.WriteLine("平次数{0}", ping); + if (ying>shu) + { + Console.WriteLine("九龙拉棺,泰山封禅"); + } + if ( shu name; set => name = value; } + public string Dianhua { get => dianhua; set => dianhua = value; } + public int Dizhi { get => dizhi; set => dizhi = value; } + + } +} diff --git "a/\350\224\241\344\270\234\347\224\237/\347\273\223\346\236\204\344\275\223/Program.cs" "b/\350\224\241\344\270\234\347\224\237/\347\273\223\346\236\204\344\275\223/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..fc85eac4dffc841b5029c87cc46587fc8c6dae8e --- /dev/null +++ "b/\350\224\241\344\270\234\347\224\237/\347\273\223\346\236\204\344\275\223/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 + { + public struct PersonStruct { + public string name; + public string dianhua; + public int dizhi; + + + + } + static void Main(string[] args) + { + + PersonStruct p1 = new PersonStruct(); + p1.name = "呵呵"; + PersonStruct p2= new PersonStruct(); + p2.name = p1.name; + p2.name = "傻傻"; + PersonClass p3 = new PersonClass(); + p3.Name = "思思"; + PersonClass p4 = new PersonClass(); + p4.Name = p3.Name; + p4.Name = "所谓的哈"; + Console.WriteLine(p1.name); + Console.WriteLine(p2.name); + Console.WriteLine(p3.Name); + Console.WriteLine(p4.Name); + Console.ReadKey(); + + } + } +} diff --git "a/\350\224\241\345\256\227\351\225\207/Chp02.csproj" "b/\350\224\241\345\256\227\351\225\207/Chp02.csproj" new file mode 100644 index 0000000000000000000000000000000000000000..69ca2498a085e84ef63a0647a7d10b66a2004c17 --- /dev/null +++ "b/\350\224\241\345\256\227\351\225\207/Chp02.csproj" @@ -0,0 +1,56 @@ + + + + + Debug + AnyCPU + {AA5821C2-A837-424C-9E74-141BF4D97F9B} + Exe + Chp02 + Chp02 + v4.7.2 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/\350\224\241\345\256\227\351\225\207/Comperter.cs" "b/\350\224\241\345\256\227\351\225\207/Comperter.cs" new file mode 100644 index 0000000000000000000000000000000000000000..4e0d5352fc648878bf7d3520bb1129f43a4f0386 --- /dev/null +++ "b/\350\224\241\345\256\227\351\225\207/Comperter.cs" @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Computer + { + enum box + { 剪刀 = 1, 石头, 布 } + public int sj() + { + Random ra = new Random(); + int a = ra.Next(1,4); + return a; + } + } +} + + + + + diff --git "a/\350\224\241\345\256\227\351\225\207/Judgment.cs" "b/\350\224\241\345\256\227\351\225\207/Judgment.cs" new file mode 100644 index 0000000000000000000000000000000000000000..4e0061a7e35075c274b69c78a9f61a61b0e07f72 --- /dev/null +++ "b/\350\224\241\345\256\227\351\225\207/Judgment.cs" @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Judgment + { + enum box + { 剪刀 = 1, 石头, 布 } + + private string perName; + private string computerName; + private int perNum; + private int comNum; + + + public string PerName { get => perName; set => perName = value; } + public string ComputerName { get => computerName; set => computerName = value; } + public int PerNum { get => perNum; set => perNum = value; } + public int ComNum { get => comNum; set => comNum = value; } + + public void ju() + { + if (perNum>comNum) + { + Console.WriteLine("{0} 出拳:{1}",this.perName,(box)(this.perNum)); + Console.WriteLine("{0} 出拳:{1}", this.computerName, (box)(this.ComNum)); + Console.WriteLine("{0}输了",this.computerName); + } + else if (perNum j.ComNum) + { + + a++; + + } + else if (j.PerNum < j.ComNum) + { + b++; + } + else + { + + } + sa(j, p, comparer); + } + else + { + Console.WriteLine("{0} VS {1}", j.PerName, j.ComputerName); + Console.WriteLine("对战次数:{0}", sum); + Console.WriteLine(); + Console.WriteLine("姓名 得分"); + Console.WriteLine("{0} {1}", j.PerName, a); + Console.WriteLine("{0} {1}", j.ComputerName, b); + if (a > b) + { + Console.WriteLine("结果:{0} 赢了", j.PerName); + + + } + else + { + Console.WriteLine("结果:{0} 赢了", j.ComputerName); + } + } + } + + } +} diff --git "a/\350\256\270\345\237\271\346\250\237/\347\214\234\346\213\263/Game.cs" "b/\350\256\270\345\237\271\346\250\237/\347\214\234\346\213\263/Game.cs" new file mode 100644 index 0000000000000000000000000000000000000000..75a41929b179066e8afe8d5f11e7d5f3b332bc61 --- /dev/null +++ "b/\350\256\270\345\237\271\346\250\237/\347\214\234\346\213\263/Game.cs" @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp4 +{ + class Game + { + public enum guess + { + 石头 = 1, + 剪刀 = 2, + 布 = 3 + } + + public string name { get; set; } + public string name1 { get; set; } + + public Game(string name, string name1) + { + this.name = name; + this.name1 = name1; + } + + public virtual guess Guess() + { + Random red = new Random(); + int key = red.Next(1, 4); + guess g = (guess)key; + return g; + } + } +} diff --git "a/\350\256\270\345\237\271\346\250\237/\347\214\234\346\213\263/Npc.cs" "b/\350\256\270\345\237\271\346\250\237/\347\214\234\346\213\263/Npc.cs" new file mode 100644 index 0000000000000000000000000000000000000000..11fe9ba512b070ac9b85d43304c027632c8929f8 --- /dev/null +++ "b/\350\256\270\345\237\271\346\250\237/\347\214\234\346\213\263/Npc.cs" @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp4 +{ + class Npc : Game + { + public Npc(string name, string name1) : base(name, name1) + { + + } + + + public void talk1() + { + Console.Write("{name1}: 出拳:"); + Console.WriteLine(Guess()); + } + + } +} diff --git "a/\350\256\270\345\237\271\346\250\237/\347\214\234\346\213\263/Player.cs" "b/\350\256\270\345\237\271\346\250\237/\347\214\234\346\213\263/Player.cs" new file mode 100644 index 0000000000000000000000000000000000000000..c4c7c4bd4600d3b1019edd8c1412aad7a57f2c7f --- /dev/null +++ "b/\350\256\270\345\237\271\346\250\237/\347\214\234\346\213\263/Player.cs" @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp4 +{ + class Player : Game + { + public Player(string name, string name1) : base(name, name1) + { + + } + public int key; + public void talk1() + { + Console.WriteLine("请出拳:{0}", Guess1()); + key = int.Parse(Console.ReadLine()); + Console.Write($"{0}: 出拳:",name); + Console.WriteLine(Guess()); + } + public override guess Guess() + { + + guess g = (guess)key; + return g; + } + static string Guess1() + { + string str = null; + int i = 1; + foreach (guess t in Enum.GetValues(typeof(guess))) + { + str += $"{i}、{t} "; + i++; + } + return str; + } + } +} diff --git "a/\350\256\270\345\237\271\346\250\237/\347\214\234\346\213\263/Program.cs" "b/\350\256\270\345\237\271\346\250\237/\347\214\234\346\213\263/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..2c9148408badd953171cd9609d479b8e3c65814e --- /dev/null +++ "b/\350\256\270\345\237\271\346\250\237/\347\214\234\346\213\263/Program.cs" @@ -0,0 +1,99 @@ +using ConsoleApp1; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp4 +{ + class Program + { + static void Main(string[] args) + { + + Console.WriteLine("------欢迎进入游戏世界------"); + 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.Write("请输入您的姓名:"); + string 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: + break; + } + } + + private static void Go(string a, string b) + { + Npc nPC = new Npc(a, b); + Player user = new Player(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.talk1(); + int f = (int)user.Guess(); + int i = (int)nPC.Guess(); + + NextRound(nPC,user); + } + else if (key == ('n' | 'N')) + { + + Environment.Exit(0); + NextRound(nPC, user); + + } + else + { + Console.WriteLine("选择出错!自动退出"); + Environment.Exit(0); + } + + } + + + public static void NextRound(Npc nPC, Player user) + { + Referee referee = new Referee(); + Console.WriteLine("是否开始下一轮(y/n)"); + char key = char.Parse(Console.ReadLine()); + if (key == ('y' | 'Y')) + { + user.talk1(); + nPC.talk1(); + NextRound(nPC, user); + } + else if (key == ('n' | 'N')) + { + referee.Date1(); + } + + + } + } +} diff --git "a/\350\256\270\345\237\271\346\250\237/\347\214\234\346\213\263/Referee.cs" "b/\350\256\270\345\237\271\346\250\237/\347\214\234\346\213\263/Referee.cs" new file mode 100644 index 0000000000000000000000000000000000000000..8c2d621761be67f94d7967d9c003ed1dd9d8370d --- /dev/null +++ "b/\350\256\270\345\237\271\346\250\237/\347\214\234\346\213\263/Referee.cs" @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Referee + { + + int sum1 = 0; + int sum2 = 0; + int sum3 = 0; + int sum4 = 0; + + public void Date(int a1, int a2) + { + if (a1 - a2 == -2 || a1 - a2 == 1) + { + Console.WriteLine("玩家胜利!"); + sum2++; + } + else if (a1 == a2) + { + Console.WriteLine("平局"); + sum3++; + } + else + { + Console.WriteLine("玩家失败!"); + sum4++; + } + sum1 = sum2 + sum3 + sum4; + + } + + + internal void Date1() + { + Console.WriteLine("你的胜场数:{0}", sum2); + Console.WriteLine("对手胜场数:{0}", sum4); + Console.WriteLine("平局场数:{0}", sum3); + Console.WriteLine("总场数:{0}", sum1); + if (sum2 > sum4) + { + Console.WriteLine("你赢了"); + } + else if (sum2 < sum4) + { + Console.WriteLine("你输了"); + } + else if (sum2 == sum4) + { + Console.WriteLine("平局"); + } + } + } +} diff --git "a/\350\256\270\345\237\271\346\250\237/\347\273\223\346\236\204\344\275\223/PersonClass.cs" "b/\350\256\270\345\237\271\346\250\237/\347\273\223\346\236\204\344\275\223/PersonClass.cs" new file mode 100644 index 0000000000000000000000000000000000000000..eda314159ad4a65946ab10f1e336fd8ba310b42d --- /dev/null +++ "b/\350\256\270\345\237\271\346\250\237/\347\273\223\346\236\204\344\275\223/PersonClass.cs" @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp5 +{ + class PersonClass + { + public string name; + public int telephone; + public string add; + + public PersonClass(string name, int telephone, string add) + { + this.name = name; + this.telephone = telephone; + this.add = add; + } + } +} diff --git "a/\350\256\270\345\237\271\346\250\237/\347\273\223\346\236\204\344\275\223/Program.cs" "b/\350\256\270\345\237\271\346\250\237/\347\273\223\346\236\204\344\275\223/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..49b6c2bfcd1379041d3fcccce5206420a4610cc0 --- /dev/null +++ "b/\350\256\270\345\237\271\346\250\237/\347\273\223\346\236\204\344\275\223/Program.cs" @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp5 +{ + class Program + { + public struct PersonStruct + { + public string name; + public int telephone; + public string add; + + public PersonStruct(string name, int telephone, string add) + { + this.name = name; + this.telephone = telephone; + this.add = add; + } + + } + + + + static void Main(string[] args) + { + PersonStruct p1 = new PersonStruct(); + p1.name = "张三"; + p1.telephone = 4548789; + p1.add = "龙岩"; + + PersonStruct p2 = new PersonStruct(); + p2 = p1; + p2.name = "李四"; + Console.WriteLine("姓名:{0},电话:{1},地址:{2}", p1.name, p1.telephone, p1.add); + Console.WriteLine("姓名:{0},电话:{1},地址:{2}", p2.name, p2.telephone, p2.add); + + PersonStruct p3 = new PersonStruct("王五", 546765306, "泉州"); + + PersonClass p4 = new PersonClass(p3.name, p3.telephone, p3.add); + p4.name = "赵六"; + Console.WriteLine("姓名:{0},电话:{1},地址:{2}", p3.name, p3.telephone, p3.add); + Console.WriteLine("姓名:{0},电话:{1},地址:{2}", p4.name, p4.telephone, p4.add); + } + } +} diff --git "a/\350\256\270\350\207\252\346\246\225/Name.cs" "b/\350\256\270\350\207\252\346\246\225/Name.cs" new file mode 100644 index 0000000000000000000000000000000000000000..0699cefe0883493af77a3891111eb1c937b41e13 --- /dev/null +++ "b/\350\256\270\350\207\252\346\246\225/Name.cs" @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Name + { + public int Num { get; set; } + public int Opper() + { + Random ran = new Random(); + Num= ran.Next(1,4); + return Num; + } + public int Rannum() + { + int ran = Opper(); + return ran; + } + public string Name2() + { + Console.WriteLine("请输入你的姓名"); + string name = Console.ReadLine(); + return name; + } + public string Ran() + { + int num = Rannum(); + string a = "0"; + if(num == 1) + { + a = "剪刀"; + } + if(num == 2) + { + a = "石头"; + } + if (num == 3) + { + a = "布"; + } + return a; + } + } +} \ No newline at end of file diff --git "a/\350\256\270\350\207\252\346\246\225/Opreation.cs" "b/\350\256\270\350\207\252\346\246\225/Opreation.cs" new file mode 100644 index 0000000000000000000000000000000000000000..6923e6e5ea5da6ddbbf9624ebd47526c5709022f --- /dev/null +++ "b/\350\256\270\350\207\252\346\246\225/Opreation.cs" @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + public enum Op { 剪刀=1,石头,布} + class Opreation:Name + { + public int Num2 { get; set; } + struct Msg2 + { + public int num2; + } + public int Msg() + { + Msg2 msg2; + msg2.num2 = int.Parse(Console.ReadLine()); + return msg2.num2; + } + public int Opper2() + { + int num2cha = Msg(); + return num2cha; + } + public void Opre() + { + switch (Opper2()) + { + case (int)Op.剪刀: + Console.WriteLine($"{Name2()}: 出拳:{Op.剪刀}"); + break; + case (int)Op.石头: + Console.WriteLine($"{Name2()}: 出拳:{Op.石头}"); + break; + case (int)Op.布: + Console.WriteLine($"{Name2()}: 出拳:{Op.布}"); + break; + default: + Console.WriteLine("输入错误!"); + break; + } + } + } +} \ No newline at end of file diff --git "a/\350\256\270\350\207\252\346\246\225/Person.cs" "b/\350\256\270\350\207\252\346\246\225/Person.cs" new file mode 100644 index 0000000000000000000000000000000000000000..19b22a4697a40996f85fbe161c5af95d181ef8a8 --- /dev/null +++ "b/\350\256\270\350\207\252\346\246\225/Person.cs" @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Person : Opreation + { + public void suiji() + { + int Num2 = Opper2(); + int Num = Rannum(); + Console.WriteLine("随机"+Num); + Console.WriteLine("玩家"+Num2); + if (Num2 == Num) + { + Console.WriteLine("平局"); + } + if (Num2 > Num & Num2 == Num + 1) + { + Console.WriteLine("胜利"); + } + if (Num2 < Num & Num2 == Num - 1) + { + Console.WriteLine("失败"); + } + } + public int[] Draw() + { + int draw = 0; + int defeat = 0; + int victory = 0; + for (int i = 0; i < 1000; i++) + { + if (Num2 == Num) + { + draw++; + break; + } + if (Num2 > Num & Num2 == Num + 1) + { + victory++; + break; + } + if (Num2 < Num & Num2 == Num - 1) + { + defeat++; + break; + } + } + int[] arr = new int[] { draw, victory, defeat }; + return arr; + } + public void Score() + { + Console.WriteLine("平局:"+Draw()[0]); + Console.WriteLine("胜利:"+Draw()[1]); + Console.WriteLine("失败:"+Draw()[2]); + } + } +} \ No newline at end of file diff --git "a/\350\256\270\350\207\252\346\246\225/Program.cs" "b/\350\256\270\350\207\252\346\246\225/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..930a02ad341c8af4193da23dc31009e58d696fe8 --- /dev/null +++ "b/\350\256\270\350\207\252\346\246\225/Program.cs" @@ -0,0 +1,52 @@ +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) + { + while (true) + { + Stact(); + Chara cha = new Chara(); + cha.Chara2(); + Console.WriteLine("开始游戏吗? "); + string key1 = Console.ReadLine(); + if (key1.Equals("y")) + { + Opreation op2 = new Opreation(); + Name N = new Name(); + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应的数字)"); + op2.Msg(); + op2.Opre(); + cha.Chaopre(); + Person pr = new Person(); + pr.suiji(); + Console.WriteLine("==============比分================="); + pr.Score(); + } + else + { + Environment.Exit(0); + } + Console.WriteLine("========================"); + Console.WriteLine(); + } + + } + + public static void Stact() + { + Console.WriteLine("欢迎来到游戏世界"); + Console.WriteLine("猜拳开始"); + Console.WriteLine("出拳规则: 1.剪刀 2.石头 3.布"); + Console.WriteLine("请选择对方角色 :1.刘备 2.孙权 3.曹操"); + } + } +} +} diff --git "a/\350\265\265\345\230\211\351\252\217/\347\214\234\346\213\263/Program.cs" "b/\350\265\265\345\230\211\351\252\217/\347\214\234\346\213\263/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..250ed2d748d5b69da8b2705bf039a4f0e337a482 --- /dev/null +++ "b/\350\265\265\345\230\211\351\252\217/\347\214\234\346\213\263/Program.cs" @@ -0,0 +1,421 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp5 +{ + class Program + { + enum Caiquan + { + 剪刀 = 1, + 石头 = 2, + 布 = 3 + } + + static void Main(string[] args) + { + + Random ran = new Random(); + Console.WriteLine("--------------- 欢 迎 进 入 游 戏 世 界 ---------------"); + Console.WriteLine("*********************"); + Console.WriteLine("******猜拳,开始*****"); + Console.WriteLine("*********************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Console.WriteLine("请选择对方角色<1:刘备 2:孙权 3:曹操>"); + int num = int.Parse(Console.ReadLine()); + switch (num) + { + case 1: + Console.WriteLine("你选择了刘备"); + Console.WriteLine("请输入您的姓名:"); + string name = Console.ReadLine(); + Console.WriteLine(name+" VS 刘备 对战"); + Console.WriteLine("开始游戏吗?"); + string a = Console.ReadLine(); + + + if (a == "yes") + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布 (输入相应数字:)"); + int num2 = int.Parse(Console.ReadLine()); + + switch (num2) + { + case 1: + int player = 1; + + Console.WriteLine(name+":出拳:剪刀"); + int b = ran.Next(0, 4); + string strPC = ""; + if (b == 1) + { + strPC = "剪刀"; + } + else if (b == 2) + { + strPC = "石头"; + } + else if (b == 3) + { + strPC = "布"; + } + Console.WriteLine("刘备 :出拳:"+strPC); + int pc = b; + if (player - pc == -2) + { + Console.WriteLine("恭喜," + name + "赢了"); + } + else if (player - pc == -1) + { + Console.WriteLine("八嘎," + name + "输了"); + } + else { + Console.WriteLine("出错"); + } + Console.WriteLine("是否开始下一轮?"); + break; + case 2: + int player2 = 2; + + Console.WriteLine(name + ":出拳:石头"); + int c = ran.Next(0, 4); + string strPC2 = ""; + if (c == 1) + { + strPC = "剪刀"; + } + else if (c == 2) + { + strPC = "石头"; + } + else if (c == 3) + { + strPC = "布"; + } + Console.WriteLine("刘备 :出拳:" + strPC2); + int pc2 = c; + if (player2 - pc2 == 1) + { + Console.WriteLine("恭喜," + name + "赢了"); + } + else if (player2 - pc2 == -1) + { + Console.WriteLine("八嘎," + name + "输了"); + } + else + { + Console.WriteLine("出错"); + } + Console.WriteLine("是否开始下一轮?"); + break; + case 3: + int player3 = 3; + + Console.WriteLine(name + ":出拳:布"); + int d = ran.Next(0, 4); + string strPC3 = ""; + if (d == 1) + { + strPC = "剪刀"; + } + else if (d== 2) + { + strPC = "石头"; + } + else if (d == 3) + { + strPC = "布"; + } + Console.WriteLine("刘备 :出拳:" + strPC3); + int pc3 = d; + if (player3 - pc3 == 1) + { + Console.WriteLine("恭喜," + name + "赢了"); + } + else if (player3 - pc3 == 2) + { + Console.WriteLine("八嘎," + name + "输了"); + } + else + { + Console.WriteLine("出错"); + } + Console.WriteLine("是否开始下一轮?"); + break; + default: + break; + } + } else if (a=="no") + { + Console.WriteLine("系统退出"); + break; + } + break; + case 2: + Console.WriteLine("你选择了孙权"); + Console.WriteLine("请输入您的姓名:"); + string name2 = Console.ReadLine(); + Console.WriteLine(name2 + " VS 孙权 对战"); + Console.WriteLine("开始游戏吗?"); + string e = Console.ReadLine(); + + + if (e == "yes") + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布 (输入相应数字:)"); + int num2 = int.Parse(Console.ReadLine()); + + switch (num2) + { + case 1: + int player = 1; + + Console.WriteLine(name2 + ":出拳:剪刀"); + int b = ran.Next(0, 4); + string strPC = ""; + if (b == 1) + { + strPC = "剪刀"; + } + else if (b == 2) + { + strPC = "石头"; + } + else if (b == 3) + { + strPC = "布"; + } + Console.WriteLine("孙权 :出拳:" + strPC); + int pc = b; + if (player - pc == -2) + { + Console.WriteLine("恭喜," + name2 + "赢了"); + } + else if (player - pc == -1) + { + Console.WriteLine("八嘎," + name2 + "输了"); + } + else + { + Console.WriteLine("出错"); + } + Console.WriteLine("是否开始下一轮?"); + break; + case 2: + int player2 = 2; + + Console.WriteLine(name2 + ":出拳:石头"); + int c = ran.Next(0, 4); + string strPC2 = ""; + if (c == 1) + { + strPC = "剪刀"; + } + else if (c == 2) + { + strPC = "石头"; + } + else if (c == 3) + { + strPC = "布"; + } + Console.WriteLine("孙权 :出拳:" + strPC2); + int pc2 = c; + if (player2 - pc2 == 1) + { + Console.WriteLine("恭喜," + name2 + "赢了"); + } + else if (player2 - pc2 == -1) + { + Console.WriteLine("八嘎," + name2 + "输了"); + } + else + { + Console.WriteLine("出错"); + } + Console.WriteLine("是否开始下一轮?"); + break; + case 3: + int player3 = 3; + + Console.WriteLine(name2 + ":出拳:布"); + int d = ran.Next(0, 4); + string strPC3 = ""; + if (d == 1) + { + strPC = "剪刀"; + } + else if (d == 2) + { + strPC = "石头"; + } + else if (d == 3) + { + strPC = "布"; + } + Console.WriteLine("孙权 :出拳:" + strPC3); + int pc3 = d; + if (player3 - pc3 == 1) + { + Console.WriteLine("恭喜," + name2 + "赢了"); + } + else if (player3 - pc3 == 2) + { + Console.WriteLine("八嘎," + name2 + "输了"); + } + else + { + Console.WriteLine("出错"); + } + Console.WriteLine("是否开始下一轮?"); + break; + default: + break; + } + } + else if (e == "no") + { + Console.WriteLine("系统退出"); + break; + } + break; + case 3: + Console.WriteLine("你选择了曹操"); + Console.WriteLine("请输入您的姓名:"); + string name3 = Console.ReadLine(); + Console.WriteLine(name3 + " VS 曹操 对战"); + Console.WriteLine("开始游戏吗?"); + string r = Console.ReadLine(); + + + if (r == "yes") + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布 (输入相应数字:)"); + int num2 = int.Parse(Console.ReadLine()); + + switch (num2) + { + case 1: + int player = 1; + + Console.WriteLine(name3 + ":出拳:剪刀"); + int b = ran.Next(0, 4); + string strPC = ""; + if (b == 1) + { + strPC = "剪刀"; + } + else if (b == 2) + { + strPC = "石头"; + } + else if (b == 3) + { + strPC = "布"; + } + Console.WriteLine("曹操 :出拳:" + strPC); + int pc = b; + if (player - pc == -2) + { + Console.WriteLine("恭喜," + name3+ "赢了"); + } + else if (player - pc == -1) + { + Console.WriteLine("八嘎," + name3+ "输了"); + } + else + { + Console.WriteLine("出错"); + } + Console.WriteLine("是否开始下一轮?"); + break; + case 2: + int player2 = 2; + + Console.WriteLine(name3 + ":出拳:石头"); + int c = ran.Next(0, 4); + string strPC2 = ""; + if (c == 1) + { + strPC = "剪刀"; + } + else if (c == 2) + { + strPC = "石头"; + } + else if (c == 3) + { + strPC = "布"; + } + Console.WriteLine("曹操:出拳:" + strPC2); + int pc2 = c; + if (player2 - pc2 == 1) + { + Console.WriteLine("恭喜," + name3 + "赢了"); + } + else if (player2 - pc2 == -1) + { + Console.WriteLine("八嘎," + name3 + "输了"); + } + else + { + Console.WriteLine("出错"); + } + Console.WriteLine("是否开始下一轮?"); + break; + case 3: + int player3 = 3; + + Console.WriteLine(name3 + ":出拳:布"); + int d = ran.Next(0, 4); + string strPC3 = ""; + if (d == 1) + { + strPC = "剪刀"; + } + else if (d == 2) + { + strPC = "石头"; + } + else if (d == 3) + { + strPC = "布"; + } + Console.WriteLine("曹操 :出拳:" + strPC3); + int pc3 = d; + if (player3 - pc3 == 1) + { + Console.WriteLine("恭喜," + name3 + "赢了"); + } + else if (player3 - pc3 == 2) + { + Console.WriteLine("八嘎," + name3+ "输了"); + } + else + { + Console.WriteLine("出错"); + } + Console.WriteLine("是否开始下一轮?"); + break; + default: + break; + } + } + else if (r == "no") + { + Console.WriteLine("系统退出"); + break; + } + break; + break; + break; + default: + break; + } + } + + } +} diff --git "a/\350\265\265\345\230\211\351\252\217/\347\273\223\346\236\204\344\275\223/PersonClass.cs" "b/\350\265\265\345\230\211\351\252\217/\347\273\223\346\236\204\344\275\223/PersonClass.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b7537765dd941926f9f6c58b5df8e45b0246bdbc --- /dev/null +++ "b/\350\265\265\345\230\211\351\252\217/\347\273\223\346\236\204\344\275\223/PersonClass.cs" @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp4 +{ + class PersonClass + { + public PersonClass() + { + } + private string name; + private string telephone; + private string area; + public PersonClass(string name, string telephone,string area) + { + this.name = name; + this.telephone = telephone; + this.area = area; + } + public string Name { get => name; set => name = value; } + public string Telephone { get => telephone; set => telephone = value; } + public string Area { get => area; set => area = value; } + } +} diff --git "a/\350\265\265\345\230\211\351\252\217/\347\273\223\346\236\204\344\275\223/Program.cs" "b/\350\265\265\345\230\211\351\252\217/\347\273\223\346\236\204\344\275\223/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..e89c3d2d45340834a8664a391ad913bc77d98b9d --- /dev/null +++ "b/\350\265\265\345\230\211\351\252\217/\347\273\223\346\236\204\344\275\223/Program.cs" @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp4 +{ + class Program + { + public struct PersonStruct + { + public string name; + public string telephone; + public string area; + } + static void Main(string[] args) + { + PersonStruct p1 = new PersonStruct(); + p1.name = "卢本伟"; + p1.telephone = "13174560712"; + p1.area = "地球"; + + PersonStruct p2 = new PersonStruct(); + p2 = p1; + p2.name = "刘谋"; + Console.WriteLine("p1.name="+p1.name+"\t" + + "p1.telephone=" + +p1.telephone+"\t"+"p1.area="+p1.area); + + PersonClass p3 = new PersonClass(); + p3.Name = "粉红豹"; + p3.Telephone = "110"; + p3.Area = "你心里"; + + PersonClass p4 = new PersonClass(); + p4 = p3; + p4.Name = "粉红豹无了"; + Console.WriteLine("p3.name=" + p3.Name + "\t" + + "p3.telephone=" + + p3.Telephone + "\t" + "p3.area=" + p3.Area); + + } + } +} diff --git "a/\351\202\271\346\265\267\345\205\265/struct/PersonClass.cs" "b/\351\202\271\346\265\267\345\205\265/struct/PersonClass.cs" new file mode 100644 index 0000000000000000000000000000000000000000..3cc4e069d03bd060e5110f110137ecf2d0834f64 --- /dev/null +++ "b/\351\202\271\346\265\267\345\205\265/struct/PersonClass.cs" @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ConsoleApp1 +{ + class PersonClass + { + public string name { get; set; } + public string phone { get; set; } + public string add { get; set; } + } +} diff --git "a/\351\202\271\346\265\267\345\205\265/struct/Program.cs" "b/\351\202\271\346\265\267\345\205\265/struct/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..3a95a00927d06a9ea5d730346a4d1a11a51cae83 --- /dev/null +++ "b/\351\202\271\346\265\267\345\205\265/struct/Program.cs" @@ -0,0 +1,44 @@ +using System; + +namespace ConsoleApp1 +{ + class Program + { + // 定义一个结构体,名为PersonStruct,有三个成员变量:姓名、电话、地址, + //在主方法中,创建一个PersonStruct结构体对象p1,为p1的成员变量赋值。 + //再声明一个PersonStruct结构体变量p2,把p1赋值给p2,改变p2的姓名,打印p1的内容。 + + + struct PersonStruct + { + public string name; + public string phone; + public string add; + } + static void Main(string[] args) + { + PersonStruct p1; + p1.name = "p1"; + p1.phone = "123456"; + p1.add = "北京"; + + PersonStruct p2; + //p2.name = "p2"; + //p2.phone = "123456789"; + //p2.add = "南京"; + + p2 = p1; + Console.WriteLine(p2.name+p2.phone+p2.add); + Console.WriteLine("-----------------------"); + + PersonClass p3 = new PersonClass(); + p3.name = "p1"; + p3.phone = "123456"; + p3.add = "北京"; + + PersonClass p4 = new PersonClass(); + p4 = p3; + Console.WriteLine(p4.name + p4.phone + p4.add); + } + } +} diff --git "a/\351\202\271\346\265\267\345\205\265/\347\214\234\346\213\263/Chara.cs" "b/\351\202\271\346\265\267\345\205\265/\347\214\234\346\213\263/Chara.cs" new file mode 100644 index 0000000000000000000000000000000000000000..cec3cdea6f183b514f4a8ab2387a4e83576b32c1 --- /dev/null +++ "b/\351\202\271\346\265\267\345\205\265/\347\214\234\346\213\263/Chara.cs" @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ConsoleApp2 +{ + enum cha { 刘备 = 1, 孙权, 曹操 } + class Chara : Name + { + + public int Num3 { get; set; } + public int Chara2() + { + //Console.WriteLine("请选择对方角色 :1.刘备 2.孙权 3.曹操"); + int num3 = int.Parse(Console.ReadLine()); + Num3 = num3; + return Num3; + } + public void Chaopre() + { + switch (Chara2()) + { + case (int)cha.刘备: + Console.WriteLine($"{cha.刘备}: 出拳:{Ran()}"); + break; + case (int)cha.孙权: + Console.WriteLine($"{cha.孙权}: 出拳:{Ran()}"); + break; + case (int)cha.曹操: + Console.WriteLine($"{cha.曹操}: 出拳:{Ran()}"); + break; + default: + break; + } + } + } + +} diff --git "a/\351\202\271\346\265\267\345\205\265/\347\214\234\346\213\263/Name.cs" "b/\351\202\271\346\265\267\345\205\265/\347\214\234\346\213\263/Name.cs" new file mode 100644 index 0000000000000000000000000000000000000000..7719f4953bc3259feb3ceb8529bc902258e78c99 --- /dev/null +++ "b/\351\202\271\346\265\267\345\205\265/\347\214\234\346\213\263/Name.cs" @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ConsoleApp2 +{ + class Name + { + public int Num { get; set; } + public int Opper() + { + Random ran = new Random(); + Num= ran.Next(1,4); + return Num; + } + public int Rannum() + { + int ran = Opper(); + return ran; + } + public string Name2() + { + Console.WriteLine("请输入你的姓名"); + string name = Console.ReadLine(); + return name; + } + public string Ran() + { + int num = Rannum(); + string a = "0"; + if(num == 1) + { + a = "剪刀"; + } + if(num == 2) + { + a = "石头"; + } + if (num == 3) + { + a = "布"; + } + return a; + } + } +} diff --git "a/\351\202\271\346\265\267\345\205\265/\347\214\234\346\213\263/Program.cs" "b/\351\202\271\346\265\267\345\205\265/\347\214\234\346\213\263/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..6ecc8daf337b79732cfa144273ead12dd3c7e8b3 --- /dev/null +++ "b/\351\202\271\346\265\267\345\205\265/\347\214\234\346\213\263/Program.cs" @@ -0,0 +1,71 @@ +using System; + +namespace ConsoleApp2 +{ + class Program + { + static void Main(string[] args) + { + while (true) + { + Stact(); + Chara cha = new Chara(); + cha.Chara2(); + Console.WriteLine("开始游戏吗? "); + string key1 = Console.ReadLine(); + if (key1.Equals("y")) + { + Opreation op2 = new Opreation(); + Name N = new Name(); + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应的数字)"); + op2.Msg(); + op2.Opre(); + cha.Chaopre(); + Person pr = new Person(); + pr.Judge1(); + Console.WriteLine("=======================比分========================="); + pr.Score(); + } + else + { + Environment.Exit(0); + } + Console.WriteLine("=================================="); + Console.WriteLine(); + } + + } + //public static int[] Record(Opreation op) + //{ + // int draw = 0; + // int defeat = 0; + // int victory = 0; + // int Num2 = op.Opper2(); + // int Num = op.Opper(); + // if (Num2 == Num) + // { + // draw++; + // } + // if (Num2 > Num & Num2 == Num + 1) + // { + // victory++; + // } + // if (Num2 < Num & Num2 == Num - 1) + // { + // defeat++; + // } + // Console.WriteLine(victory); + // Console.WriteLine(draw); + // Console.WriteLine(defeat); + // int[] arr = new int[] { draw,victory, defeat }; + // return arr; + //} + public static void Stact() + { + Console.WriteLine("欢迎来到游戏世界"); + Console.WriteLine("猜拳开始"); + Console.WriteLine("出拳规则: 1.剪刀 2.石头 3.布"); + Console.WriteLine("请选择对方角色 :1.刘备 2.孙权 3.曹操"); + } + } +} diff --git "a/\351\202\271\346\265\267\345\205\265/\347\214\234\346\213\263/opreation.cs" "b/\351\202\271\346\265\267\345\205\265/\347\214\234\346\213\263/opreation.cs" new file mode 100644 index 0000000000000000000000000000000000000000..af6b5bdcc7f530c979aeb95044d884e7f1dc3645 --- /dev/null +++ "b/\351\202\271\346\265\267\345\205\265/\347\214\234\346\213\263/opreation.cs" @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ConsoleApp2 +{ + public enum Op { 剪刀=1,石头,布} + class Opreation:Name + { + public int Num2 { get; set; } + struct Msg2 + { + public int num2; + } + public int Msg() + { + Msg2 msg2; + msg2.num2 = int.Parse(Console.ReadLine()); + return msg2.num2; + } + public int Opper2() + { + int num2cha = Msg(); + return num2cha; + } + public void Opre() + { + switch (Opper2()) + { + case (int)Op.剪刀: + Console.WriteLine($"{Name2()}: 出拳:{Op.剪刀}"); + break; + case (int)Op.石头: + Console.WriteLine($"{Name2()}: 出拳:{Op.石头}"); + break; + case (int)Op.布: + Console.WriteLine($"{Name2()}: 出拳:{Op.布}"); + break; + default: + Console.WriteLine("opre输入错误!"); + break; + } + } + } +} diff --git "a/\351\202\271\346\265\267\345\205\265/\347\214\234\346\213\263/person.cs" "b/\351\202\271\346\265\267\345\205\265/\347\214\234\346\213\263/person.cs" new file mode 100644 index 0000000000000000000000000000000000000000..46c48acfe4a5b3bde40b75648f16eae9038685c7 --- /dev/null +++ "b/\351\202\271\346\265\267\345\205\265/\347\214\234\346\213\263/person.cs" @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ConsoleApp2 +{ + class Person : Opreation + { + public void Judge1() + { + int Num2 = Opper2(); + int Num = Rannum(); + Console.WriteLine("随机"+Num); + Console.WriteLine("玩家"+Num2); + if (Num2 == Num) + { + Console.WriteLine("平局"); + } + if (Num2 > Num & Num2 == Num + 1) + { + Console.WriteLine("胜利"); + } + if (Num2 < Num & Num2 == Num - 1) + { + Console.WriteLine("失败"); + } + } + public int[] Draw() + { + int draw = 0; + int defeat = 0; + int victory = 0; + for (int i = 0; i < 1000; i++) + { + if (Num2 == Num) + { + draw++; + break; + } + if (Num2 > Num & Num2 == Num + 1) + { + victory++; + break; + } + if (Num2 < Num & Num2 == Num - 1) + { + defeat++; + break; + } + } + int[] arr = new int[] { draw, victory, defeat }; + return arr; + } + public void Score() + { + Console.WriteLine("平局:"+Draw()[0]); + Console.WriteLine("胜利:"+Draw()[1]); + Console.WriteLine("失败:"+Draw()[2]); + } + } +} diff --git "a/\351\203\221\347\276\216\345\251\267/\347\214\234\346\213\263/Caipan.cs" "b/\351\203\221\347\276\216\345\251\267/\347\214\234\346\213\263/Caipan.cs" new file mode 100644 index 0000000000000000000000000000000000000000..41678d3ec6254a216d0f015c1cc84d47dc9e2d25 --- /dev/null +++ "b/\351\203\221\347\276\216\345\251\267/\347\214\234\346\213\263/Caipan.cs" @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Caipan + { + public void RuleSpeak() + { + Console.WriteLine("------欢迎进入游戏世界------"); + Console.WriteLine(); + Console.WriteLine("****************************"); + Console.WriteLine("*********猜拳,开始*********"); + Console.WriteLine("****************************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + } + public void returnup(string name,Heroname he,int counttime, int result1,int result2) + { + + Console.WriteLine("==================================="); + Console.WriteLine($"{name} vs {he}"); + Console.WriteLine($"对战次数:{counttime}"); + Console.WriteLine(); + Console.WriteLine($"姓名\t得分"); + Console.WriteLine($"{name}\t{result1}"); + Console.WriteLine($"{he}\t{result2}"); + Console.Write("结果:"); + result(name, he, result1, result2); + } + public void result(string name,Heroname he,int result1,int result2) + { + if (result1 > result2) + { + Console.WriteLine($"{name}赢,{he}笨蛋"); + } + else if(result1 > result2) + { + Console.WriteLine($"{he}赢,{name}笨蛋"); + } + else + { + Console.WriteLine("平局!"); + } + } + public void Shibai(string name) + { + Console.WriteLine($"笨蛋,{name}输了"); + } + public void Win(string name) + { + Console.WriteLine($"恭喜,{name}赢了"); + } + public void He() + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + } +} \ No newline at end of file diff --git "a/\351\203\221\347\276\216\345\251\267/\347\214\234\346\213\263/Cc.cs" "b/\351\203\221\347\276\216\345\251\267/\347\214\234\346\213\263/Cc.cs" new file mode 100644 index 0000000000000000000000000000000000000000..f53b9dd8c9d5d2f5b9184a49890a2f1a20abfcd4 --- /dev/null +++ "b/\351\203\221\347\276\216\345\251\267/\347\214\234\346\213\263/Cc.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Cc : Hero + { + public Cc(string name, int age, char sex) : base(name, age, sex) + { + base.Name = name; + base.Age = age; + base.Sex = sex; + } + public override void yuyin() + { + Console.WriteLine($"在下{base.Name},后会有期~"); + } + public override void chu() + { + + } + } +} diff --git "a/\351\203\221\347\276\216\345\251\267/\347\214\234\346\213\263/Computer.cs" "b/\351\203\221\347\276\216\345\251\267/\347\214\234\346\213\263/Computer.cs" new file mode 100644 index 0000000000000000000000000000000000000000..6316148b9860f879a07fc5800e5d27a66551817d --- /dev/null +++ "b/\351\203\221\347\276\216\345\251\267/\347\214\234\346\213\263/Computer.cs" @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + enum chuquanf + { + 剪刀=1, + 石头=2, + 布=3 + } + class Computer + { + Random rd = new Random(); + string[] arr = new string[3]; + int temp = 0; + int max = 3; + int min = 1; + //chuquanf cq = (chuquanf)Enum.Parse(typeof(chuquanf), rd); + public void chuquan() + { + + } + } +} diff --git "a/\351\203\221\347\276\216\345\251\267/\347\214\234\346\213\263/Hero.cs" "b/\351\203\221\347\276\216\345\251\267/\347\214\234\346\213\263/Hero.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b77c9584ec9d7403ca7e6008feee07edcc6698ea --- /dev/null +++ "b/\351\203\221\347\276\216\345\251\267/\347\214\234\346\213\263/Hero.cs" @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + abstract class Hero + { + private string name; + private int age; + private char sex; + public Hero() + { } + public Hero(string name, int age, char sex) + { + this.name = name; + this.age = age; + this.sex = sex; + } + + public string Name + { + get { return this.name; } + set { this.name = value; } + } + + public int Age { get => age; set => age = value; } + public char Sex { get => sex; set => sex = value; } + public abstract void yuyin(); + public abstract void chu(); + } +} diff --git "a/\351\203\221\347\276\216\345\251\267/\347\214\234\346\213\263/Liubei.cs" "b/\351\203\221\347\276\216\345\251\267/\347\214\234\346\213\263/Liubei.cs" new file mode 100644 index 0000000000000000000000000000000000000000..0dd9312d45d7fb2a7fc69bdf12fb7bbb77aa5390 --- /dev/null +++ "b/\351\203\221\347\276\216\345\251\267/\347\214\234\346\213\263/Liubei.cs" @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Liubei : Hero + { + public Liubei() { } + public Liubei(string name, int age, char sex) : base(name, age, sex) + { + base.Name = name; + base.Age = age; + base.Sex = sex; + } + public override void yuyin() + { + Console.WriteLine("在下{0},请多多指教。",base.Name); + } + public override void chu() + { + + } + } +} diff --git "a/\351\203\221\347\276\216\345\251\267/\347\214\234\346\213\263/Me.cs" "b/\351\203\221\347\276\216\345\251\267/\347\214\234\346\213\263/Me.cs" new file mode 100644 index 0000000000000000000000000000000000000000..2ae04473b508629e06fd55515e8e20f2e620077a --- /dev/null +++ "b/\351\203\221\347\276\216\345\251\267/\347\214\234\346\213\263/Me.cs" @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Me + { + + } +} diff --git "a/\351\203\221\347\276\216\345\251\267/\347\214\234\346\213\263/Program.cs" "b/\351\203\221\347\276\216\345\251\267/\347\214\234\346\213\263/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..40daa747b71bd7b4a2dcfe323c84707f94674e6a --- /dev/null +++ "b/\351\203\221\347\276\216\345\251\267/\347\214\234\346\213\263/Program.cs" @@ -0,0 +1,246 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + public enum Heroname//枚举英雄 + { + 刘备=1, + 孙权=2, + 曹操=3 + } + public enum Chuquaning//枚举出拳 + { + 剪刀 = 1, + 石头 = 2, + 布 = 3 + } + class Program + { + static void Main(string[] args)//主方法 + { + Play(); + } + public static void Play() + { + Caipan cp = new Caipan();//实例化裁判 + cp.RuleSpeak();//引入裁判规则 + //while (true) + //{ + Console.WriteLine("请选择对方角色<1:刘备 2:孙权 3:曹操>"); + int heroname = int.Parse(Console.ReadLine()); + Heroname he = (Heroname)Enum.Parse(typeof(Heroname), heroname.ToString()); + //if (heroname.Equals(he.)) + //{ + Console.WriteLine("请输入您的名字:"); + string username = Console.ReadLine(); + + Console.WriteLine("{0} vs {1} 对战", username, he); + Console.WriteLine("开始游戏吗?"); + string yn = Console.ReadLine(); + YN(yn, username, he); + //} + //else + //{ + // Console.WriteLine("输入英雄不存在,请重新输入!"); + //} + //} + } + public static void Youxi(string name,Heroname he) + { + Caipan cb = new Caipan(); + + //我方出拳 + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应数字:)"); + int renchuquan = int.Parse(Console.ReadLine()); + Chuquaning cqr = (Chuquaning)Enum.Parse(typeof(Chuquaning), renchuquan.ToString()); + + //电脑随机出拳 + int computercq = GetRandomByGuid(0, 3); + Chuquaning cqc = (Chuquaning)Enum.Parse(typeof(Chuquaning), computercq.ToString()); + + //比较双方出拳结果 + Bijiao(renchuquan,computercq,cb,name,he,cqc,cqr); + } + public static void Bijiao(int renchuquan, int computercq, Caipan cb, string name, Heroname he, Chuquaning cqc, Chuquaning cqr) + { + int time = 0; + int rscore = 0; + int cscore = 0; + while (true) + { + time++; + switch (renchuquan) + { + case 1: + Console.WriteLine($"{name}:出拳:{cqr}"); + Console.WriteLine($"{he}:出拳:{cqc}"); + qinkuan1(renchuquan, computercq, cb, name, rscore, cscore); + break; + case 2: + Console.WriteLine($"{name}:出拳:{cqr}"); + Console.WriteLine($"{he}:出拳:{cqc}"); + qinkuan2(renchuquan, computercq, cb, name, rscore, cscore); + break; + case 3: + Console.WriteLine($"{name}:出拳:{cqr}"); + Console.WriteLine($"{he}:出拳:{cqc}"); + qinkuan3(renchuquan, computercq, cb, name, rscore, cscore); + break; + default: + Console.WriteLine("出拳错误,请重新输入!"); + break; + } + + Console.WriteLine("是否开始下一轮?"); + string b = Console.ReadLine(); + + YNyn(b, name, he, rscore, cscore, time); + } + } + private static void qinkuan3(int aa,int bb,Caipan cb,string name,int rscore,int cscore) + { + if (aa == bb) + { + cb.He(); + } + else if (aa != bb) + { + if (aa == 1) + { + cb.Shibai(name); + cscore++; + } + else if (aa == 2) + { + cb.Win(name); + rscore++; + } + } + else + { + Console.WriteLine("输入错误!"); + } + } + private static void qinkuan2(int aa, int bb, Caipan cb,string name, int rscore, int cscore) + { + if (aa == bb) + { + cb.He(); + } + else if (aa != bb) + { + if (aa == 1) + { + cb.Win(name); + rscore ++; + } + else if (aa == 3) + { + cb.Shibai(name); + cscore++; + } + } + else + { + Console.WriteLine("输入错误!"); + } + } + private static void qinkuan1(int ren, int cpu, Caipan cb, string name, int rscore, int cscore) + { + if (ren == cpu) + { + cb.He(); + } + else if (ren != cpu) + { + if (cpu == 2) + { + cb.Shibai(name); + cscore ++; + } + else if (cpu == 3) + { + cb.Win(name); + rscore++; + } + } + else + { + Console.WriteLine("输入错误!"); + } + } + static void Return(string name,Heroname he,int cishu,int rfs,int cfs) + { + Caipan cb = new Caipan(); + cb.returnup(name,he,cishu,rfs,cfs); + + Console.WriteLine("要开始下一局吗?"); + string xzxz = Console.ReadLine(); + YN(xzxz, name, he); + } + + private static void YN(string beginorend, string name, Heroname he) + { + if (beginorend == "y") + { + Youxi(name, he); + } + else if (beginorend == "Y") + { + Youxi(name, he); + } + else if (beginorend == "n") + { + Play(); + } + else if (beginorend == "N") + { + Play(); + } + else + { + Console.WriteLine("系统退出!"); + Environment.Exit(0); + } + } + private static void YNyn(string xz,string name, Heroname h,int rfengshu,int cfengshu,int time) + { + if (xz == "y") + { + Youxi(name,h); + } + else if (xz == "Y") + { + Youxi(name,h); + } + else if (xz == "n") + { + Return(name,h, time, rfengshu, cfengshu); + } + else if (xz == "N") + { + Return(name,h, time, rfengshu, cfengshu); + } + else + { + Console.WriteLine("系统退出!"); + Environment.Exit(0); + } + } + //电脑出拳 + private static int GetRandomByGuid(int min, int max) + { + Random ro = new Random(GetRandomSeedByGuid()); + int ronum = ro.Next(min, max); + return ronum; + } + static int GetRandomSeedByGuid() + { + return new Guid().GetHashCode(); + } + } +} \ No newline at end of file diff --git "a/\351\203\221\347\276\216\345\251\267/\347\214\234\346\213\263/Sunquan.cs" "b/\351\203\221\347\276\216\345\251\267/\347\214\234\346\213\263/Sunquan.cs" new file mode 100644 index 0000000000000000000000000000000000000000..7a3a3500f37c484a3a5c29fac3e265176460b10d --- /dev/null +++ "b/\351\203\221\347\276\216\345\251\267/\347\214\234\346\213\263/Sunquan.cs" @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Sunquan : Hero + { + public Sunquan() { } + public Sunquan(string name, int age, char sex) : base(name, age, sex) + { + base.Name = name; + base.Age = age; + base.Sex = sex; + } + public override void yuyin() + { + Console.WriteLine($"{base.Name}在此,有何贵干?"); + } + public override void chu() + { + + } + } +} + diff --git "a/\351\203\221\347\276\216\345\251\267/\347\273\223\346\236\204\344\275\223/PersonClass.cs" "b/\351\203\221\347\276\216\345\251\267/\347\273\223\346\236\204\344\275\223/PersonClass.cs" new file mode 100644 index 0000000000000000000000000000000000000000..273c08f242b78e70b9e6e1c6f77bf3fbb7ef4fad --- /dev/null +++ "b/\351\203\221\347\276\216\345\251\267/\347\273\223\346\236\204\344\275\223/PersonClass.cs" @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class PersonClass + { + private string name; + private long phone; + private string adder; + + public PersonClass() + { } + public PersonClass(string name, long phone, string adder) + { + this.name = name; + this.phone = phone; + this.adder = adder; + } + + public string Name { get => name; set => name = value; } + public long Phone { get => phone; set => phone = value; } + public string Adder { get => adder; set => adder = value; } + } +} diff --git "a/\351\203\221\347\276\216\345\251\267/\347\273\223\346\236\204\344\275\223/Program.cs" "b/\351\203\221\347\276\216\345\251\267/\347\273\223\346\236\204\344\275\223/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..11a4d31eef788d99746e8e6f5becc366971e9499 --- /dev/null +++ "b/\351\203\221\347\276\216\345\251\267/\347\273\223\346\236\204\344\275\223/Program.cs" @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + //定义一个结构体,名为PersonStruct,有三个成员变量:姓名、电话、地址, + //在主方法中,创建一个PersonStruct结构体对象p1,为p1的成员变量赋值。 + //再声明一个PersonStruct结构体变量p2,把p1赋值给p2,改变p2的姓名,打印p1的内容。 + + //定义一个类,名为PersonClass,有三个成员变量:姓名、电话、地址, + //在主方法中,创建一个PersonClass对象p3,为p3的成员变量赋值。 + //再声明一个PersonClass变量p4,把p3赋值给p4,改变p4的姓名,打印p3的内容。 + + + //观察打印结果,并在在注释中,说下你对此的认识(它们为什么会这样?) + class Program + { + /// + /// 它们为什么会这样? + /// 因为: + /// struct 有自己的存储空间,p1、p2相当于有两个分开的存储空间,p1的值赋值给p2,p1的值不会改变(p1有单独的存储空间)。 + /// class 是共有存储空间,p1、p2的值是相通的,p2值被改变,p1值同时被改变,反之亦然。 + /// + public struct PersonStruct + { + public string name; + public long phone; + public string adder; + } + static void Main(string[] args) + { + + PersonStruct p1 = new PersonStruct(); + p1.name = "阿珍"; + p1.phone =13520148521; + p1.adder = "上海老街"; + + PersonStruct p2 = new PersonStruct(); + p2 = p1; + p2.name = "阿强"; + Console.WriteLine(p1.name);//未改变 + + PersonClass p3 = new PersonClass(); + p3.Name = "阿珍爱上了阿强"; + p3.Phone = 12365485201; + p3.Adder = "夜上海"; + + PersonClass p4 = new PersonClass(); + p4 = p3; + p4.Name = "阿强爱上了阿珍"; + Console.WriteLine(p3.Name);//改变 + } + } +} diff --git "a/\351\203\255\347\220\252\346\236\253/\344\270\215\344\274\232\345\201\232/Computer.cs" "b/\351\203\255\347\220\252\346\236\253/\344\270\215\344\274\232\345\201\232/Computer.cs" new file mode 100644 index 0000000000000000000000000000000000000000..8db209a9d343d3619a4964f6fcc0e7a311ecbd51 --- /dev/null +++ "b/\351\203\255\347\220\252\346\236\253/\344\270\215\344\274\232\345\201\232/Computer.cs" @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Computer + { + private string name; + + public Computer(string name) + { + this.name = name; + } + + public string Name { get => name; set => name = value; } + + + public int Check() + { + Random ran = new Random(); + int num = ran.Next(1, 4); + switch (num) + { + case 1: + Console.WriteLine("{0}:出拳:剪刀", name); + break; + case 2: + Console.WriteLine("{0}:出拳:石头", name); + break; + case 3: + Console.WriteLine("{0}:出拳:布", name); + break; + } + return num; + } + } +} diff --git "a/\351\203\255\347\220\252\346\236\253/\344\270\215\344\274\232\345\201\232/Player.cs" "b/\351\203\255\347\220\252\346\236\253/\344\270\215\344\274\232\345\201\232/Player.cs" new file mode 100644 index 0000000000000000000000000000000000000000..3ffb3411e5374d6ef3f8bf43eb7a568a1ca209c6 --- /dev/null +++ "b/\351\203\255\347\220\252\346\236\253/\344\270\215\344\274\232\345\201\232/Player.cs" @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Player + { + private string name; + + public Player(string name) + { + this.name = name; + } + + public string Name { get => name; set => name = value; } + public int Really() + { + + Console.WriteLine("请出拳:1.剪刀,2.石头,3.布(输入相应的数字)"); + int num1 = int.Parse(Console.ReadLine()); + switch (num1) + { + case 1: + Console.WriteLine("{0}:出拳:剪刀", name); + break; + case 2: + Console.WriteLine("{0}:出拳:石头", name); + break; + case 3: + Console.WriteLine("{0}:出拳:布", name); + break; + } + return num1; + } + } +} diff --git "a/\351\203\255\347\220\252\346\236\253/\344\270\215\344\274\232\345\201\232/Program.cs" "b/\351\203\255\347\220\252\346\236\253/\344\270\215\344\274\232\345\201\232/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..3ddcb54e0041a66aa91ecddb936de0aed2b6785c --- /dev/null +++ "b/\351\203\255\347\220\252\346\236\253/\344\270\215\344\274\232\345\201\232/Program.cs" @@ -0,0 +1,95 @@ +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("------------------------------------------"); + Console.WriteLine("出拳规则:1.剪刀,2.石头,3.布"); + Console.WriteLine("请选择敌方角色:1.刘备,2.孙权,3.曹操"); + int num = int.Parse(Console.ReadLine()); + string str = Convert.ToString(num); + switch (num) + { + case 1: + str = "刘备"; + break; + case 2: + str = "孙权"; + break; + case 3: + str = "曹操"; + break; + } + Computer computer = new Computer(str); + Console.WriteLine("请输入您的名字"); + string name = Console.ReadLine(); + Player player = new Player(name); + Referee referee = new Referee(name,str); + + switch (num) + { + case 1: + Console.WriteLine(name + " " + "VS" + " " + "刘备" + " " + "对战"); + Test(referee, computer, player); + break; + case 2: + Console.WriteLine(name + " " + "VS" + " " + "孙权" + " " + "对战"); + Test(referee, computer, player); + break; + case 3: + Console.WriteLine(name + " " + "VS" + " " + "曹操" + " " + "对战"); + Test(referee, computer, player); + break; + } + Player player1 = new Player(name); + player1.Really(); + Computer computer1 = new Computer(str); + computer1.Check(); + } + public static void Test(Referee referee, Computer computer, Player player) + { + Console.WriteLine("游戏开始吗?"); + string str = Console.ReadLine(); + switch (str) + { + case "y": + Test1(referee, computer, player); + break; + case "n": + Console.WriteLine("欢迎下次光临"); + break; + } + } + public static void Test1(Referee referee, Computer computer, Player player) + { + while (true) + { + int n1 = player.Really(); + int n2 = computer.Check(); + referee.Result(n1, n2); + Console.WriteLine("是否进入下一轮(y/n)"); + string str = Console.ReadLine(); + switch (str) + { + case "y": + Test1(referee, computer, player); + break; + case "n": + referee.Finally(); + break; + } + } + } + } + +} diff --git "a/\351\203\255\347\220\252\346\236\253/\344\270\215\344\274\232\345\201\232/Referee.cs" "b/\351\203\255\347\220\252\346\236\253/\344\270\215\344\274\232\345\201\232/Referee.cs" new file mode 100644 index 0000000000000000000000000000000000000000..c6403b4b7ce3aa0366073bbba7ff8316dbbc5e0e --- /dev/null +++ "b/\351\203\255\347\220\252\346\236\253/\344\270\215\344\274\232\345\201\232/Referee.cs" @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Referee + { + private string name; + private string name1; + + + + int sum = 0; + int sum1 = 0; + int sum2 = 0; + + public string Name { get => name; set => name = value; } + public string Name1 { get => name1; set => name1 = value; } + + public Referee(string name, string name1) + { + this.Name = name; + this.Name1 = name1; + } + + public void Result(int n1, int n2) + { + if (n1 - n2 == -2 || n1 - n2 == 1) + { + Console.WriteLine("恭喜,{0}赢了", name); + sum++; + sum1++; + } + else if (n1 == n2) + { + Console.WriteLine("和局,真衰,嘿嘿,走着瞧"); + sum++; + } + else + { + Console.WriteLine("笨蛋,{0}输了", name); + sum++; + sum2++; + } + } + public void Finally() + { + Console.WriteLine("================================"); + Console.WriteLine("{0} VS {1}",name,name1); + Console.WriteLine("对战次数", sum); + Console.WriteLine("姓名{0},得分{1}", name, sum1); + Console.WriteLine("姓名{0},得分{1}", name1, sum2); + if (sum1 > sum2) + { + Console.WriteLine("{0}赢,{1}笨蛋", name, name1); + } + else if (sum1 == sum2) + { + Console.WriteLine("和局,真衰,嘿嘿,走着瞧"); + } + else + { + Console.WriteLine("{0}赢,{1}笨蛋", name1, name); + } + } + } +} diff --git "a/\351\203\255\347\220\252\346\236\253/\345\210\253\347\234\213\344\272\206/PersonClass.cs" "b/\351\203\255\347\220\252\346\236\253/\345\210\253\347\234\213\344\272\206/PersonClass.cs" new file mode 100644 index 0000000000000000000000000000000000000000..9a4bcdafcee1803ea8ac0ec4c5ec67e85855901d --- /dev/null +++ "b/\351\203\255\347\220\252\346\236\253/\345\210\253\347\234\213\344\272\206/PersonClass.cs" @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class PersonClass + { + public string name; + public string num; + public string address; + + public PersonClass(string name,string num,string address) + { + this.name = name; + this.num = num; + this.address = address; + } + } +} diff --git "a/\351\203\255\347\220\252\346\236\253/\345\210\253\347\234\213\344\272\206/Program.cs" "b/\351\203\255\347\220\252\346\236\253/\345\210\253\347\234\213\344\272\206/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..5cbcf1ed10438e74564e2fc6d4cb9b7d1fb47301 --- /dev/null +++ "b/\351\203\255\347\220\252\346\236\253/\345\210\253\347\234\213\344\272\206/Program.cs" @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + public struct PersonStruct + { + public string name; + public string num; + public string address; + + public PersonStruct(string name, string num, string address) + { + this.name = name; + this.num = num; + this.address = address; + } + } + class Program + { + // 定义一个结构体,名为PersonStruct,有三个成员变量:姓名、电话、地址, + //在主方法中,创建一个PersonStruct结构体对象p1,为p1的成员变量赋值。 + //再声明一个PersonStruct结构体变量p2,把p1赋值给p2,改变p2的姓名,打印p1的内容。 + //定义一个类,名为PersonClass,有三个成员变量:姓名、电话、地址, + //在主方法中,创建一个PersonClass对象p3,为p3的成员变量赋值。 + //再声明一个PersonClass变量p4,把p3赋值给p4,改变p4的姓名,打印p3的内容。 + //观察打印结果,并在在注释中,说下你对此的认识(它们为什么会这样?) + static void Main(string[] args) + { + PersonStruct p1 = new PersonStruct(); + p1.name = "吴一"; + p1.num = "12345678999"; + p1.address = "莆田"; + + PersonStruct p2 ; + p2.name = "吴二"; + p2 = p1; + Console.WriteLine("姓名:{0},电话号码:{1},家庭住址:{2}",p1.name,p1.num,p1.address); + + PersonClass p3 = new PersonClass("吴三","98765432111","莆田"); + PersonClass p4; + p4 = p3; + p4.name = "吴四"; + Console.WriteLine("姓名:{0},电话号码:{1},家庭住址:{2}", p3.name, p3.num, p3.address); + + + } + } +} diff --git "a/\351\231\210\346\225\217\351\222\212/Program.cs" "b/\351\231\210\346\225\217\351\222\212/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..8d568abac75481d2807afabeb1fa61655c4dbe15 --- /dev/null +++ "b/\351\231\210\346\225\217\351\222\212/Program.cs" @@ -0,0 +1,144 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Program + { + + enum enrole + { + 刘备 = 1, + 孙权 = 2, + 曹操 = 3 + } + enum enMora + { + 石头 = 1, + 剪刀 = 2, + 布 = 3 + } + static void Main(string[] args) + { + //人物类 出的选型类 + + Console.WriteLine("-----------欢迎进入游戏世界-----------" + "\n"); + Console.WriteLine("************************"); + Console.WriteLine("********猜拳开始********"); + Console.WriteLine("************************"); + Console.WriteLine("出拳规则:1.剪刀2.石头3.布"); + Console.WriteLine("请选择对方的角色(1:刘备2.孙权3.曹操)"); + int numname = int.Parse(Console.ReadLine()); + string npcstr = Enum.GetName(typeof(enrole), numname); //NPC姓名 npcstr + + Role role = new Role(npcstr); //获取名字后传入类重写 + Console.WriteLine("请输入您的姓名"); // 玩家姓名 playname + string playname = Console.ReadLine(); + + Console.WriteLine(playname + " VS " + npcstr); + + Console.WriteLine("是否开始游戏(y/n)"); + char char1 = Convert.ToChar(Console.ReadLine()); + if (char1 == 'y' || char1 == 'Y') + { + WinMora(role, npcstr, playname); + + } + else if(char1 == 'n' || char1 == 'N') + { + Console.WriteLine("退出游戏"); + } + Console.WriteLine("要开始下一局游戏吗?(y/n)"); + char char3 = Convert.ToChar(Console.ReadLine()); + if (char3 == 'y' || char3 == 'Y') + { + WinMora(role, npcstr, playname); + + } + else if (char3 == 'n' || char3 == 'N') + { + Console.WriteLine("退出程序"); + System.Environment.Exit(0); + } + } + + private static void WinMora(Role role, string npcstr, string playname) + { + + + int draw = 0; + int NPCwin = 0; + int Playwin = 0; + + while (true) + { + Console.WriteLine("请出拳1.石头2.剪刀3.布请输入数字(请输入相应的数字)"); + int Moranum = int.Parse(Console.ReadLine()); + string playMora = Enum.GetName(typeof(enMora), Moranum); //获取用户输入的数字转化为相应的枚举里的值 + + Console.WriteLine(playname + " : 出拳: " + playMora); + role.Write(); + + if (role.StrMora == playMora) + { + Console.WriteLine("平局,放你一马"); + draw = draw + 1; + } + else if (playMora == "石头" && role.StrMora == "剪刀" || playMora == "布" && role.StrMora == "石头" || playMora == "剪刀" && role.StrMora == "布") + { + Console.WriteLine("恭喜您,勇夺三军,天下无双"); + Playwin = Playwin + 1; + } + else if (role.StrMora == "剪刀" && playMora == "布" || role.StrMora == "石头" && playMora == "剪刀" || role.StrMora == "布" && playMora == "石头") + { + Console.WriteLine("天啦噜,难以置信,这也会输"); + NPCwin = NPCwin + 1; + } + else if (playMora != "石头" || playMora != "剪刀" || playMora != "布") + { + NPCwin = NPCwin + 1; + Console.WriteLine("玩家,出拳不符合规则默认判负"); + } + + Console.WriteLine("是否开始下一局(y/n)"); + char char2 = Convert.ToChar(Console.ReadLine()); + if (char2 == 'y' || char2 == 'Y') + { + + } + else if(char2 == 'n' || char2 == 'N') + { + Console.WriteLine("结束游戏"); + Console.WriteLine("==========================="); + Console.WriteLine(playname + " VS " + npcstr); + Console.WriteLine("对战次数" + (Playwin + NPCwin + draw)); + Console.WriteLine("姓名 得分"); + Console.WriteLine($"{playname} {Playwin}"); + Console.WriteLine($"{npcstr} {NPCwin}"); + if (Playwin > NPCwin) + { + Console.WriteLine( "玩家 "+playname+" 胜出,举世同庆"); + } + else if (NPCwin > Playwin) + { + Console.WriteLine( "电脑"+ npcstr+"胜出,棋差一手"); + } + else + { + Console.WriteLine("平局"); + } + break; + } + + + } + } + } + + +} + + diff --git "a/\351\231\210\346\225\217\351\222\212/Role.cs" "b/\351\231\210\346\225\217\351\222\212/Role.cs" new file mode 100644 index 0000000000000000000000000000000000000000..2970a348aa51a9de886523e6d5e30f4896d4161f --- /dev/null +++ "b/\351\231\210\346\225\217\351\222\212/Role.cs" @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Role + { + private string name; + private string strmora; + public string Name { get; set; } + public string StrMora + { + get { return this.strmora; } + set { this.strmora=value; } + + } + + public Role(string name) + { + this.Name = name; + } + public void Test(string strmora) + { + + Random random = new Random(); + + + if (random.Next(1, 4) == 1) + { + strmora = "石头"; + } + else if (random.Next(1, 4) == 2) + { + strmora = "布"; + } + else if (random.Next(1, 4) == 3) + { + strmora = "剪刀"; + } + + this.StrMora = strmora; + + + } + public void Write() + { + Test(strmora); + StrMora = strmora; + Console.WriteLine("{0}: 出拳 :{1}",Name, StrMora); + + + } + + } +} diff --git "a/\351\237\246\345\244\251\351\255\224\346\234\257\346\243\222/Npc.cs" "b/\351\237\246\345\244\251\351\255\224\346\234\257\346\243\222/Npc.cs" new file mode 100644 index 0000000000000000000000000000000000000000..4b27d0f49f75da8609ec4dd5f3486e2833c96601 --- /dev/null +++ "b/\351\237\246\345\244\251\351\255\224\346\234\257\346\243\222/Npc.cs" @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Npc + { + private string _npcname; + private int _nchu; + private int _ying; + + public Npc() { } + + public Npc(string npcname, int nchu) + { + Npcname = npcname; + Nchu = nchu; + } + + public string Npcname { get => _npcname; set => _npcname = value; } + public int Nchu { get => _nchu; set => _nchu = value; } + public int Ying { get => _ying; set => _ying = value; } + + public void Say() + { + switch (Nchu) + { + case 1: + Console.WriteLine("{0}出拳:剪刀", this.Npcname); + break; + case 2: + Console.WriteLine("{0}出拳:石头", this.Npcname); + break; + case 3: + Console.WriteLine("{0}出拳:布", this.Npcname); + break; + default: + break; + } + } + } +} diff --git "a/\351\237\246\345\244\251\351\255\224\346\234\257\346\243\222/Player.cs" "b/\351\237\246\345\244\251\351\255\224\346\234\257\346\243\222/Player.cs" new file mode 100644 index 0000000000000000000000000000000000000000..7c79de4e3b7e1888273f85d08c83769b576091c9 --- /dev/null +++ "b/\351\237\246\345\244\251\351\255\224\346\234\257\346\243\222/Player.cs" @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Player + { + private string _name; + private int _pchu; + private int _ying; + + + public Player() { } + + public Player(string name, int pchu) + { + Name = name; + Pchu = pchu; + } + + public string Name { get => _name; set => _name = value; } + public int Pchu { get => _pchu; set => _pchu = value; } + public int Ying { get => _ying; set => _ying = value; } + + public void Say() + { + switch (Pchu) + { + case 1: + Console.WriteLine("{0}出拳:剪刀", this.Name); + break; + case 2: + Console.WriteLine("{0}出拳:石头", this.Name); + break; + case 3: + Console.WriteLine("{0}出拳:布", this.Name); + break; + default: + break; + } + } + } +} diff --git "a/\351\237\246\345\244\251\351\255\224\346\234\257\346\243\222/Program.cs" "b/\351\237\246\345\244\251\351\255\224\346\234\257\346\243\222/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..fcb2ad58444d26038ce3be882af72c6f051aee18 --- /dev/null +++ "b/\351\237\246\345\244\251\351\255\224\346\234\257\346\243\222/Program.cs" @@ -0,0 +1,165 @@ +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) + { + while (true) + { + Console.WriteLine("-----------欢迎来到野球拳大舞台-------------"); + Console.WriteLine("*************************************************"); + Console.WriteLine("*******************开始击剑**********************"); + Console.WriteLine("*************************************************"); + + Console.WriteLine("出拳规则:1.剪刀,2.石头,3.布"); + Console.WriteLine("请选择您的对手:1::刘备,2:孙权,3:曹操"); + int y = Convert.ToInt32(Console.ReadLine()); + Npc n1 = new Npc(); + switch (y) + { + case 1: + n1.Npcname = "蛇喰梦子"; + break; + case 2: + n1.Npcname = "皇伊月"; + break; + case 3: + n1.Npcname = "生志摩妄"; + break; + default: + break; + } + Console.WriteLine("您的对手为" + n1.Npcname); + Console.WriteLine(); + + Console.WriteLine("请输入您的角色名"); + string name = Console.ReadLine(); + Player p1 = new Player(); + p1.Name = name; + Console.WriteLine("您的角色名为" + p1.Name); + Console.WriteLine(); + Console.WriteLine("是否开始游戏(y/n)"); + string x = Console.ReadLine(); + if (x == "y") + { + Console.WriteLine("{0}Vs{1},Deul!", p1.Name, n1.Npcname); + } + else + { + Console.WriteLine("怂了,就这?"); + Console.WriteLine("不会真有人选n吧不会吧不会吧?"); + } + int Cishu = 0; + int NY = 0; + int PY = 0; + Boolean faalg = true; + while (true) + { + Cai(p1, n1); + Cishu = Cishu + 1; + Console.WriteLine("还继续吗?(y/n)"); + string Jixu = Console.ReadLine(); + + if (Jixu == "n") + { + Console.WriteLine("行吧,输了就想跑呗。"); + faalg = false; + break; + } + } + + Console.WriteLine("============================="); + Console.WriteLine(p1.Name + "VS" + n1.Npcname); + Console.WriteLine("对战次数" + Cishu); + Console.WriteLine("名字-----------得分"); + Console.WriteLine(n1.Npcname + "-----------" + n1.Ying); + Console.WriteLine(p1.Name + "-----------" + p1.Ying); + Console.WriteLine("再来一把?(y/n)"); + string Zai = Console.ReadLine(); + if (Zai=="n") + { + Console.WriteLine("滚吧滚吧,晦气"); + break; + } + } + + } + public static void Cai(Player p1, Npc n1) + { + Console.WriteLine("请出拳:1.剪刀,2.石头,3.布(请输入相应数字)"); + int pchu = Convert.ToInt32(Console.ReadLine()); + Random rd = new Random(); + int nchu = rd.Next(1, 3); + + + p1.Pchu = pchu; + n1.Nchu = nchu; + p1.Say(); + n1.Say(); + + + Pan(p1, n1); + + } + public static void Pan(Player p1, Npc n1) + { + Boolean falg; + if (p1.Pchu==n1.Nchu) + { + Console.WriteLine("平局,真可惜啊"); + } + else + { + if (p1.Pchu>n1.Nchu) + { + if (p1.Pchu==3&&n1.Nchu==1) + { + falg = false;//npc赢 + ny(n1); + Console.WriteLine("你输了,菜不菜啊。"); + } + else + { + falg = true;//玩家赢 + py(p1); + Console.WriteLine("让你一把而已。"); + } + } + else if(n1.Nchu>p1.Pchu) + { + if (n1.Nchu==3&&p1.Pchu==1) + { + falg = true;//玩家赢 + py(p1); + Console.WriteLine("让你一把而已。"); + } + else + { + falg = false;//npc赢 + ny(n1); + Console.WriteLine("你输了,菜不菜啊。"); + } + } + + + } + } + public static Player py(Player p1) + { + p1.Ying =p1.Ying + 1; + return p1; + } + public static Npc ny(Npc n1) + { + n1.Ying=n1.Ying + 1; + return n1; + } + + } +} diff --git "a/\351\237\246\346\230\214\345\235\244/\347\214\234\346\213\263\346\270\270\346\210\217/Ad.cs" "b/\351\237\246\346\230\214\345\235\244/\347\214\234\346\213\263\346\270\270\346\210\217/Ad.cs" new file mode 100644 index 0000000000000000000000000000000000000000..890868ee32a5a6dff896d2fc3d6d984a4ea23d4e --- /dev/null +++ "b/\351\237\246\346\230\214\345\235\244/\347\214\234\346\213\263\346\270\270\346\210\217/Ad.cs" @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp14 +{ + class Ad + { + private string name; + + public Ad(string name) + { + this.name = name; + } + + public string Name { get => name; set => name = value; } + + public int Test1() + { + Console.WriteLine("请你选择出拳:1.剪刀 2.石头 3.布"); + int k = int.Parse(Console.ReadLine()); + switch (k) + { + case 1: + Console.WriteLine("{0}出了一个剪刀",name); + break; + case 2: + Console.WriteLine("{0}出了一个石头", name); + break; + case 3: + Console.WriteLine("{0}出了一个布",name); + break; + } + + return k; + } + } +} diff --git "a/\351\237\246\346\230\214\345\235\244/\347\214\234\346\213\263\346\270\270\346\210\217/Judgment.cs" "b/\351\237\246\346\230\214\345\235\244/\347\214\234\346\213\263\346\270\270\346\210\217/Judgment.cs" new file mode 100644 index 0000000000000000000000000000000000000000..51c1f531807f9b3271002118ec7a621421dfea6f --- /dev/null +++ "b/\351\237\246\346\230\214\345\235\244/\347\214\234\346\213\263\346\270\270\346\210\217/Judgment.cs" @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp14 +{ + class Judgment + { + int sum1 = 0; + int sum2 = 0; + int sum3 = 0; + int sum4 = 0; + + public void Date(int p1, int p2) + { + if (p1 - p2 == -2 || p1 - p2 == 1) + { + Console.WriteLine("玩家胜利!"); + sum2++; + } + else if (p1 == p2) + { + Console.WriteLine("平局"); + sum3++; + } + else + { + Console.WriteLine("玩家失败!"); + sum4++; + } + sum1 = sum2 + sum3 + sum4; + + } + + + internal void Date1() + { + Console.WriteLine("你的胜场数:{0}", sum2); + Console.WriteLine("对手胜场数:{0}", sum4); + Console.WriteLine("平局场数:{0}", sum3); + Console.WriteLine("总场数:{0}", sum1); + if (sum2 > sum4) + { + Console.WriteLine("你赢了"); + } + else if (sum2 < sum4) + { + Console.WriteLine("你输了"); + } + else if (sum2 == sum4) + { + Console.WriteLine("平局"); + } + } + } +} \ No newline at end of file diff --git "a/\351\237\246\346\230\214\345\235\244/\347\214\234\346\213\263\346\270\270\346\210\217/Mdf.cs" "b/\351\237\246\346\230\214\345\235\244/\347\214\234\346\213\263\346\270\270\346\210\217/Mdf.cs" new file mode 100644 index 0000000000000000000000000000000000000000..1e5802b63b71fd500014d8a88f9db1fee37596f6 --- /dev/null +++ "b/\351\237\246\346\230\214\345\235\244/\347\214\234\346\213\263\346\270\270\346\210\217/Mdf.cs" @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp14 +{ + class Npc : Ad + { + private string name1; + + public Npc(string name, string name1) : base(name) + { + this.Name1 = name1; + + } + + public string Name1 { get => name1; set => name1 = value; } + + public int MDF1() + { + Random random = new Random(); + int result = random.Next(1, 4); + string str = Convert.ToString(result); + switch (result) + { + case 1: + str = "剪刀"; + break; + case 2: + str = "石头"; + break; + case 3: + str = "布"; + break; + } + Console.WriteLine("{0}出了一个{1}",name1,str); + return result; + } + } +} \ No newline at end of file diff --git "a/\351\237\246\346\230\214\345\235\244/\347\214\234\346\213\263\346\270\270\346\210\217/Program.cs" "b/\351\237\246\346\230\214\345\235\244/\347\214\234\346\213\263\346\270\270\346\210\217/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..557a788d302be946eb9bf99660f1efcc6ed58a8a --- /dev/null +++ "b/\351\237\246\346\230\214\345\235\244/\347\214\234\346\213\263\346\270\270\346\210\217/Program.cs" @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp14 +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("---------------欢 迎 进 入 英 雄 联 盟 猜 拳 游 戏--------------"); + Console.WriteLine(); + Console.WriteLine("*********************猜拳开始***********************"); + Console.WriteLine(); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Console.WriteLine("请输入你的名字"); + string name = Console.ReadLine(); + Me me = new Me(name); + + Judgment judgment = new Judgment(); + Console.WriteLine("请选择你对战的角色:1.迪莫 2.小法 3.亚索"); + int a = int.Parse(Console.ReadLine()); + string str = Convert.ToString(a); + switch (str) + { + case "1": + str = "迪莫"; + break; + case "2": + str = "小法"; + break; + case "3": + str = "亚索"; + break; + default: + break; + } + + Mdf mdf = new Mdf(name,str); + switch (a) + { + case 1: + Console.WriteLine("{0} vs 迪莫", name); + dong(ad,mdf,judgment); + break; + case 2: + Console.WriteLine("{0} vs 小法", name); + dong(ad, mdf, judgment); + break; + case 3: + Console.WriteLine("{0} vs 亚索", name); + dong(ad, mdf, judgment); + break; + default: + break; + + } + + } + public static void dong(Ad ad,Mdf mdf,Judgment judgment) + { + + Console.WriteLine("游戏开始吗?"); + string str = Console.ReadLine(); + switch (str) + { + case "y": + dong2(ad, mdf, judgment); + break; + case "n": + + break; + } + } + public static void dong2(Ad ad, Mdf mdf, Judgment judgment) { + while (true) + { + int p1 = ad.Test1(); + int p2 = mdf.NPC1(); + judgment.Date(p1,p2); + Console.WriteLine("是否进行下一轮?"); + string str = Console.ReadLine(); + switch (str) + { + case "y": + dong2(ad, mdf, judgment); + break; + case "n": + judgment.Date1(); + break; + } + break; + } + } + } + } diff --git "a/\351\253\230\345\245\225/.keep" "b/\351\253\230\345\245\225/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\351\253\230\345\245\225/Program.cs" "b/\351\253\230\345\245\225/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..d893a4d8f325d65a3b7466995ff1536bee190740 --- /dev/null +++ "b/\351\253\230\345\245\225/Program.cs" @@ -0,0 +1,144 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Program + { + + enum enrole + { + 刘备 = 1, + 孙权 = 2, + 曹操 = 3 + } + enum enMora + { + 石头 = 1, + 剪刀 = 2, + 布 = 3 + } + static void Main(string[] args) + { + //人物类 出的选型类 + + Console.WriteLine("-----------欢迎进入游戏世界-----------" + "\n"); + Console.WriteLine("************************"); + Console.WriteLine("********猜拳开始********"); + Console.WriteLine("************************"); + Console.WriteLine("出拳规则:1.剪刀2.石头3.布"); + Console.WriteLine("请选择对方的角色(1:刘备2.孙权3.曹操)"); + int numname = int.Parse(Console.ReadLine()); + string npcstr = Enum.GetName(typeof(enrole), numname); //NPC姓名 npcstr + + Role role = new Role(npcstr); //获取名字后传入类重写 + Console.WriteLine("请输入您的姓名"); // 玩家姓名 playname + string playname = Console.ReadLine(); + + Console.WriteLine(playname + " VS " + npcstr); + + Console.WriteLine("是否开始游戏(y/n)"); + char char1 = Convert.ToChar(Console.ReadLine()); + if (char1 == 'y' || char1 == 'Y') + { + WinMora(role, npcstr, playname); + + } + else if(char1 == 'n' || char1 == 'N') + { + Console.WriteLine("退出游戏"); + } + Console.WriteLine("要开始下一局游戏吗?(y/n)"); + char char3 = Convert.ToChar(Console.ReadLine()); + if (char3 == 'y' || char3 == 'Y') + { + WinMora(role, npcstr, playname); + + } + else if (char3 == 'n' || char3 == 'N') + { + Console.WriteLine("退出程序"); + System.Environment.Exit(0); + } + } + + private static void WinMora(Role role, string npcstr, string playname) + { + + + int draw = 0; + int NPCwin = 0; + int Playwin = 0; + + while (true) + { + Console.WriteLine("请出拳1.石头2.剪刀3.布请输入数字(请输入相应的数字)"); + int Moranum = int.Parse(Console.ReadLine()); + string playMora = Enum.GetName(typeof(enMora), Moranum); //获取用户输入的数字转化为相应的枚举里的值 + + Console.WriteLine(playname + " : 出拳: " + playMora); + role.Write(); + + if (role.StrMora == playMora) + { + Console.WriteLine("平局,放你一马"); + draw = draw + 1; + } + else if (playMora == "石头" && role.StrMora == "剪刀" || playMora == "布" && role.StrMora == "石头" || playMora == "剪刀" && role.StrMora == "布") + { + Console.WriteLine("恭喜您,勇夺三军,天下无双"); + Playwin = Playwin + 1; + } + else if (role.StrMora == "剪刀" && playMora == "布" || role.StrMora == "石头" && playMora == "剪刀" || role.StrMora == "布" && playMora == "石头") + { + Console.WriteLine("天啦噜,难以置信,这也会输"); + NPCwin = NPCwin + 1; + } + else if (playMora != "石头" || playMora != "剪刀" || playMora != "布") + { + NPCwin = NPCwin + 1; + Console.WriteLine("玩家,出拳不符合规则默认判负"); + } + + Console.WriteLine("是否开始下一局(y/n)"); + char char2 = Convert.ToChar(Console.ReadLine()); + if (char2 == 'y' || char2 == 'Y') + { + + } + else if(char2 == 'n' || char2 == 'N') + { + Console.WriteLine("结束游戏"); + Console.WriteLine("==========================="); + Console.WriteLine(playname + " VS " + npcstr); + Console.WriteLine("对战次数" + (Playwin + NPCwin + draw)); + Console.WriteLine("姓名 得分"); + Console.WriteLine($"{playname} {Playwin}"); + Console.WriteLine($"{npcstr} {NPCwin}"); + if (Playwin > NPCwin) + { + Console.WriteLine( "玩家 "+playname+" 胜出,举世同庆"); + } + else if (NPCwin > Playwin) + { + Console.WriteLine( "电脑"+ npcstr+"胜出,棋差一手"); + } + else + { + Console.WriteLine("平局"); + } + break; + } + + + } + } + } + + +} + + diff --git "a/\351\253\230\345\245\225/Role.cs" "b/\351\253\230\345\245\225/Role.cs" new file mode 100644 index 0000000000000000000000000000000000000000..bcfcb4c43d5ffd1d56794b770b63643c23cfc5aa --- /dev/null +++ "b/\351\253\230\345\245\225/Role.cs" @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Role + { + private string name; + private string strmora; + public string Name { get; set; } + public string StrMora + { + get { return this.strmora; } + set { this.strmora=value; } + + } + + public Role(string name) + { + this.Name = name; + } + public void Test(string strmora) + { + + Random random = new Random(); + + + if (random.Next(1, 4) == 1) + { + strmora = "石头"; + } + else if (random.Next(1, 4) == 2) + { + strmora = "布"; + } + else if (random.Next(1, 4) == 3) + { + strmora = "剪刀"; + } + + this.StrMora = strmora; + + + } + public void Write() + { + Test(strmora); + StrMora = strmora; + Console.WriteLine("{0}: 出拳 :{1}",Name, StrMora); + + + } + + } +} diff --git "a/\351\273\204\345\277\240\347\243\212/Program.cs" "b/\351\273\204\345\277\240\347\243\212/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..5c94b60890b716a0aed06f8f1e93fb4486e876c0 --- /dev/null +++ "b/\351\273\204\345\277\240\347\243\212/Program.cs" @@ -0,0 +1,347 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp15 +{ + public enum e + { + 石头 = 1, + 剪刀, + 布 + } + public enum e1 + { + 刘备=1, + 曹操 = 2, + 孙权, + + } + class Program + { + static void Main(string[] args) + { + Console.WriteLine("《---------------欢迎来到游戏世界---------------》"); + Console.WriteLine("******************************************"); + Console.WriteLine("******************猜拳开始****************"); + Console.WriteLine("******************************************"); + Console.WriteLine("出拳规则:1.石头,2.剪刀,3.布"); + Console.WriteLine("请选择敌方: 1.刘备,2.孙权,3.曹操"); + int num = int.Parse(Console.ReadLine()); + + switch (num) + { + + + case 1: + + test(); + break; + + case 2: + test(); + break; + + case 3: + test(); + + break; + + } + + + } + static void test() + { + ArrayList array = new ArrayList(); + people pe = new people(); + pe.Name = "刘备"; + people pe1 = new people(); + pe1.Name = "孙权"; + people pe2 = new people(); + pe2.Name = "曹操"; + array.Add(pe); + array.Add(pe1); + array.Add(pe2); + int SUM = 0; + int A = 0; + int B = 0; + Random r = new Random(); + Console.WriteLine("请输入你的姓名"); + string a = Console.ReadLine(); + Console.WriteLine(a + " VS " + pe.Name); + + Console.WriteLine(); + + Console.WriteLine("开始游戏吗Y/N"); + string d = Console.ReadLine(); + if (d == "Y") + { + Console.WriteLine("请出拳:1.石头,2.剪刀,3.布(输入相应数字)"); + int num2 = int.Parse(Console.ReadLine()); + SUM++; + if (num2 == (int)e.石头) + { + Console.WriteLine(a + " :石头 "); + Console.WriteLine(); + if (num2 < r.Next((int)1.4)) + { + Console.WriteLine(pe.Name + ": " + e.布); + Console.WriteLine(a + "输了你是大笨蛋"); + B++; + + } + else if (num2 == r.Next((int)1.4)) + { + Console.WriteLine(pe.Name + ": " + e.石头); + Console.WriteLine(a + "平局不要打了"); + } + else + { + Console.WriteLine(pe.Name + ": " + e.剪刀); + Console.WriteLine(a + "赢了你是大哥大"); + A++; + } + } + + if (num2 == (int)e.剪刀) + { + if (num2 < r.Next((int)1.4)) + { + Console.WriteLine(pe.Name + ": " + e.布); + Console.WriteLine(a + "赢了你是大哥大"); + A++; + } + else if (num2 == r.Next((int)1.4)) + { + Console.WriteLine(pe.Name + ": " + e.剪刀); + Console.WriteLine(a + "平局不要打了"); + } + else + { + Console.WriteLine(pe.Name + ": " + e.石头); + Console.WriteLine(a + "输了你是大笨蛋"); + B++; + } + } + if (num2 == (int)e.布) + { + + + if (num2 < r.Next((int)1.4)) + { + Console.WriteLine(pe.Name + ": " + e.剪刀); + Console.WriteLine(a + "输了你是大笨蛋"); + B++; + } + else if (num2 == r.Next((int)1.4)) + { + Console.WriteLine(pe.Name + ": " + e.布); + Console.WriteLine(a + "平局不要打了"); + } + else + { + Console.WriteLine(pe.Name + ": " + e.石头); + Console.WriteLine(a + "赢了你是大哥大"); + A++; + } + } + } + else if (d == "N") + { + Console.WriteLine("退出成功"); + + } + Console.WriteLine("是否开始游戏吗Y/N"); + String C = Console.ReadLine(); + SUM++; + if (C == "Y") + { + Console.WriteLine("请出拳:1.石头,2.剪刀,3.布(输入相应数字)"); + int num3 = int.Parse(Console.ReadLine()); + if (num3 == (int)e.石头) + { + Console.WriteLine(a + " :石头 "); + Console.WriteLine(); + if (num3 < r.Next((int)1.4)) + { + Console.WriteLine(pe.Name + ": " + e.布); + Console.WriteLine(a + "输了你是大笨蛋"); + + B++; + } + else if (num3 == r.Next((int)1.4)) + { + Console.WriteLine(pe.Name + ": " + e.石头); + Console.WriteLine(a + "平局不要打了"); + } + else + { + Console.WriteLine(pe.Name + ": " + e.剪刀); + Console.WriteLine(a + "赢了你是大哥大"); + A++; + } + } + if (num3 == (int)e.剪刀) + { + if (num3 < r.Next((int)1.4)) + { + Console.WriteLine(pe.Name + ": " + e.布); + Console.WriteLine(a + "赢了你是大哥大"); + A++; + } + else if (num3 == r.Next((int)1.4)) + { + Console.WriteLine(pe.Name + ": " + e.剪刀); + Console.WriteLine(a + "平局不要打了"); + } + else + { + Console.WriteLine(pe.Name + ": " + e.石头); + Console.WriteLine(a + "输了你是大笨蛋"); + B++; + } + } + + if (num3 == (int)e.布) + { + + + if (num3 < r.Next((int)1.4)) + { + Console.WriteLine(pe.Name + ": " + e.剪刀); + Console.WriteLine(a + "输了你是大笨蛋"); + B++; + } + else if (num3 == r.Next((int)1.4)) + { + Console.WriteLine(pe.Name + ": " + e.布); + Console.WriteLine(a + "平局不要打了"); + } + else + { + Console.WriteLine(pe.Name + ": " + e.石头); + Console.WriteLine(a + "赢了你是大哥大"); + A++; + } + } + + } + else if (d == "N") + { + Console.WriteLine("退出成功"); + + } + Console.WriteLine("是否开始游戏吗Y/N"); + String CC = Console.ReadLine(); + SUM++; + if (CC == "Y") + { + Console.WriteLine("请出拳:1.石头,2.剪刀,3.布(输入相应数字)"); + int num4 = int.Parse(Console.ReadLine()); + if (num4 == (int)e.石头) + { + Console.WriteLine(a + " :石头 "); + Console.WriteLine(); + if (num4 < r.Next((int)1.4)) + { + Console.WriteLine(pe.Name + ": " + e.布); + Console.WriteLine(a + "输了你是大笨蛋"); + B++; + } + else if (num4 == r.Next((int)1.4)) + { + Console.WriteLine(pe.Name + ": " + e.石头); + Console.WriteLine(a + "平局不要打了"); + } + else + { + Console.WriteLine(pe.Name + ": " + e.剪刀); + Console.WriteLine(a + "赢了你是大哥大"); + A++; + } + } + + if (num4 == (int)e.剪刀) + { + if (num4 < r.Next((int)1.4)) + { + Console.WriteLine(pe.Name + ": " + e.布); + Console.WriteLine(a + "赢了你是大哥大"); + A++; + } + else if (num4 == r.Next((int)1.4)) + { + Console.WriteLine(pe.Name + ": " + e.剪刀); + Console.WriteLine(a + "平局不要打了"); + } + else + { + Console.WriteLine(pe.Name + ": " + e.石头); + Console.WriteLine(a + "输了你是大笨蛋"); + B++; + } + } + if (num4 == (int)e.布) + { + + if (num4 < r.Next((int)1.4)) + { + Console.WriteLine(pe.Name + ": " + e.剪刀); + Console.WriteLine(a + "输了你是大笨蛋"); + B++; + } + else if (num4 == r.Next((int)1.4)) + { + Console.WriteLine(pe.Name + ": " + e.布); + Console.WriteLine(a + "平局不要打了"); + } + else + { + Console.WriteLine(pe.Name + ": " + e.石头); + Console.WriteLine(a + "赢了你是大哥大"); + A++; + } + } + } + + else if (d == "N") + { + Console.WriteLine("退出成功"); + + } + Console.WriteLine("-------------------------------"); + Console.WriteLine("对战次数" + SUM); + Console.WriteLine("姓名", "得分"); + Console.WriteLine(a + "次数"+A); + Console.WriteLine(pe.Name + "次数" + B); + if (A>B) + { + Console.WriteLine(a+":赢咯"); + + } + else + { + Console.WriteLine(B+ ":赢咯"); + } + + Console.WriteLine(); + Console.WriteLine(); + Console.WriteLine("是否开始游戏吗Y/N"); + string qq = Console.ReadLine(); + if (qq == "Y") + { + Console.WriteLine("玩个屁"); + } + else + { + Console.WriteLine("休息休息休息休息"); + } + } + } + } + + diff --git "a/\351\273\204\345\277\240\347\243\212/people.cs" "b/\351\273\204\345\277\240\347\243\212/people.cs" new file mode 100644 index 0000000000000000000000000000000000000000..833bb81bc69abf61c6c8b27057551e9645194056 --- /dev/null +++ "b/\351\273\204\345\277\240\347\243\212/people.cs" @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp15 +{ + class people + { + private string name; + private int telephlone; + private string addes; + + public string Name { get => name; set => name = value; } + public int Telephlone { get => telephlone; set => telephlone = value; } + public string Addes { get => addes; set => addes = value; } + + public people(string name, + string addes, + int telephlone) + + { + + this.Addes = addes; + this.Name = name; + this.Telephlone = telephlone; + } + public people() + + { } + } +}