diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/.keep" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\215\242\345\256\201/.keep" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\215\242\345\256\201/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\215\242\345\256\201/Game.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\215\242\345\256\201/Game.cs" new file mode 100644 index 0000000000000000000000000000000000000000..d0fad88a18fb38e3cd6244ac5b29bacef9af39b0 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\215\242\345\256\201/Game.cs" @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Game + { + private object userName; + private object wayName; + + public bool Gaming(Way way, User user) + { + int sum = 0; + int lNum = 0; + int nNum = 0; + while (true) + { + string wayAction; + string userAction; + userAction = user.Action(); + Console.WriteLine(user.Name + " :出拳: " + userAction); + wayAction = way.Action(); + Console.WriteLine(way.Name + " :出拳: " + wayAction); + IsWin(wayAction, userAction, user.Name, ref nNum); + + //Console.WriteLine(IsWin(wayAction, userAction, user.Name, ref lNum, ref nNum)); + + sum++; + while (true) + { + Console.WriteLine("是否开始下一轮?(1.继续 / 2.停止)"); + string a = Console.ReadLine(); + if (a == "1") + { + break; + } + else if (a == "2") + { + return EndGame(way.Name, user.Name, sum, lNum, nNum); + } + else + { + Console.WriteLine("输入错误,请重新输入!"); + continue; + } + } + } + } + + private void IsWin(string wayAction, string userAction, string name, ref int nNum) + { + throw new NotImplementedException(); + } + + private bool EndGame(string name1, string name2, int sum, int lNum, int nNum) + { + Console.WriteLine("========================="); + Console.WriteLine("对战次数:" + sum); + + Console.WriteLine("姓名 \t 得分"); + Console.WriteLine(userName + "\t" + nNum); + Console.WriteLine(wayName + "\t" + lNum); + if (lNum > nNum) + { + Console.WriteLine($"{userName}赢了,{wayName}输了"); + } + else + { + Console.WriteLine("平局"); + } + while (true) + { + Console.WriteLine("要开始下一局吗?(y/n)"); + string a = Console.ReadLine(); + switch (a) + { + case "y": + return true; + case "n": + return false; + default: + Console.WriteLine("选择错误,请重新输入!"); + continue; + } + } + } + + public void IsWin(string wayAction, string userAction, string name, ref int lNum, ref int nNum) + { + string str; + if ((wayAction == "剪刀" && userAction == "布") || (wayAction == "石头" && userAction == "剪刀") || wayAction == "布" && userAction == "石头") + { + lNum++; + Console.WriteLine($"笨蛋,{name}输了"); + } + else if (wayAction == userAction) + { + Console.WriteLine($"和局,太可惜了!"); + } + else + { + nNum++; + Console.WriteLine($"恭喜,{name}赢了!"); + } + + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\215\242\345\256\201/Person.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\215\242\345\256\201/Person.cs" new file mode 100644 index 0000000000000000000000000000000000000000..ef4bc6ae5e446beb47c134ac51581ad526c81c53 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\215\242\345\256\201/Person.cs" @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Person + { + public string Name { get; set; } + public Person() + { + + } + public Person(string name) + { + Name = name; + } + public virtual string Action() + { + return null; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\215\242\345\256\201/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\215\242\345\256\201/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..8b85581e3b7e9eef5d9df16267ff0921bebc7dae --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\215\242\345\256\201/Program.cs" @@ -0,0 +1,88 @@ +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("-----------------欢迎进入游戏世界!-----------------"); + while (true) + { + Console.WriteLine("**********************"); + Console.WriteLine("********猜拳,开始******"); + Console.WriteLine("**********************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Way way = WayCreate(); + User user = UserCreate(); + bool IsStart = Start(); + if (!IsStart) + { + Console.WriteLine("系统退出!"); + return; + } + else + { + Console.WriteLine(way.Name + " VS " + user.Name + " 对战 "); + } + Game game = new Game(); + bool IsCountine = game.Gaming(way, user); + if (!IsCountine) + { + Console.WriteLine("系统退出!"); + return; + } + } + } + public static bool Start() + { + while (true) + { + Console.WriteLine("开始游戏吗?(y/n)"); + string a = Console.ReadLine(); + switch (a) + { + case "y": + return true; + case "n": + return false; + default: + Console.WriteLine("选择错误,请重新输入!"); + continue; + } + } + } + private static Way WayCreate() + { + while (true) + { + Console.WriteLine("请选择对方角色<1.刘备 2.孙权 3.曹操"); + Console.Write("请选择:"); + string a = Console.ReadLine(); + switch (a) + { + case "1": + return new Way("刘备"); + case "2": + return new Way("孙权"); + case "3": + return new Way("曹操"); + default: + Console.WriteLine("选择错误,请重新输入!"); + continue; + } + } + } + + private static User UserCreate() + { + Console.WriteLine("请输入您的姓名"); + string userName = Console.ReadLine(); + return new User(userName); + } + } + } diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\215\242\345\256\201/User.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\215\242\345\256\201/User.cs" new file mode 100644 index 0000000000000000000000000000000000000000..7359bb6e39abec2a63dfae21ddd386d3da60944f --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\215\242\345\256\201/User.cs" @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class User:Person + { + public User() + { + + } + public User(string name) : base(name) + { + + } + + public string Name { get; internal set; } + + public override string Action() + { + while (true) + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布 (请输入相应的数字:)"); + string a = Console.ReadLine(); + switch (a) + { + case "1": + return " 剪刀"; + case "2": + return " 石头"; + case "3": + return " 布"; + default: + Console.WriteLine("选择错误,请重新输入!"); + continue; + } + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\215\242\345\256\201/Way.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\215\242\345\256\201/Way.cs" new file mode 100644 index 0000000000000000000000000000000000000000..06fa27635116cbfae7c849c79b79256a0824d3d0 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\215\242\345\256\201/Way.cs" @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Way:Person + { + public Way() + { + + } + public Way(string name) : base(name) + { + + } + public override string Action() + { + Random random = new Random(); + int num = random.Next(1, 4); + switch (num) + { + case 1: + return "剪刀"; + case 2: + return "石头"; + case 3: + return "布"; + } + return ""; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\217\266\345\220\257\350\210\252/.keep" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\217\266\345\220\257\350\210\252/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\217\266\345\220\257\350\210\252/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\217\266\345\220\257\350\210\252/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..3f3540815d1d7de5a693f8b0fb0bd849f4e8dbe1 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\217\266\345\220\257\350\210\252/Program.cs" @@ -0,0 +1,173 @@ +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.布"); + Rule rule = new Rule("剪刀"); + Rule rule2 = new Rule("石头"); + Rule rule3 = new Rule("布"); + Console.WriteLine("请输入对方角色<1.刘备 2.孙权 3.曹操>"); + Role role = new Role("刘备"); + Role role2 = new Role("孙权"); + Role role3 = new Role("曹操"); + int rules = int.Parse(Console.ReadLine()); + Console.WriteLine("请输入您的姓名:"); + string name = Console.ReadLine(); + string names = null; + if (rules == 1) + { + Console.WriteLine($"{name} VS {role.Name} 对战"); + names = role.Name; + } + else if (rules == 2) + { + Console.WriteLine($"{name} VS {role2.Name} 对战"); + names = role.Name; + } + else if (rules == 3) + { + Console.WriteLine($"{name} VS {role3.Name} 对战"); + names = role.Name; + } + + + + Console.WriteLine("开始游戏吗?(y/n)"); + string yn = Console.ReadLine(); + int num = 0; + int i = 0; + int y = 0; + switch (yn) + { + case "y": + while (true) + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应的数字:)"); + int rps = int.Parse(Console.ReadLine()); + if (rps == 1) + { + Console.WriteLine($"{name}:出拳:剪刀"); + role.SayHai(); rule.SayHai(); + if (rule.Gegular == "剪刀") + { + Console.WriteLine("和局,真晦气!嘿嘿,等着瞧吧!"); + } + if (rule.Gegular == "石头") + { + Console.WriteLine($"笨蛋,{name}输了"); + y++; + } + if (rule.Gegular == "布") + { + Console.WriteLine($"恭喜,{name}赢了"); + i++; + } + + } + if (rps == 2) + { + Console.WriteLine($"{name}:出拳:石头"); + role2.SayHai(); rule2.SayHai(); + if (rule2.Gegular == "剪刀") + { + Console.WriteLine($"恭喜,{name}赢了"); + i++; + } + if (rule2.Gegular == "石头") + { + Console.WriteLine("和局,真晦气!嘿嘿,等着瞧吧!"); + y++; + } + if (rule2.Gegular == "布") + { + Console.WriteLine($"笨蛋,{name}输了"); + } + + } + if (rps == 3) + { + Console.WriteLine($"{name}:出拳:布"); + role3.SayHai(); rule3.SayHai(); + if (rule3.Gegular == "剪刀") + { + Console.WriteLine($"笨蛋,{name}输了"); + y++; + } + if (rule3.Gegular == "石头") + { + Console.WriteLine($"恭喜,{name}赢了"); + i++; + } + if (rule3.Gegular == "布") + { + Console.WriteLine("和局,真晦气!嘿嘿,等着瞧吧!"); + } + } + num++; + Console.WriteLine("是否开始下一轮?(y/n)"); + string ny = Console.ReadLine(); + if (ny == "y") + { + + } + + if (ny == "n") + { + Console.WriteLine("-----------------------------------------"); + Console.WriteLine($"{name} VS {names}"); + Console.WriteLine($"对战次数:{num}"); + Console.WriteLine("姓名 得分"); + Console.WriteLine($"{name} {i}"); + Console.WriteLine($"{names} {y}"); + if (i > y) + { + Console.WriteLine($"{name}赢,{names}笨蛋"); + } + else if (i < y) + { + Console.WriteLine($"{names}赢,{name}笨蛋"); + + } + else if (i==y) + { + Console.WriteLine("平局"); + } + Console.WriteLine("要开始下一局吗?(y/n)"); + string aa = Console.ReadLine(); + if (aa == "y") + { + Main(null); + } + else if (aa == "n") + { + Console.WriteLine("系统退出!!!"); + break; + } + break; + } + + } + break; + case "n": + Console.WriteLine("系统退出!!!"); + break; + default: + break; + } + Console.ReadLine(); + } + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\217\266\345\220\257\350\210\252/Role.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\217\266\345\220\257\350\210\252/Role.cs" new file mode 100644 index 0000000000000000000000000000000000000000..5bb781663e879dfae7a3b276a8005e5ea1594166 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\217\266\345\220\257\350\210\252/Role.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Role + { + public string Gegular { get; set; } + public string Name { get; set; } + + + public Role(string name) + { + Name = name; + } + + public void SayHai() + { + + Console.Write($"{Name}"); + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\217\266\345\220\257\350\210\252/Rule.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\217\266\345\220\257\350\210\252/Rule.cs" new file mode 100644 index 0000000000000000000000000000000000000000..6cc0ef8658d5809720933f857912eb0f5572c875 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\217\266\345\220\257\350\210\252/Rule.cs" @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Rule + { + public string Gegular { get; set; } + + public Rule(string gegular) + { + Gegular = gegular; + } + public Rule() { } + + public void SayHai() + { + Random ran = new Random(); + int a = ran.Next(1, 4); + if (a == 1) + { + Gegular = "剪刀"; + } + else if (a == 2) + { + Gegular = "石头"; + } + else if (a == 3) + { + Gegular = "布"; + } + Console.WriteLine($": 出拳:{Gegular}"); + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\217\266\350\257\232/ComputerPlayer.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\217\266\350\257\232/ComputerPlayer.cs" new file mode 100644 index 0000000000000000000000000000000000000000..5788e70a8cbe7a31f58b9c962e3eb8c4f5404d5b --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\217\266\350\257\232/ComputerPlayer.cs" @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 剪刀石头布游戏 +{ + class ComputerPlayer : Player + { + static Random rand = new Random(); + public override int getInputValue() + { + int value = rand.Next(1, 4); + if (value == 1) + { + Console.WriteLine("剪刀"); + } + else if (value == 2) + { + Console.WriteLine("石头"); + } + else if (value == 3) + { + Console.WriteLine("布"); + } + return value; + } + + public string getPlayerName(int num) + { + if (num == 1) + { + name = "刘备"; + } + else if (num == 2) + { + name = "孙权"; + } + else if (num == 3) + { + name = "曹操"; + } + return name; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\217\266\350\257\232/Judger.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\217\266\350\257\232/Judger.cs" new file mode 100644 index 0000000000000000000000000000000000000000..ee30e9928e8d255d93ecc6ee8d7e9d0dbe962d78 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\217\266\350\257\232/Judger.cs" @@ -0,0 +1,129 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 剪刀石头布游戏 +{ + class Judger + { + static ComputerPlayer computer = new ComputerPlayer(); + static UserPlayer user = new UserPlayer(); + public bool statr(String inputName, String computName) + { + int comWinCount = 0; + int userWinCount = 0; + bool flag = false; + int count = 1; + string j; + Console.WriteLine("准备开始游戏了吗(y/n)"); + j = Console.ReadLine(); + if (j.Equals("y")) + { + m: do + { + count++; + //玩家出拳 + int userValue = user.getInputValue(); + Console.WriteLine(inputName + "出拳: "); + //电脑出拳 + int comValue = computer.getInputValue(); + Console.WriteLine(computName + "出拳: " ); + //裁判比较 + int result = compare(comValue, userValue); + if (result == 1) + { + Console.WriteLine("笨蛋," + computName + "赢了"); + comWinCount++; + } + else if (result == -1) + { + Console.WriteLine("笨蛋," + inputName + "赢了"); + userWinCount++; + } + else + { + Console.WriteLine("嘿嘿,和局真衰,等着瞧吧"); + } + Console.WriteLine("准备开始游戏了吗(y/n)"); + j = Console.ReadLine(); + switch (j) + { + case "y": + flag = true; + break; + case "n": + Console.WriteLine("=========================================="); + Console.WriteLine(inputName + " VS "+ computName); + Console.WriteLine("对战次数" + count); + Console.WriteLine(); + Console.WriteLine("姓名\t\t得分"); + Console.WriteLine(inputName+"\t\t" + userWinCount); + Console.WriteLine(computName + "\t\t" + comWinCount); + if (userWinCount> comWinCount) + { + Console.WriteLine(inputName+"赢"); + } + else if (userWinCount > comWinCount) + { + Console.WriteLine(computName+"赢"); + } + else + { + Console.WriteLine("平局"); + } + Console.WriteLine("退出系统"); + break; + } + goto m; + } while (flag); + } + else if (j.Equals("n")) + { + Console.WriteLine("系统退出"); + } + return flag; + } + public int compare(int computerValue, int userValue) + { + if (computerValue == userValue) + { + return 0; + } + else if (computerValue == 1)//1 剪刀 + { + if (userValue == 2)//1 石头 + { + return -1; + } + else//3 布 + { + return 1; + } + } + else if (computerValue == 2)//2 石头 + { + if (userValue == 1)// 1 剪刀 + { + return 1; + } + else//3 布 + { + return -1; + } + } + else//3 computerValue==布 + { + if (userValue == 2)//石头 + { + return 1; + } + else// 1 剪刀 + { + return -1; + } + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\217\266\350\257\232/Player.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\217\266\350\257\232/Player.cs" new file mode 100644 index 0000000000000000000000000000000000000000..99086e15fa19fd410949e4aca59d2edb1938a400 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\217\266\350\257\232/Player.cs" @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 剪刀石头布游戏 +{ + abstract class Player + { + public string name { get; set; }//名字 + public string value { get; set; }//出拳 剪刀,石头,不 + public string winCount { get; set; }//取胜局数 + public Player() + { + + } + + public abstract int getInputValue(); + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\217\266\350\257\232/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\217\266\350\257\232/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..5cbb58534c44f6697e30133e03561faf279f09e8 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\217\266\350\257\232/Program.cs" @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 剪刀石头布游戏 +{ + class Program + { + static void Main(string[] args) + { + ComputerPlayer computer = new ComputerPlayer(); + UserPlayer user = new UserPlayer(); + Judger judger = new Judger(); + Console.WriteLine("------------------------------------欢 迎 进 入 游 戏 世 界------------------------------------"); + Console.WriteLine("************************************************"); + Console.WriteLine("* **********************猜拳, 开始 *************"); + Console.WriteLine("出拳规则:1.剪刀2.石头3.布(请输入想应的数字)"); + Console.WriteLine("请选择对方角色:请选择对方角色 < 1:刘备 2.孙权 3.曹操 > "); + int num = int.Parse(Console.ReadLine()); + string computreName = computer.getPlayerName(num); + Console.WriteLine("请输入名字"); + string userName = Console.ReadLine(); + string personName = user.PersonName(userName); + Console.WriteLine(computreName + " VS " + personName + " 对战"); + judger.statr(userName, computreName); + + } + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\217\266\350\257\232/UserPlayer.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\217\266\350\257\232/UserPlayer.cs" new file mode 100644 index 0000000000000000000000000000000000000000..d9888b349ae20acfdc77ec074d2c6cf7eae14d94 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\217\266\350\257\232/UserPlayer.cs" @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 剪刀石头布游戏 +{ + class UserPlayer : Player + { + public String PersonName(String inputName) + { + this.name = inputName; + return this.name; + } + public override int getInputValue() + { + Console.WriteLine("请出拳:1.剪刀 2.石头3.布"); + int value = int.Parse(Console.ReadLine()); + if (value == 1) + { + Console.WriteLine("剪刀"); + } + else if (value == 2) + { + Console.WriteLine("石头"); + } + else if (value == 3) + { + Console.WriteLine("布"); + } + return value; + + } + + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/GameSystem.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/GameSystem.cs" new file mode 100644 index 0000000000000000000000000000000000000000..482cf1c0a9c72d0d4822b868735eb661e1a6ed00 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/GameSystem.cs" @@ -0,0 +1,140 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class GameSystem + { + public bool Gaming(Hero hero, User user) { + int sum = 0; + int hNum = 0; + int uNum = 0; + while (true) + { + string heroAction; + string userAction; + userAction = user.Action(); + Console.WriteLine(user.Name + ": 出拳: " + userAction); + heroAction = hero.Action(); + Console.WriteLine(hero.Name + ": 出拳: " + heroAction); + Console.WriteLine(IsWin(heroAction, userAction, user.Name, ref hNum, ref uNum)); + sum++; + while (true) + { + Console.WriteLine("是否开始下一轮?(1.继续/0.停止)"); + string chioce = Console.ReadLine(); + if (chioce=="1") + { + break; + } + else if (chioce == "0") + { + return EndGame(hero.Name, user.Name, sum, hNum, uNum); + } + else + { + Console.WriteLine("输入错误,请重新输入"); + continue; + } + } + } + } + + private bool EndGame(string heroName, string userName, int sum, int hNum, int uNum) + { + Console.WriteLine("==================================="); + Console.WriteLine("对战次数:"+ sum); + + Console.WriteLine("姓名\t得分"); + Console.WriteLine(heroName+"\t"+ hNum); + Console.WriteLine(userName + "\t"+ uNum); + if (hNum > uNum) + { + Console.WriteLine($"{heroName}赢了,{userName}输了"); + } + else if (hNum < uNum) + { + Console.WriteLine($"{userName}赢了,{heroName}输了"); + } + else { + Console.WriteLine("平局"); + } + while (true) + { + Console.WriteLine("要开始下一局吗?(y/n)"); + string chioce = Console.ReadLine(); + switch (chioce) + { + case "y": + return true; + case "n": + return false; + default: + Console.WriteLine("选择错误,请重新输入"); + continue; + } + } + } + + public string IsWin(string A, string B,string name,ref int hNum, ref int uNum) { + string str; + if ((A == "剪刀" && B == "布")||(A == "石头" && B == "剪刀")|| A == "布" && B == "石头") + { + hNum++; + str = "赢"; + } + else if (A==B) + { + + str = "平局"; + } + else + { + uNum++; + str = "输"; + } + if (str == "赢") + { + return $"笨蛋,{name}输了"; + + } + else if (str == "输") + { + return $"恭喜,{name}赢了"; + } + else { + return "平局,再来"; + } + +/* else if (A == "石头" && B == "剪刀") + { + if () + { + hNum++; + return $"笨蛋,{name}输了"; + } + else if (B == "布") + { + uNum++; + return $"恭喜,{name}赢了"; + } + } + else if (A == "布" && B == "剪刀") + { + uNum++; + return $"恭喜,{name}赢了"; + } + else if (A == "布" && B == "石头") + { + hNum++; + return $"笨蛋,{name}输了"; + } + else*/ + + } + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Hero.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Hero.cs" new file mode 100644 index 0000000000000000000000000000000000000000..97a3ca4d022dbbcb1b21893bc731cab723ca9a8c --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Hero.cs" @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Hero : Person + { + public Hero() + { + } + + public Hero(string name) : base(name) + { + } + + public override string Action() + { + Random rd = new Random(); + int num = rd.Next(1, 4); + switch (num) + { + case 1: + return "剪刀"; + case 2: + return "石头"; + case 3: + return "布"; + } + return ""; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Person.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Person.cs" new file mode 100644 index 0000000000000000000000000000000000000000..8cd8fbae87867bb106ce8fb540f769fca7f7070a --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Person.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Person + { + public string Name { get; set; } + + public Person() + { + } + + public Person(string name) + { + Name = name; + } + + public virtual string Action() { + return null; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..7d9f26216a7831dab96c938d101e7149c4abfd3c --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/Program.cs" @@ -0,0 +1,91 @@ +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("-------欢 迎 进 入 游 戏 世 界-------"); + while (true) + { + Console.WriteLine("*******************************"); + Console.WriteLine("**********猜拳,开始***********"); + Console.WriteLine("*******************************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Hero hero = HeroCreate(); + User user = UserCreate(); + bool IsStart = Start(); + if (!IsStart) + { + Console.WriteLine("系统退出"); + return; + } + else + { + Console.WriteLine(hero.Name + " VS " + user.Name + " 对战"); + } + + GameSystem gm = new GameSystem(); + bool IsConutinue = gm.Gaming(hero, user); + if (!IsConutinue) + { + Console.WriteLine("系统退出"); + return; + } + } + } + + public static bool Start() + { + while (true) + { + Console.WriteLine("开始游戏吗?(y/n)"); + string chioce = Console.ReadLine(); + switch (chioce) + { + case "y": + return true; + case "n": + return false; + default: + Console.WriteLine("选择错误,请重新输入"); + continue; + } + } + } + public static Hero HeroCreate() + { + while (true) + { + Console.WriteLine("请选择对方角色<1.刘备 2.孙权 3.曹操>"); + Console.Write("请选择:"); + string chioce = Console.ReadLine(); + switch (chioce) + { + case "1": + return new Hero("刘备"); + case "2": + return new Hero("孙权"); + case "3": + return new Hero("曹操"); + default: + Console.WriteLine("选择错误,请重新输入"); + continue; + } + } + } + public static User UserCreate() + { + + Console.WriteLine("请输入您的姓名"); + string userName = Console.ReadLine(); + return new User(userName); + } + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/User.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/User.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b003d8d38748cb77a70be111784eddbfd5c4e051 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\220\264\345\255\235\346\266\265/User.cs" @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class User : Person + { + public User() + { + } + + public User(string name) : base(name) + { + } + + public override string Action() + { + while (true) + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应数字)"); + string chioce = Console.ReadLine(); + switch (chioce) + { + case "1": + return "剪刀"; + case "2": + return "石头"; + case "3": + return "布"; + default: + Console.WriteLine("选择错误,请重新输入"); + continue; + } + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\255\231\346\226\207\350\243\225/.keep" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\255\231\346\226\207\350\243\225/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\255\231\346\226\207\350\243\225/Game.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\255\231\346\226\207\350\243\225/Game.cs" new file mode 100644 index 0000000000000000000000000000000000000000..0cd30885dd5d083fa6f78263f1848edefbec2254 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\255\231\346\226\207\350\243\225/Game.cs" @@ -0,0 +1,113 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo01 +{ + class Game + { + public bool Gaming(Hero hero,User user) + { + int sum = 0; + int hNum = 0; + int uNum = 0; + while (true) + { + string heroAction; + string userAction; + userAction = user.Action(); + Console.WriteLine(user.Name + ":出拳:" + userAction); + heroAction = hero.Action(); + Console.WriteLine(hero.Name + ":出拳:" + heroAction); + Console.WriteLine(IsWin(heroAction,userAction,user.Name,ref hNum,ref uNum)); + sum++; + while (true) + { + Console.WriteLine("是否开始下一轮?(y/n)"); + string chioce = Console.ReadLine(); + if (chioce == "y") + { + break; + } + else if (chioce == "n") + { + return EndGame(hero.Name, user.Name, sum, hNum, uNum); + } + else + { + Console.WriteLine("输入错,请重新输入!"); + continue; + } + } + } + } + public bool EndGame(string heroName,string userName,int sum,int hNum,int uNum) + { + Console.WriteLine("================================="); + Console.WriteLine("对战次数:"+sum); + + Console.WriteLine("姓名\t得分"); + Console.WriteLine(heroName + "\t" +hNum); + Console.WriteLine(userName + "\t" +uNum); + if (hNum > uNum) + { + Console.WriteLine($"{heroName}赢了,{userName}输了"); + } + else if (hNum < uNum) + { + Console.WriteLine($"{userName}赢了,{heroName}输了"); + } + else + { + Console.WriteLine("平局"); + } + while (true) + { + Console.WriteLine("要开始下一局吗?(y/n)"); + string chioce = Console.ReadLine(); + switch (chioce) + { + case "y": + return true; + case "n": + return false; + default: + Console.WriteLine("输入错误,请重新输入!"); + continue; + } + } + } + public string IsWin(string A,string B,string name,ref int hNum,ref int uNum) + { + string str; + if ((A == "剪刀" && B == "布")||(A == "石头" && B == "剪刀")||(A == "布" && B == "石头")) + { + hNum++; + str = "赢"; + } + else if (A == B) + { + str = "平局"; + } + else + { + uNum++; + str = "输"; + } + if (str == "赢") + { + return $"笨蛋,{name}输了"; + } + else if (str == "输") + { + return $"恭喜,{name}赢了"; + } + else + { + return "平局,再来"; + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\255\231\346\226\207\350\243\225/Hero.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\255\231\346\226\207\350\243\225/Hero.cs" new file mode 100644 index 0000000000000000000000000000000000000000..f1c652e78730374ab2cd8a8ca47fb6502cc67f49 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\255\231\346\226\207\350\243\225/Hero.cs" @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo01 +{ + class Hero:Person + { + public Hero() + { + + } + public Hero(string name) : base(name) + { + + } + public override string Action() + { + Random r = new Random(); + int num = r.Next(1, 4); + switch (num) + { + case 1: + return "剪刀"; + case 2: + return "石头"; + case 3: + return "布"; + } + return ""; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\255\231\346\226\207\350\243\225/Person.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\255\231\346\226\207\350\243\225/Person.cs" new file mode 100644 index 0000000000000000000000000000000000000000..756ed7ef5c36cea7ac5f2b50fbd19869040be8ca --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\255\231\346\226\207\350\243\225/Person.cs" @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo01 +{ + class Person + { + public string Name { get; set; } + + public Person() + { + + } + + public Person(string name) + { + Name = name; + } + + public virtual string Action() + { + return null; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\255\231\346\226\207\350\243\225/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\255\231\346\226\207\350\243\225/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..a7eec924e30f475128896963a27b022f04775518 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\255\231\346\226\207\350\243\225/Program.cs" @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo01 +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("--------欢迎进入游戏世界--------"); + while (true) + { + Console.WriteLine("*********************************"); + Console.WriteLine("************猜拳,开始***********"); + Console.WriteLine("*********************************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Hero hero = HeroCreate(); + User user = UserCreate(); + bool IsStart = Start(); + if (!IsStart) + { + Console.WriteLine("退出系统!"); + return; + } + else + { + Console.WriteLine(hero.Name + " vs " + user.Name + " 对战 "); + } + Game g = new Game(); + bool Isconutinue = g.Gaming(hero, user); + if (!Isconutinue) + { + Console.WriteLine("退出系统!"); + return; + } + } + } + public static bool Start() + { + while (true) + { + Console.WriteLine("开始游戏吗?(y/n)"); + string chioce = Console.ReadLine(); + switch (chioce) + { + case "y": + return true; + case "n": + return false; + default: + Console.WriteLine("输入错误,请重新输入!"); + continue; + } + } + } + public static Hero HeroCreate() + { + while (true) + { + Console.WriteLine("请选择对方角色<1.刘备 2.孙权 3.曹操>"); + Console.Write("请选择:"); + string chioce = Console.ReadLine(); + switch (chioce) + { + case "1": + return new Hero("刘备"); + case "2": + return new Hero("孙权"); + case "3": + return new Hero("曹操"); + default: + continue; + } + } + } + public static User UserCreate() + { + Console.WriteLine("请输入您的姓名:"); + string userName = Console.ReadLine(); + return new User(userName); + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\255\231\346\226\207\350\243\225/User.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\255\231\346\226\207\350\243\225/User.cs" new file mode 100644 index 0000000000000000000000000000000000000000..85a21d30982e3b33148f68eb87c51edeb3bdf693 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\255\231\346\226\207\350\243\225/User.cs" @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo01 +{ + class User:Person + { + public User() + { + + } + + public User(string name) : base(name) + { + + } + + public override string Action() + { + while (true) + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应数字)"); + string chioce = Console.ReadLine(); + switch (chioce) + { + case "1": + return "剪刀"; + case "2": + return "石头"; + case "3": + return "布"; + default: + Console.WriteLine("输入错误,请重新输入!"); + continue; + } + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\256\213\345\230\211\347\202\234/.keep" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\256\213\345\230\211\347\202\234/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\256\213\345\230\211\347\202\234/BattleInfo.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\256\213\345\230\211\347\202\234/BattleInfo.cs" new file mode 100644 index 0000000000000000000000000000000000000000..c6afb6bb3bdd419f39bbda6ad8dc07c3dc18f8c5 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\256\213\345\230\211\347\202\234/BattleInfo.cs" @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 猜拳 +{ + abstract class BattleInfo + { + private string _name; + private int _throwPunch; + private string _throwPunchChinese; + + public BattleInfo(string name) + { + Name = name; + + } + + public string Name { get => _name; set => _name = value; } + public int ThrowPunch { get => _throwPunch; set => _throwPunch = value; } + public string ThrowPunchChinese { get => _throwPunchChinese; set => _throwPunchChinese = value; } + + //出拳的信息 + public virtual string Rule() + { + return $"{Name}:出拳:{ThrowPunchChinese}"; + } + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\256\213\345\230\211\347\202\234/Opponent.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\256\213\345\230\211\347\202\234/Opponent.cs" new file mode 100644 index 0000000000000000000000000000000000000000..407d957b7e43451f72cbdbcdbb9a2ea3c05c1f31 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\256\213\345\230\211\347\202\234/Opponent.cs" @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 猜拳 +{ + class Opponent:BattleInfo + { + public Opponent(string name) : base(name) + { + } + + //出拳的信息 + public override string Rule () + { + return $"{Name}:出拳:{ThrowPunchChinese}"; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\256\213\345\230\211\347\202\234/Player.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\256\213\345\230\211\347\202\234/Player.cs" new file mode 100644 index 0000000000000000000000000000000000000000..379c1cafd9e45c62b69e06e473071a66c5c77a09 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\256\213\345\230\211\347\202\234/Player.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 猜拳 +{ + class Player : BattleInfo + { + + public Player(string name) : base(name) + { + } + + + //出拳的信息 + public override string Rule() + { + return $"{Name}:出拳:{ThrowPunchChinese}"; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\256\213\345\230\211\347\202\234/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\256\213\345\230\211\347\202\234/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..566037707bc95e893955a959ed434d0c5c257113 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\256\213\345\230\211\347\202\234/Program.cs" @@ -0,0 +1,215 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 猜拳 +{ + enum Fight + { + 剪刀, + 石头, + 巴掌 + } + class Program + { + + static Random ran = new Random(); + static int winRound = 0; + static int winRoundOp = 0; + + static int battleCount = 0; + static Opponent op; + static Player gamer; + static void Main(string[] args) + { + + Console.WriteLine("--------欢迎来猜拳--------"); + Console.WriteLine("*************************"); + Console.WriteLine("********猜拳,开始********"); + Console.WriteLine("*************************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.巴掌"); + Console.WriteLine("输入对战角色:1.刘备 2.孙权 3.曹操"); + string opponenter = Console.ReadLine(); + switch (opponenter) + { + case "1": + op = new Opponent("刘备"); + Console.WriteLine("hoho~,旗鼓相当的对手");//可以用继承 把刘备曹操孙权,各些成一个类 + break; + + case "2": + op = new Opponent("孙权"); + Console.WriteLine("你也想挑战我????"); + break; + + case "3": + op = new Opponent("曹操"); + Console.WriteLine("?????"); + break; + } + + Console.WriteLine("请输入您的姓名"); + string userName = Console.ReadLine(); + gamer = new Player(userName); + + while (true) + { + Console.WriteLine("是否开始游戏 Y/N"); + string choose4 = Console.ReadLine(); + while (!choose4.Equals("n", StringComparison.OrdinalIgnoreCase)) + { + Battling(); + + + Console.WriteLine("你是否还想继续游戏 Y/N"); + string choose = Console.ReadLine(); + if (choose.Equals("n", StringComparison.OrdinalIgnoreCase)) + { + break; + } + else + { + continue; + } + + + + } + Console.WriteLine("==========================="); + Console.WriteLine($"{op.Name} vs {gamer.Name}"); + Console.WriteLine("对战次数{0}", battleCount); + Console.WriteLine(@"姓名 得分 +{0} {1} +{2} {3}", gamer.Name, winRound, op.Name, winRoundOp); + if (winRound>winRoundOp) + { + Console.WriteLine("恭喜{0},赢得胜利",gamer.Name); + } + else if (winRound==winRoundOp) + { + Console.WriteLine("唉,{0}怎么这么拉啊",gamer.Name); + } + else + { + Console.WriteLine("平局,算你运气好!"); + } + Console.WriteLine("是否想再来battle一把 Y/N"); + string choose2 = Console.ReadLine(); + if (choose2.Equals("n", StringComparison.OrdinalIgnoreCase)) + { + break; + } + else + { + continue; + } + } + Console.WriteLine("结束了,别再来作业来了好吗"); + + + + + + + + + Console.ReadKey(); + } + + private static void Battling() + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.巴掌");//把出拳写成一个方法 + + int throwPunch = int.Parse(Console.ReadLine()); + gamer.ThrowPunch = throwPunch; + Change(gamer); + Console.WriteLine(gamer.Rule());//把出拳的内容 原本是数字 换成中文 + + op.ThrowPunch = ran.Next(1, 4); + Change(op); + + Console.WriteLine(op.Rule()); + JudgeRule(gamer, op); + battleCount++; + } + + static void Change(BattleInfo a) + { + if (a.ThrowPunch == 1) + { + a.ThrowPunchChinese = "剪刀"; + } + else if (a.ThrowPunch == 2) + { + a.ThrowPunchChinese = "石头"; + } + else if (a.ThrowPunch == 3) + { + a.ThrowPunchChinese = "布"; + } + + + } + static void JudgeRule(Player a, Opponent b)//前者是玩家,后者人机 + { + //1.剪刀 2.石头 3.布 + if (a.ThrowPunch == 1)//剪刀 + { + if (b.ThrowPunch == a.ThrowPunch) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧。"); + } + else if (b.ThrowPunch == 2) + { + Console.WriteLine($"笨蛋,{a.Name}输了"); + winRoundOp++; + } + else if (b.ThrowPunch == 3) + { + Console.WriteLine($"恭喜,{a.Name}胜出"); + winRound++; + } + } + + if (a.ThrowPunch == 2)//石头 + { + if (b.ThrowPunch == a.ThrowPunch) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧。"); + } + else if (b.ThrowPunch == 3) + { + Console.WriteLine($"笨蛋,{a.Name}输了"); + winRoundOp++; + } + else if (b.ThrowPunch == 1) + { + Console.WriteLine($"恭喜,{a.Name}胜出"); + winRound++; + } + } + if (a.ThrowPunch == 3)//布 + { + if (b.ThrowPunch == a.ThrowPunch) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧。"); + } + else if (b.ThrowPunch == 1) + { + Console.WriteLine($"笨蛋,{a.Name}输了"); + winRoundOp++; + } + else if (b.ThrowPunch == 2) + { + Console.WriteLine($"恭喜,{a.Name}胜出"); + winRound++; + } + } + + + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\262\263\345\220\257\345\215\216/.keep" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\262\263\345\220\257\345\215\216/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\262\263\345\220\257\345\215\216/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\262\263\345\220\257\345\215\216/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..ed1d702f7197f6febf40b95a735e07f831fd7e3e --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\262\263\345\220\257\345\215\216/Program.cs" @@ -0,0 +1,400 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Program + { + static void Main(string[] args) + { + new Fight().Begin(); + } + + class Fight + { + + public Fight() { } + + public void Begin() + { + Console.WriteLine("*****************************"); + Console.WriteLine("*********猜拳游戏************"); + Console.WriteLine("*****************************"); + Console.WriteLine("出拳规则,石头剪刀布"); + Console.WriteLine("请输入玩家姓名:"); + string str = Console.ReadLine(); + RandomGamer(str); + } + + public void RandomGamer(string gamer) + { + + string[] name = new string[] { "刘备", "关羽", "张飞", "刘禅", "秦始皇", "唐玄宗", "唐三藏", "孙悟空", "猪八戒", "沙僧", "李小龙", "周星驰", "叶辰", "王昊", "王维", "李白", "张三", "司马迁", "司马懿", "荀子", "老子", "阿基米德", "爱因斯坦", "牛顿", "夏洛特" }; + string[] arr = new string[3]; + for (int i = 0; i < 3; i++) + { + Random ran = new Random(); + int num = ran.Next(0, 25); + if (!arr.Contains(name[num])) + { + arr[i] = name[num]; + } + else + { + i--; + } + + } + Console.WriteLine($"玩家:{gamer},角色1:{arr[0]},角色2:{arr[1]},角色3:{arr[2]}"); + a: Console.WriteLine("是否开始游戏[Y/N]"); + string str = Console.ReadLine(); + switch (str) + { + case "Y": + RandomFight(arr, gamer); + break; + case "N": + Begin(); + break; + default: + Console.WriteLine("输入错误"); + goto a; + } + } + + public void RandomFight(string[] newName, string gamer) + { + + int count = 1; + int[] arr = new int[3]; + while (true) + { + Console.WriteLine($"Round {count}"); + + int num = FightWhat(); + + if (num == 1) + { + bool flag = GuessOne(newName, gamer, 1, count); + + + } + else if (num == 2) + { + GuessOne(newName, gamer, 2, count); + } + else + { + GuessOne(newName, gamer, 3, count); + + } + } + + } + + private bool GuessOne(string[] newName, string gamer, int g1,int count) + { + int g2 = 0; + int g3 = 0; + + if (g1 == 1) + { + g2 = 2; + g3 = 3; + } + else if (g1 == 2) { + g2 = 3; + g3 = 1; + } + else { + g2 = 1; + g3 = 2; + } + int[] arr = new int[3]; + Random ran = new Random(); + for (int i = 0; i < arr.Length; i++) + { + int num = ran.Next(1,4); + arr[i] = num; + } + arr[0] = g1; arr[1] = g1; arr[2] = g3; + + if ((arr[0] == g2 && arr[1] == g1 && arr[2] == g1) || (arr[0] == g1 && arr[1] == g1 && arr[2] == g2) || (arr[0] == g1 && arr[1] == g2 && arr[2] == g1)) + { + for (int i = 0; i < arr.Length; i++) + { + if (arr[i] == g2) + { + string punch = GuessPunch(g2); + Console.WriteLine($"出牌者 {newName[i]}赢了,出了{punch},{gamer} 为最后一名"); + return true; + } + } + + } + else if (arr[0] == g3 && arr[1] == g3 && arr[2] == g3) + { + Console.WriteLine($"玩家 {gamer}赢了,通吃!"); + return true; + } + else if ((arr[0] == g1 && arr[1] == g3 && arr[2] == g3) || (arr[0] == g3 && arr[1] == g1 && arr[2] == g3) || (arr[0] == g3 && arr[1] == g3 && arr[2] == g1)) + { + for (int i = 0; i < arr.Length; i++) + { + if (arr[i] == g1) + { + Console.WriteLine($"出{GuessPunch(g1)}者胜!!!"); + Console.WriteLine($"玩家 {gamer}和出牌者 {newName[i]}赢了,进入下一轮厮杀"); + string[] name = new string[] { newName[i] }; + NextFight(count, gamer, name); + + } + } + } + else if ((arr[0] == g1 && arr[1] == g3 && arr[2] == g1) || (arr[0] == g1 && arr[1] == g1 && arr[2] == g3) || (arr[0] == g3 && arr[1] == g1 && arr[2] == g1)) + { + string[] name = new string[2]; + for (int i = 0; i < arr.Length; i++) + { + if (arr[i] == g1) + { + int count2 = 1; + + if (count2 == 1) { name[0] = newName[i]; } + else + { + name[1] = newName[i]; + } + count++; + + } + } + Console.WriteLine($"出{GuessPunch(g1)}者胜!!!不对劲,人数有点多!"); + Console.WriteLine($"玩家 {gamer}和出牌者 {name[0]},{name[1]}赢了,进入下一轮厮杀"); + NextFight(count, gamer, name); + } + else + { + Console.WriteLine($"谁都没落着好,下一把"); + return false; + } + return false; + } + + private string GuessPunch(int num) + { + switch (num) { + case 1: + return "剪刀"; + case 2: + return "拳头"; + case 3: + return "布"; + default: + return "不存在的掌法"; + } + + } + + public int FightWhat() + { + + Console.WriteLine("请输入你要出:1、剪刀,2、石头,3、布"); + int num; + b: try + { + num = int.Parse(Console.ReadLine()); + } + catch (Exception) + { + Console.WriteLine("输入错误"); + goto b; + } + + return num; + } + + private void NextFight(int count, string gamer, string[] name) + { + if (name.Length == 1) + { + c: int num = FightWhat(); + Console.WriteLine($"Round {count}"); + + int ran = new Random().Next(1, 4); + if (num == 1) + { + if (!GuessTwo(1, name, gamer,ran)) { count++; goto c; } else { FinalThing(count, gamer); } + + } + else if (num == 2) + { + if (!GuessTwo(2, name, gamer,ran)) { count++; goto c; } else { FinalThing(count, gamer); } + } + else + { + if (!GuessTwo(3, name, gamer,ran)) { count++; goto c; } else { FinalThing(count, gamer); } + } + + + } + else + { + + d: int num = FightWhat(); + Console.WriteLine($"Round {count}"); + + + if (num == 1) + { + if (!GuessThree(1, gamer, name, count)) { count++; goto d; } else { FinalThing(count,gamer); } + } + else if (num == 2) + { + + if (!GuessThree(2, gamer, name, count)) { count++; goto d; } else { FinalThing(count, gamer); } + + } + else + { + if (!GuessThree(3, gamer, name, count)) { count++; goto d; } else { FinalThing(count, gamer); } + } + + } + } + + private void FinalThing(int count,string gamer) + { + int count2 = 1; + count2++; + f: Console.WriteLine($"玩家 【{gamer}】 ,您总共进行了 {count} 轮,是否继续?[Y/N]"); + string str = Console.ReadLine(); + switch (str) { + case "Y": + Console.WriteLine($"游戏继续,当前为第 {count2} 大轮"); + RandomGamer(gamer); + break; + case "N": + Process.GetCurrentProcess().Kill(); + break; + default: + Console.WriteLine("输入错误"); + goto f; + } + } + + + + private bool GuessTwo(int num,string[] name,string gamer,int ran) + { + int num2 = 0; + int num3 = 0; + if (num == 1) + { + num2 = 2; + num3 = 3; + } + else if (num == 2) + { + num2 = 3; + num3 = 1; + } + else { + num2 = 1; + num3 = 2; + } + if (ran == num2) + { + Console.WriteLine($"出{GuessPunch(ran)}者胜!!!"); + Console.WriteLine($"出牌者 {name[0]} 赢了!"); + return true; + } + else if (ran == num3) + { + Console.WriteLine($"出{GuessPunch(num)}者胜利了!!!Victory!!!"); + Console.WriteLine($"玩家 {gamer} 获得了最终的胜利!"); + return true; + } + else + { + Console.WriteLine("再来一把!快要分胜负了!"); + return false; + } + + } + + private bool GuessThree(int num, string gamer, string[] name, int count) + { + int num2 = 0; + int num3 = 0; + int[] arr = new int[2]; + Random ran = new Random(); + for (int i = 0; i < arr.Length; i++) + { + int r = ran.Next(1, 4); + arr[i] = r; + } + if (num == 1) + { + num2 = 3; + num3 = 2; + } + else if (num == 2) + { + num2 = 1; + num3 = 3; + } + else + { + num2 = 2; + num3 = 1; + } + if ((arr[0] == num && arr[1] == num2) || (arr[0] == num2 && arr[1] == num)) + { + for (int i = 0; i < arr.Length; i++) + { + if (arr[i] == num) + { + Console.WriteLine($"出{GuessPunch(num)}了,比赛结果是什么?!"); + Console.WriteLine($"玩家 {gamer}和出牌者 {name[i]}进入总决赛!!"); + string[] name2 = new string[] { name[i] }; + count++; + NextFight(count, gamer, name2); + } + } + + } + else if ((arr[0] == num && arr[1] == num3) || (arr[0] == num3 && arr[1] == num)) + { + for (int i = 0; i < arr.Length; i++) + { + if (arr[i] == num3) + { + Console.WriteLine($"对手狡猾的出了{GuessPunch(num3)}"); + Console.WriteLine($"出牌者{name[i]}获得了最终胜利"); + return true; + } + } + } + else if (arr[0] == num2 && arr[1] == num2) + { + Console.WriteLine($"玩家使出了{GuessPunch(num)}"); + Console.WriteLine($"玩家{gamer}赢得最终胜利"); + return true; + } + else + { + Console.WriteLine("再来一轮"); + Console.WriteLine("双方的运气都很不错,结局将会鹿死几手?"); + if (count % 3 == 0) Console.WriteLine("幸运彩蛋"); + return false; + } + return false; + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\274\240\346\230\214\351\276\231/ComputerPlayer.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\274\240\346\230\214\351\276\231/ComputerPlayer.cs" new file mode 100644 index 0000000000000000000000000000000000000000..5788e70a8cbe7a31f58b9c962e3eb8c4f5404d5b --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\274\240\346\230\214\351\276\231/ComputerPlayer.cs" @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 剪刀石头布游戏 +{ + class ComputerPlayer : Player + { + static Random rand = new Random(); + public override int getInputValue() + { + int value = rand.Next(1, 4); + if (value == 1) + { + Console.WriteLine("剪刀"); + } + else if (value == 2) + { + Console.WriteLine("石头"); + } + else if (value == 3) + { + Console.WriteLine("布"); + } + return value; + } + + public string getPlayerName(int num) + { + if (num == 1) + { + name = "刘备"; + } + else if (num == 2) + { + name = "孙权"; + } + else if (num == 3) + { + name = "曹操"; + } + return name; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\274\240\346\230\214\351\276\231/Judger.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\274\240\346\230\214\351\276\231/Judger.cs" new file mode 100644 index 0000000000000000000000000000000000000000..ee30e9928e8d255d93ecc6ee8d7e9d0dbe962d78 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\274\240\346\230\214\351\276\231/Judger.cs" @@ -0,0 +1,129 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 剪刀石头布游戏 +{ + class Judger + { + static ComputerPlayer computer = new ComputerPlayer(); + static UserPlayer user = new UserPlayer(); + public bool statr(String inputName, String computName) + { + int comWinCount = 0; + int userWinCount = 0; + bool flag = false; + int count = 1; + string j; + Console.WriteLine("准备开始游戏了吗(y/n)"); + j = Console.ReadLine(); + if (j.Equals("y")) + { + m: do + { + count++; + //玩家出拳 + int userValue = user.getInputValue(); + Console.WriteLine(inputName + "出拳: "); + //电脑出拳 + int comValue = computer.getInputValue(); + Console.WriteLine(computName + "出拳: " ); + //裁判比较 + int result = compare(comValue, userValue); + if (result == 1) + { + Console.WriteLine("笨蛋," + computName + "赢了"); + comWinCount++; + } + else if (result == -1) + { + Console.WriteLine("笨蛋," + inputName + "赢了"); + userWinCount++; + } + else + { + Console.WriteLine("嘿嘿,和局真衰,等着瞧吧"); + } + Console.WriteLine("准备开始游戏了吗(y/n)"); + j = Console.ReadLine(); + switch (j) + { + case "y": + flag = true; + break; + case "n": + Console.WriteLine("=========================================="); + Console.WriteLine(inputName + " VS "+ computName); + Console.WriteLine("对战次数" + count); + Console.WriteLine(); + Console.WriteLine("姓名\t\t得分"); + Console.WriteLine(inputName+"\t\t" + userWinCount); + Console.WriteLine(computName + "\t\t" + comWinCount); + if (userWinCount> comWinCount) + { + Console.WriteLine(inputName+"赢"); + } + else if (userWinCount > comWinCount) + { + Console.WriteLine(computName+"赢"); + } + else + { + Console.WriteLine("平局"); + } + Console.WriteLine("退出系统"); + break; + } + goto m; + } while (flag); + } + else if (j.Equals("n")) + { + Console.WriteLine("系统退出"); + } + return flag; + } + public int compare(int computerValue, int userValue) + { + if (computerValue == userValue) + { + return 0; + } + else if (computerValue == 1)//1 剪刀 + { + if (userValue == 2)//1 石头 + { + return -1; + } + else//3 布 + { + return 1; + } + } + else if (computerValue == 2)//2 石头 + { + if (userValue == 1)// 1 剪刀 + { + return 1; + } + else//3 布 + { + return -1; + } + } + else//3 computerValue==布 + { + if (userValue == 2)//石头 + { + return 1; + } + else// 1 剪刀 + { + return -1; + } + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\274\240\346\230\214\351\276\231/Player.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\274\240\346\230\214\351\276\231/Player.cs" new file mode 100644 index 0000000000000000000000000000000000000000..99086e15fa19fd410949e4aca59d2edb1938a400 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\274\240\346\230\214\351\276\231/Player.cs" @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 剪刀石头布游戏 +{ + abstract class Player + { + public string name { get; set; }//名字 + public string value { get; set; }//出拳 剪刀,石头,不 + public string winCount { get; set; }//取胜局数 + public Player() + { + + } + + public abstract int getInputValue(); + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\274\240\346\230\214\351\276\231/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\274\240\346\230\214\351\276\231/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..5cbb58534c44f6697e30133e03561faf279f09e8 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\274\240\346\230\214\351\276\231/Program.cs" @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 剪刀石头布游戏 +{ + class Program + { + static void Main(string[] args) + { + ComputerPlayer computer = new ComputerPlayer(); + UserPlayer user = new UserPlayer(); + Judger judger = new Judger(); + Console.WriteLine("------------------------------------欢 迎 进 入 游 戏 世 界------------------------------------"); + Console.WriteLine("************************************************"); + Console.WriteLine("* **********************猜拳, 开始 *************"); + Console.WriteLine("出拳规则:1.剪刀2.石头3.布(请输入想应的数字)"); + Console.WriteLine("请选择对方角色:请选择对方角色 < 1:刘备 2.孙权 3.曹操 > "); + int num = int.Parse(Console.ReadLine()); + string computreName = computer.getPlayerName(num); + Console.WriteLine("请输入名字"); + string userName = Console.ReadLine(); + string personName = user.PersonName(userName); + Console.WriteLine(computreName + " VS " + personName + " 对战"); + judger.statr(userName, computreName); + + } + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\274\240\346\230\214\351\276\231/UserPlayer.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\274\240\346\230\214\351\276\231/UserPlayer.cs" new file mode 100644 index 0000000000000000000000000000000000000000..d9888b349ae20acfdc77ec074d2c6cf7eae14d94 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\274\240\346\230\214\351\276\231/UserPlayer.cs" @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 剪刀石头布游戏 +{ + class UserPlayer : Player + { + public String PersonName(String inputName) + { + this.name = inputName; + return this.name; + } + public override int getInputValue() + { + Console.WriteLine("请出拳:1.剪刀 2.石头3.布"); + int value = int.Parse(Console.ReadLine()); + if (value == 1) + { + Console.WriteLine("剪刀"); + } + else if (value == 2) + { + Console.WriteLine("石头"); + } + else if (value == 3) + { + Console.WriteLine("布"); + } + return value; + + } + + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\274\240\351\223\255\350\275\251/.keep" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\274\240\351\223\255\350\275\251/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\274\240\351\223\255\350\275\251/\345\274\240\351\223\255\350\275\251/Computer.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\274\240\351\223\255\350\275\251/\345\274\240\351\223\255\350\275\251/Computer.cs" new file mode 100644 index 0000000000000000000000000000000000000000..0091c7d5554f2448d11f69e43b47a55cfed0e1bb --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\274\240\351\223\255\350\275\251/\345\274\240\351\223\255\350\275\251/Computer.cs" @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace P1 +{ + class Computer + { + private string _name; + public string Name { get {return this._name; } set { this._name = value; } } + + public int Cp() + { + Random random = new Random(); + int cp = random.Next(1, 4); + switch (cp) + { + case 1: + Console.WriteLine($"{this.Name}:出拳: 剪刀"); + break; + case 2: + Console.WriteLine($"{this.Name}:出拳: 石头"); + break; + case 3: + Console.WriteLine($"{this.Name}:出拳: 布"); + break; + } + return cp; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\274\240\351\223\255\350\275\251/\345\274\240\351\223\255\350\275\251/Person.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\274\240\351\223\255\350\275\251/\345\274\240\351\223\255\350\275\251/Person.cs" new file mode 100644 index 0000000000000000000000000000000000000000..005af46524b0253dc7223c892c710c225e013427 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\274\240\351\223\255\350\275\251/\345\274\240\351\223\255\350\275\251/Person.cs" @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace P1 +{ + class Person + { + private string _name; + + public string Name { get {return this._name; } set {this._name=value; } } + + public int Ps() + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布 <输入相应数字>:"); + int ps = int.Parse(Console.ReadLine()); + switch (ps) + { + case 1: + Console.WriteLine($"{this.Name}:出拳: 剪刀"); + break; + case 2: + Console.WriteLine($"{this.Name}:出拳: 石头"); + break; + case 3: + Console.WriteLine($"{this.Name}:出拳: 布"); + break; + } + return ps; + } + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\274\240\351\223\255\350\275\251/\345\274\240\351\223\255\350\275\251/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\274\240\351\223\255\350\275\251/\345\274\240\351\223\255\350\275\251/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..f24002c4bbcfe84d08e561873fba2e4c960614c2 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\274\240\351\223\255\350\275\251/\345\274\240\351\223\255\350\275\251/Program.cs" @@ -0,0 +1,145 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace P1 +{ + class Program + { + static void Main(string[] args) + { + + Computer computer = new Computer(); + + Person person = new Person(); + int count = 0; + int s1 = 0; + int s2 = 0; + + Console.WriteLine("----------欢迎进入游戏世界----------"); + Console.WriteLine("*************************************"); + Console.WriteLine("**************猜拳,开始*************"); + Console.WriteLine("*************************************"); + a: Console.WriteLine("出拳规则:1.剪刀2.石头3.布"); + Console.WriteLine("请选择对方角色<1:刘备2:孙权3:曹操>"); + int key = int.Parse(Console.ReadLine()); + if (key == 1) + { + computer.Name = "刘备"; + } + if (key == 2) + { + computer.Name = "孙权"; + } + if (key == 3) + { + computer.Name = "曹操"; + } + Console.WriteLine("请输入您的姓名:"); + person.Name = Console.ReadLine(); + Console.WriteLine($"{person.Name} vs {computer.Name}对战"); + Console.WriteLine("开始游戏吗?"); + string ks = Console.ReadLine(); + while (Xh(ks)) + { + if (ks == "y") + { + int per = person.Ps(); + int com = computer.Cp(); + + if (per == 1 && com == 1) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + else if (per == 1 && com == 2) + { + Console.WriteLine($"笨蛋,{person.Name}输了"); + s2++; + } + + else if (per == 1 && com == 3) + { + Console.WriteLine($"恭喜,{person.Name}赢了"); + s1++; + } + else if (per == 2 && com == 1) + { + Console.WriteLine($"恭喜,{person.Name}赢了"); + s1++; + } + else if (per == 2 && com == 2) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + else if (per == 2 && com == 3) + { + Console.WriteLine($"笨蛋,{person.Name}输了"); + s2++; + } + else if (per == 3 && com == 1) + { + Console.WriteLine($"笨蛋,{person.Name}输了"); + s2++; + } + else if (per == 3 && com == 2) + { + Console.WriteLine($"恭喜,{person.Name}赢了"); + s1++; + } + else if (per == 3 && com == 3) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + Console.WriteLine("是否开始下一轮?"); + ks = Console.ReadLine(); + Xh(ks); + count++; + if (ks=="n") + { + Console.WriteLine("*************************************"); + Console.WriteLine($"{computer.Name} vs {person.Name}对战"); + Console.WriteLine($"对战次数: {count}"); + Console.WriteLine(); + Console.WriteLine("姓名"+"\t"+"得分"); + Console.WriteLine($"{person.Name}\t{s1}"); + Console.WriteLine($"{computer.Name}\t{s2}"); + if (s1>s2) + { + Console.WriteLine($"结果:{person.Name}赢,{computer.Name}笨蛋"); + } + else if (s1 < s2) + { + Console.WriteLine($"结果:{computer.Name}赢,{person.Name}笨蛋"); + } + else if (s1 == s2) + { + Console.WriteLine($"恭喜你们!{computer.Name}和{person.Name}平局!"); + } + Console.WriteLine("要开始下一局吗?"); + string sf = Console.ReadLine(); + switch (sf) { + case "y": + goto a; + case "n": + Console.WriteLine("系统退出!!!!!"); + break; + } + } + } + } + } + + private static bool Xh(string ks) + { + bool b; + if (ks == "y") + { b = true; } + else { b = false; } + return b; + } + } +} + + diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\276\220\345\211\221\351\230\263/.keep" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\276\220\345\211\221\351\230\263/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\276\220\345\211\221\351\230\263/GameSystem.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\276\220\345\211\221\351\230\263/GameSystem.cs" new file mode 100644 index 0000000000000000000000000000000000000000..f0d55e0ea129def5d9d950567f1ca3a7bfbe225e --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\276\220\345\211\221\351\230\263/GameSystem.cs" @@ -0,0 +1,146 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class GameSystem + { + + public bool Gaming(Hero hero, User user) + { + int sum = 0; + int hNum = 0; + int uNum = 0; + while (true) + { + string heroAction; + string userAction; + userAction = user.Action(); + Console.WriteLine(user.Name + ": 出拳: " + userAction); + heroAction = hero.Action(); + Console.WriteLine(hero.Name + ": 出拳: " + heroAction); + Console.WriteLine(IsWin(heroAction, userAction, user.Name, ref hNum, ref uNum)); + sum++; + while (true) + { + Console.WriteLine("是否开始下一轮?(1.继续/0.停止)"); + string chioce = Console.ReadLine(); + if (chioce == "1") + { + break; + } + else if (chioce == "0") + { + return EndGame(hero.Name, user.Name, sum, hNum, uNum); + } + else + { + Console.WriteLine("输入错误,请重新输入"); + continue; + } + } + } + } + + private bool EndGame(string heroName, string userName, int sum, int hNum, int uNum) + { + Console.WriteLine("==================================="); + Console.WriteLine("对战次数:" + sum); + + Console.WriteLine("姓名\t得分"); + Console.WriteLine(heroName + "\t" + hNum); + Console.WriteLine(userName + "\t" + uNum); + if (hNum > uNum) + { + Console.WriteLine($"{heroName}赢了,{userName}输了"); + } + else if (hNum < uNum) + { + Console.WriteLine($"{userName}赢了,{heroName}输了"); + } + else + { + Console.WriteLine("平局"); + } + while (true) + { + Console.WriteLine("要开始下一局吗?(y/n)"); + string chioce = Console.ReadLine(); + switch (chioce) + { + case "y": + return true; + case "n": + return false; + default: + Console.WriteLine("选择错误,请重新输入"); + continue; + } + } + } + + public string IsWin(string A, string B, string name, ref int hNum, ref int uNum) + { + string str; + if ((A == "剪刀" && B == "布") || (A == "石头" && B == "剪刀") || A == "布" && B == "石头") + { + hNum++; + str = "赢"; + } + else if (A == B) + { + + str = "平局"; + } + else + { + uNum++; + str = "输"; + } + if (str == "赢") + { + return $"笨蛋,{name}输了"; + + } + else if (str == "输") + { + return $"恭喜,{name}赢了"; + } + else + { + return "平局,再来"; + } + + /* else if (A == "石头" && B == "剪刀") + { + if () + { + hNum++; + return $"笨蛋,{name}输了"; + } + else if (B == "布") + { + uNum++; + return $"恭喜,{name}赢了"; + } + } + else if (A == "布" && B == "剪刀") + { + uNum++; + return $"恭喜,{name}赢了"; + } + else if (A == "布" && B == "石头") + { + hNum++; + return $"笨蛋,{name}输了"; + } + else*/ + + } + + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\276\220\345\211\221\351\230\263/Hero.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\276\220\345\211\221\351\230\263/Hero.cs" new file mode 100644 index 0000000000000000000000000000000000000000..97a3ca4d022dbbcb1b21893bc731cab723ca9a8c --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\276\220\345\211\221\351\230\263/Hero.cs" @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Hero : Person + { + public Hero() + { + } + + public Hero(string name) : base(name) + { + } + + public override string Action() + { + Random rd = new Random(); + int num = rd.Next(1, 4); + switch (num) + { + case 1: + return "剪刀"; + case 2: + return "石头"; + case 3: + return "布"; + } + return ""; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\276\220\345\211\221\351\230\263/Person.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\276\220\345\211\221\351\230\263/Person.cs" new file mode 100644 index 0000000000000000000000000000000000000000..7210fed863735476b159ea4356e91e21302bcbab --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\276\220\345\211\221\351\230\263/Person.cs" @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Person + { + public string Name { get; set; } + + public Person() + { + } + + public Person(string name) + { + Name = name; + } + + public virtual string Action() + { + return null; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\276\220\345\211\221\351\230\263/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\276\220\345\211\221\351\230\263/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..c096fa04113d239bf697d0a5fc754e8b5e79a755 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\276\220\345\211\221\351\230\263/Program.cs" @@ -0,0 +1,90 @@ +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("-------欢 迎 进 入 游 戏 世 界-------"); + while (true) + { + Console.WriteLine("*******************************"); + Console.WriteLine("**********猜拳,开始***********"); + Console.WriteLine("*******************************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Hero hero = HeroCreate(); + User user = UserCreate(); + bool IsStart = Start(); + if (!IsStart) + { + Console.WriteLine("系统退出"); + return; + } + else + { + Console.WriteLine(hero.Name + " VS " + user.Name + " 对战"); + } + + GameSystem gm = new GameSystem(); + bool IsConutinue = gm.Gaming(hero, user); + if (!IsConutinue) + { + Console.WriteLine("系统退出"); + return; + } + } + } + + private static bool Start() + { + while (true) + { + Console.WriteLine("开始游戏吗?(y/n)"); + string chioce = Console.ReadLine(); + switch (chioce) + { + case "y": + return true; + case "n": + return false; + default: + Console.WriteLine("选择错误,请重新输入"); + continue; + } + } + } + public static Hero HeroCreate() + { + while (true) + { + Console.WriteLine("请选择对方角色<1.刘备 2.孙权 3.曹操>"); + Console.Write("请选择:"); + string chioce = Console.ReadLine(); + switch (chioce) + { + case "1": + return new Hero("刘备"); + case "2": + return new Hero("孙权"); + case "3": + return new Hero("曹操"); + default: + Console.WriteLine("选择错误,请重新输入"); + continue; + } + } + } + public static User UserCreate() + { + + Console.WriteLine("请输入您的姓名"); + string userName = Console.ReadLine(); + return new User(userName); + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\276\220\345\211\221\351\230\263/User.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\276\220\345\211\221\351\230\263/User.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b003d8d38748cb77a70be111784eddbfd5c4e051 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\345\276\220\345\211\221\351\230\263/User.cs" @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class User : Person + { + public User() + { + } + + public User(string name) : base(name) + { + } + + public override string Action() + { + while (true) + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应数字)"); + string chioce = Console.ReadLine(); + switch (chioce) + { + case "1": + return "剪刀"; + case "2": + return "石头"; + case "3": + return "布"; + default: + Console.WriteLine("选择错误,请重新输入"); + continue; + } + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\233\271\346\226\207\346\226\214/Game.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\233\271\346\226\207\346\226\214/Game.cs" new file mode 100644 index 0000000000000000000000000000000000000000..88f02faa5566f8890ec52640bd31fca691582599 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\233\271\346\226\207\346\226\214/Game.cs" @@ -0,0 +1,127 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp3 +{ + class Game + { + public void Games() + { + + Console.WriteLine("请选择对方角色<1:刘备 2:孙权 3:曹操>"); + int a = int.Parse(Console.ReadLine()); + Console.WriteLine("请输入您的姓名:"); + string aname = Console.ReadLine(); + string name= "刘备"; + + if (a == 2) + { + name = "孙权"; + } + if (a == 3) + { + name = "曹操"; + } + Console.WriteLine(aname + "VS" + name); + int count = 1;//对战次数 + int score = 1;//得分 + int scores = 1; + + while (true) + { + Console.WriteLine("是否开始下一轮?"); + string b = Console.ReadLine(); + if (b == "y") + { + count++; + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布 (输入相应数字:)"); + int tap = int.Parse(Console.ReadLine()); + string c = "剪刀"; + if (tap == 2) + { + c = "石头"; + } + if (tap == 3) + { + c = "布"; + } + Random r = new Random(); + int d = r.Next(1, 4); + string e = "剪刀"; + + if (d == 2) + { + e = "石头"; + } + if (d == 3) + { + e = "布"; + } + Console.WriteLine(aname + ": 出拳:" + c); + Console.WriteLine(name + ":出拳:" + e); + if (tap == d) + { + Console.WriteLine("和局"); + } + if (tap==1) + { + if (d==2) + { + Console.WriteLine(aname+"输了"); + } + if (d==3) + { + Console.WriteLine(aname+"赢了"); + } + } + if (tap==2) + { + if (d==1) + { + Console.WriteLine(aname+"赢了"); + } + if (d==3) + { + Console.WriteLine(aname+"输了"); + } + } + if (tap==3) + { + if (d==1) + { + Console.WriteLine(aname+"输了"); + score++; + } + if (d==2) + { + Console.WriteLine(aname+"赢了"); + scores++; + } + } + } + if (b=="n") + { + Console.WriteLine("==================================="); + Console.WriteLine(aname + "VS" + name); + Console.WriteLine("对战次数"+count); + Console.WriteLine("姓名 得分"); + Console.WriteLine(aname+" "+scores); + Console.WriteLine(name+" "+score); + if (score>scores) + { + Console.WriteLine(name+"赢,"+aname+"笨蛋"); + } + else + { + Console.WriteLine(name + "笨蛋," + aname + "赢"); + } + break; + } + } + } + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\233\271\346\226\207\346\226\214/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\233\271\346\226\207\346\226\214/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..5be7be5c034fd6f1d9143393f877d60fdbb31b3f --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\233\271\346\226\207\346\226\214/Program.cs" @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp3 +{ + class Program + { + static void Main(string[] args) + { + Game g = new Game(); + Console.WriteLine("--------欢迎进入游戏世界--------"); + Console.WriteLine("**********************"); + Console.WriteLine("*******猜拳,开始******"); + Console.WriteLine("**********************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + g.Games(); + Console.WriteLine("要开始下一局码?(y/n)"); + string z = Console.ReadLine(); + if (z=="y") + { + g.Games(); + } + if (z=="n") + { + Console.WriteLine("系统退出"); + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\233\276\344\273\216\346\235\234/.keep" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\233\276\344\273\216\346\235\234/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\233\276\344\273\216\346\235\234/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\233\276\344\273\216\346\235\234/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..13c486a26febcb23d4e1318b02354da1e7f40d13 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\233\276\344\273\216\346\235\234/Program.cs" @@ -0,0 +1,980 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + abstract class father { + private string name; + public string Name { get { return name; } set{ name = value; } } + abstract public void rock (); + abstract public void scissor(); + abstract public void cloth(); + public father() { } + public father(string name) + { + this.Name = name; + } + + + } + class Liubei : father + { + public Liubei() { } + public Liubei(string name) : base(name) + { + } + + public override void cloth() + { + Console.WriteLine("{0} 出拳:布", this.Name); + } + + public override void rock() + { + Console.WriteLine("{0} 出拳:拳头", this.Name); + } + + public override void scissor() + { + Console.WriteLine("{0} 出拳:剪刀", this.Name); + } + } + class Sunquan : father + { + public override void cloth() + { + Console.WriteLine("{0} 出拳:布", this.Name); + } + + public override void rock() + { + Console.WriteLine("{0} 出拳:拳头", this.Name); + } + + public override void scissor() + { + Console.WriteLine("{0} 出拳:剪刀", this.Name); + } + } + class Caochao : father + { + public override void cloth() + { + Console.WriteLine("{0} 出拳:布", this.Name); + } + + public override void rock() + { + Console.WriteLine("{0} 出拳:拳头", this.Name); + } + + public override void scissor() + { + Console.WriteLine("{0} 出拳:剪刀", this.Name); + } + } + class Player : father + { + + public override void cloth() + { + Console.WriteLine("{0} 出拳:布",this.Name); + } + + public override void rock() + { + Console.WriteLine("{0} 出拳:拳头",this.Name); + } + + public override void scissor() + { + Console.WriteLine("{0} 出拳:剪刀", this.Name); + } + } + class Speak { + public void go() { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布"); + } + public void isgo() { + Console.WriteLine("是否继续?(y/n)"); + } + public void win() { + Player player = new Player(); + Console.WriteLine("恭喜,{0}赢了",player.Name); + } + public void lose() + { + Player player = new Player(); + Console.WriteLine("笨蛋,{0}输了", player.Name); + } + public void dogfall() + { + Console.WriteLine("真衰!嘿嘿!等着瞧"); + } + } + class Program + { + static void Main(string[] args) + { + + home(); + + } + + private static void home() + { + Console.WriteLine("-----------------欢迎进入游戏世界--------------"); + Console.WriteLine("***************************************"); + Console.WriteLine("***************猜拳,开始**************"); + Console.WriteLine("***************************************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Console.WriteLine("选择对方角色:1.刘备 2.孙权 3.曹操"); + string key = Console.ReadLine(); + switch (key) + { + case "1": + Liubei liubei = new Liubei("刘备"); + Console.WriteLine("请输入你的姓名:"); + string str = Console.ReadLine(); + Player player = new Player(); + player.Name = str; + Console.WriteLine("{0} vs {1} 对战", player.Name, liubei.Name); + Console.WriteLine("开始游戏吗?(y/n)"); + string str1 = Console.ReadLine(); + switch (str1) + { + case "y": + + game(player, liubei); + break; + case "n": + break; + default: + break; + } + break; + case "2": + Sunquan sunquan = new Sunquan(); + sunquan.Name = "孙权"; + Console.WriteLine("请输入你的姓名:"); + string s1 = Console.ReadLine(); + Player player1 = new Player(); + player1.Name = s1; + Console.WriteLine("{0} vs {1} 对战", player1.Name, sunquan.Name); + Console.WriteLine("开始游戏吗?(y/n)"); + string s11 = Console.ReadLine(); + switch (s11) + { + case "y": + + game(player1, sunquan); + break; + case "n": + break; + default: + break; + } + break; + case "3": + Caochao caochao = new Caochao(); + caochao.Name = "曹操"; + Console.WriteLine("请输入你的姓名:"); + string s2 = Console.ReadLine(); + Player player2 = new Player(); + player2.Name = s2; + Console.WriteLine("{0} vs {1} 对战", player2.Name, caochao.Name); + Console.WriteLine("开始游戏吗?(y/n)"); + string s22 = Console.ReadLine(); + switch (s22) + { + case "y": + + game(player2, caochao); + break; + case "n": + break; + default: + break; + } + break; + default: + break; + } + } + + private static void game(Player player, Liubei liubei) + { + int count = 0; + int win = 0; + int win2 = 0; + Random random = new Random(); + Speak speak = new Speak(); + a: speak.go(); + string key=Console.ReadLine(); + switch (key) + { + case "1": + int num = random.Next(1, 4); + switch (num) + { + case 1: + player.scissor(); + liubei.scissor(); + speak.dogfall(); + count++; + speak.isgo(); + string a = Console.ReadLine(); + switch (a) + { + case "y": + goto a; + break; + case "n": + end(player,liubei,win,win2,count); + break; + default: + break; + } + break; + case 2: + player.scissor(); + liubei.rock(); + speak.lose(); + win2++; + count++; + speak.isgo(); + string b = Console.ReadLine(); + switch (b) + { + case "y": + goto a; + break; + case "n": + end(player, liubei, win, win2, count); + break; + default: + break; + } + + break; + case 3: + player.scissor(); + liubei.cloth(); + speak.win(); + win++; + count++; + speak.isgo(); + string y = Console.ReadLine(); + switch (y) + { + case "y": + goto a; + break; + case "n": + end(player, liubei, win, win2, count); + break; + default: + break; + } + break; + + default: + break; + } + break; + case "2": + int num2 = random.Next(1, 4); + switch (num2) + { + case 1: + + player.rock(); + liubei.scissor(); + speak.win(); + win++; + count++; + speak.isgo(); + string a = Console.ReadLine(); + switch (a) + { + case "y": + goto a; + break; + case "n": + end(player, liubei, win, win2, count); + break; + default: + break; + } + break; + + case 2: + player.rock(); + liubei.rock(); + speak.dogfall(); + count++; + speak.isgo(); + string b = Console.ReadLine(); + switch (b) + { + case "y": + goto a; + break; + case "n": + end(player, liubei, win, win2, count); + break; + default: + break; + } + break; + + case 3: + player.rock(); + liubei.cloth(); + speak.lose(); + win2++; + count++; + speak.isgo(); + string c = Console.ReadLine(); + switch (c) + { + case "y": + goto a; + break; + case "n": + end(player, liubei, win, win2, count); + break; + default: + break; + } + break; + + default: + break; + } + break; + case "3": + int num3 = random.Next(1, 4); + switch (num3) + { + case 1: + + player.cloth(); + liubei.scissor(); + speak.lose(); + win2++; + count++; + speak.isgo(); + string a = Console.ReadLine(); + switch (a) + { + case "y": + goto a; + break; + case "n": + end(player, liubei, win, win2, count); + break; + default: + break; + } + + break; + case 2: + player.cloth(); + liubei.rock(); + speak.win(); + win++; + count++; + speak.isgo(); + string b = Console.ReadLine(); + switch (b) + { + case "y": + goto a; + break; + case "n": + end(player, liubei, win, win2, count); + break; + default: + break; + } + + + break; + case 3: + player.cloth(); + liubei.cloth(); + speak.dogfall(); + count++; + speak.isgo(); + string c = Console.ReadLine(); + switch (c) + { + case "y": + goto a; + break; + case "n": + end(player, liubei, win, win2, count); + break; + default: + break; + } + break; + + + default: + break; + } + break; + + + default: + break; + } + } + private static void game(Player player, Caochao caochao) + { + int count = 0; + int win = 0; + int win2 = 0; + Random random = new Random(); + Speak speak = new Speak(); + a: speak.go(); + string key = Console.ReadLine(); + switch (key) + { + case "1": + int num = random.Next(1, 4); + switch (num) + { + case 1: + player.scissor(); + caochao.scissor(); + speak.dogfall(); + count++; + speak.isgo(); + string a = Console.ReadLine(); + switch (a) + { + case "y": + goto a; + break; + case "n": + end(player, caochao, win, win2, count); + break; + default: + break; + } + break; + case 2: + player.scissor(); + caochao.rock(); + speak.lose(); + win2++; + count++; + speak.isgo(); + string b = Console.ReadLine(); + switch (b) + { + case "y": + goto a; + break; + case "n": + end(player, caochao, win, win2, count); + break; + default: + break; + } + + break; + case 3: + player.scissor(); + caochao.cloth(); + speak.win(); + win++; + count++; + speak.isgo(); + string y = Console.ReadLine(); + switch (y) + { + case "y": + goto a; + break; + case "n": + end(player, caochao, win, win2, count); + break; + default: + break; + } + break; + + default: + break; + } + break; + case "2": + int num2 = random.Next(1, 4); + switch (num2) + { + case 1: + + player.rock(); + caochao.scissor(); + speak.win(); + win++; + count++; + speak.isgo(); + string a = Console.ReadLine(); + switch (a) + { + case "y": + goto a; + break; + case "n": + end(player, caochao, win, win2, count); + break; + default: + break; + } + break; + + case 2: + player.rock(); + caochao.rock(); + speak.dogfall(); + count++; + speak.isgo(); + string b = Console.ReadLine(); + switch (b) + { + case "y": + goto a; + break; + case "n": + end(player, caochao, win, win2, count); + break; + default: + break; + } + break; + + case 3: + player.rock(); + caochao.cloth(); + speak.lose(); + win2++; + count++; + speak.isgo(); + string c = Console.ReadLine(); + switch (c) + { + case "y": + goto a; + break; + case "n": + end(player, caochao, win, win2, count); + break; + default: + break; + } + break; + + default: + break; + } + break; + case "3": + int num3 = random.Next(1, 4); + switch (num3) + { + case 1: + + player.cloth(); + caochao.scissor(); + speak.lose(); + win2++; + count++; + speak.isgo(); + string a = Console.ReadLine(); + switch (a) + { + case "y": + goto a; + break; + case "n": + end(player, caochao, win, win2, count); + break; + default: + break; + } + + break; + case 2: + player.cloth(); + caochao.rock(); + speak.win(); + win++; + count++; + speak.isgo(); + string b = Console.ReadLine(); + switch (b) + { + case "y": + goto a; + break; + case "n": + end(player, caochao, win, win2, count); + break; + default: + break; + } + + + break; + case 3: + player.cloth(); + caochao.cloth(); + speak.dogfall(); + count++; + speak.isgo(); + string c = Console.ReadLine(); + switch (c) + { + case "y": + goto a; + break; + case "n": + end(player, caochao, win, win2, count); + break; + default: + break; + } + break; + + + default: + break; + } + break; + + + default: + break; + } + } + private static void game(Player player, Sunquan sunquan) + { + int count = 0; + int win = 0; + int win2 = 0; + Random random = new Random(); + Speak speak = new Speak(); + a: speak.go(); + string key = Console.ReadLine(); + switch (key) + { + case "1": + int num = random.Next(1, 4); + switch (num) + { + case 1: + player.scissor(); + sunquan.scissor(); + speak.dogfall(); + count++; + speak.isgo(); + string a = Console.ReadLine(); + switch (a) + { + case "y": + goto a; + break; + case "n": + end(player, sunquan, win, win2, count); + break; + default: + break; + } + break; + case 2: + player.scissor(); + sunquan.rock(); + speak.lose(); + win2++; + count++; + speak.isgo(); + string b = Console.ReadLine(); + switch (b) + { + case "y": + goto a; + break; + case "n": + end(player, sunquan, win, win2, count); + break; + default: + break; + } + + break; + case 3: + player.scissor(); + sunquan.cloth(); + speak.win(); + win++; + count++; + speak.isgo(); + string y = Console.ReadLine(); + switch (y) + { + case "y": + goto a; + break; + case "n": + end(player, sunquan, win, win2, count); + break; + default: + break; + } + break; + + default: + break; + } + break; + case "2": + int num2 = random.Next(1, 4); + switch (num2) + { + case 1: + + player.rock(); + sunquan.scissor(); + speak.win(); + win++; + count++; + speak.isgo(); + string a = Console.ReadLine(); + switch (a) + { + case "y": + goto a; + break; + case "n": + end(player, sunquan, win, win2, count); + break; + default: + break; + } + break; + + case 2: + player.rock(); + sunquan.rock(); + speak.dogfall(); + count++; + speak.isgo(); + string b = Console.ReadLine(); + switch (b) + { + case "y": + goto a; + break; + case "n": + end(player, sunquan, win, win2, count); + break; + default: + break; + } + break; + + case 3: + player.rock(); + sunquan.cloth(); + speak.lose(); + win2++; + count++; + speak.isgo(); + string c = Console.ReadLine(); + switch (c) + { + case "y": + goto a; + break; + case "n": + end(player, sunquan, win, win2, count); + break; + default: + break; + } + break; + + default: + break; + } + break; + case "3": + int num3 = random.Next(1, 4); + switch (num3) + { + case 1: + + player.cloth(); + sunquan.scissor(); + speak.lose(); + win2++; + count++; + speak.isgo(); + string a = Console.ReadLine(); + switch (a) + { + case "y": + goto a; + break; + case "n": + end(player, sunquan, win, win2, count); + break; + default: + break; + } + + break; + case 2: + player.cloth(); + sunquan.rock(); + speak.win(); + win++; + count++; + speak.isgo(); + string b = Console.ReadLine(); + switch (b) + { + case "y": + goto a; + break; + case "n": + end(player, sunquan, win, win2, count); + break; + default: + break; + } + + + break; + case 3: + player.cloth(); + sunquan.cloth(); + speak.dogfall(); + count++; + speak.isgo(); + string c = Console.ReadLine(); + switch (c) + { + case "y": + goto a; + break; + case "n": + end(player, sunquan, win, win2, count); + break; + default: + break; + } + break; + + + default: + break; + } + break; + + + default: + break; + } + } + private static void end(Player player,Liubei liubei, int win, int win2, int count) + { + Console.WriteLine("==============================================="); + Console.WriteLine("{0} vs {1} 对战", player.Name, liubei.Name); + Console.WriteLine("对战次数:{0}", count); + Console.WriteLine(); + Console.WriteLine("姓名*********得分"); + Console.WriteLine("{0} {1}", player.Name, win); + Console.WriteLine("{0} {1}", liubei.Name, win2); + if (win > win2) { Console.WriteLine("结果: {0}赢,{1}笨蛋",player.Name,liubei.Name); } + if (win == win2) { Console.WriteLine("结果:{0}和{1} 平局", player.Name, liubei.Name); } + if (win < win2) { Console.WriteLine("结果: {0}赢,{1}笨蛋", liubei.Name, player.Name); } + Console.WriteLine("是否继续下一局?(y/n)"); + string key = Console.ReadLine(); + switch (key) + { + case "y": + home(); + break; + case "n": + break; + default: + break; + } + + } + private static void end(Player player, Sunquan sunquan, int win, int win2, int count) + { + Console.WriteLine("==============================================="); + Console.WriteLine("{0} vs {1} 对战", player.Name, sunquan.Name); + Console.WriteLine("对战次数:{0}", count); + Console.WriteLine(); + Console.WriteLine("姓名*********得分"); + Console.WriteLine("{0} {1}", player.Name, win); + Console.WriteLine("{0} {1}", sunquan.Name, win2); + if (win > win2) { Console.WriteLine("结果: {0}赢,{1}笨蛋", player.Name, sunquan.Name); } + if (win == win2) { Console.WriteLine("结果:{0}和{1} 平局", player.Name, sunquan.Name); } + if (win < win2) { Console.WriteLine("结果: {0}赢,{1}笨蛋", sunquan.Name, player.Name); } + Console.WriteLine("是否继续下一局?(y/n)"); + string key = Console.ReadLine(); + switch (key) + { + case "y": + home(); + break; + case "n": + break; + default: + break; + } + + } + private static void end(Player player,Caochao caochao, int win, int win2, int count) + { + Console.WriteLine("==============================================="); + Console.WriteLine("{0} vs {1} 对战", player.Name, caochao.Name); + Console.WriteLine("对战次数:{0}", count); + Console.WriteLine(); + Console.WriteLine("姓名*********得分"); + Console.WriteLine("{0} {1}", player.Name, win); + Console.WriteLine("{0} {1}", caochao.Name, win2); + if (win > win2) { Console.WriteLine("结果: {0}赢,{1}笨蛋", player.Name, caochao.Name); } + if (win == win2) { Console.WriteLine("结果:{0}和{1} 平局", player.Name, caochao.Name); } + if (win < win2) { Console.WriteLine("结果: {0}赢,{1}笨蛋", caochao.Name, player.Name); } + Console.WriteLine("是否继续下一局?(y/n)"); + string key = Console.ReadLine(); + switch (key) + { + case "y": + home(); + break; + case "n": + break; + default: + break; + } + + } + + + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\216\344\274\237/BattleInfo.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\216\344\274\237/BattleInfo.cs" new file mode 100644 index 0000000000000000000000000000000000000000..0f494c8f93cef9c80177d108cd159fedcf84c32c --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\216\344\274\237/BattleInfo.cs" @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 猜拳 +{ + abstract class BattleInfo + { + private string _name; + private int _throwPunch; + private string _throwPunchChinese; + + public BattleInfo(string name) + { + Name = name; + + } + + public string Name { get => _name; set => _name = value; } + public int ThrowPunch { get => _throwPunch; set => _throwPunch = value; } + public string ThrowPunchChinese { get => _throwPunchChinese; set => _throwPunchChinese = value; } + + + public virtual string Rule() + { + return $"{Name}:出拳:{ThrowPunchChinese}"; + } + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\216\344\274\237/Opponent.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\216\344\274\237/Opponent.cs" new file mode 100644 index 0000000000000000000000000000000000000000..85c0a659490452c029e72375560cbc29f43f71d5 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\216\344\274\237/Opponent.cs" @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 猜拳 +{ + class Opponent:BattleInfo + { + public Opponent(string name) : base(name) + { + } + + + public override string Rule () + { + return $"{Name}:出拳:{ThrowPunchChinese}"; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\216\344\274\237/Player.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\216\344\274\237/Player.cs" new file mode 100644 index 0000000000000000000000000000000000000000..e27558090ee791ebdc945eb45fb1c805bfad2236 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\216\344\274\237/Player.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 猜拳 +{ + class Player : BattleInfo + { + + public Player(string name) : base(name) + { + } + + + + public override string Rule() + { + return $"{Name}:出拳:{ThrowPunchChinese}"; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\216\344\274\237/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\216\344\274\237/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..25155a7cef993b322013bbd5e7d8a5f33a06ae79 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\216\344\274\237/Program.cs" @@ -0,0 +1,199 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 猜拳 +{ + enum Fight + { + 剪刀, + 石头, + 布 + } + class Program + { + + static Random ran = new Random(); + static int winRound = 0; + static int winRoundOp = 0; + + static int battleCount = 0; + static Opponent op; + static Player gamer; + 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.曹操"); + string opponenter = Console.ReadLine(); + switch (opponenter) + { + case "1": + op = new Opponent("刘备"); + Console.WriteLine("哈,旗鼓相当的对手"); + break; + + case "2": + op = new Opponent("孙权"); + break; + + case "3": + op = new Opponent("曹操"); + break; + } + + Console.WriteLine("请输入您的姓名"); + string userName = Console.ReadLine(); + gamer = new Player(userName); + + Console.WriteLine(); + while (true) + { + Battling(); + + + Console.WriteLine("你是否还想继续游戏 Y/N"); + string choose = Console.ReadLine(); + if (choose.Equals("n", StringComparison.OrdinalIgnoreCase)) + { + break; + } + else + { + continue; + } + + + + } + Console.WriteLine("==========================="); + Console.WriteLine($"{op.Name} vs {gamer.Name}"); + Console.WriteLine("对战次数{0}", battleCount); + Console.WriteLine(@"姓名 得分 +{0} {1} +{2} {3}", gamer.Name, winRound, op.Name, battleCount - winRound); + Console.WriteLine("是否想再来一把 Y/N"); + string choose2 = Console.ReadLine(); + if (choose2.Equals("n",StringComparison.OrdinalIgnoreCase)) + { + break; + } + else + { + continue; + } + } + Console.WriteLine("结束了,别再来了好吗"); + + + + + + + + + Console.ReadKey(); + } + + private static void Battling() + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布"); + + int throwPunch = int.Parse(Console.ReadLine()); + gamer.ThrowPunch = throwPunch; + Change(gamer); + Console.WriteLine(gamer.Rule()); + + op.ThrowPunch = ran.Next(1, 4); + Change(op); + + Console.WriteLine(op.Rule()); + JudgeRule(gamer, op); + battleCount++; + } + + static void Change(BattleInfo a) + { + if (a.ThrowPunch == 1) + { + a.ThrowPunchChinese = "剪刀"; + } + else if (a.ThrowPunch == 2) + { + a.ThrowPunchChinese = "石头"; + } + else if (a.ThrowPunch == 3) + { + a.ThrowPunchChinese = "布"; + } + + + } + static void JudgeRule(Player a, Opponent b) + { + //1.剪刀 2.石头 3.布 + if (a.ThrowPunch == 1)//剪刀 + { + if (b.ThrowPunch == a.ThrowPunch) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧。"); + } + else if (b.ThrowPunch == 2) + { + Console.WriteLine($"笨蛋,{a.Name}输了"); + winRoundOp++; + } + else if (b.ThrowPunch == 3) + { + Console.WriteLine($"恭喜,{a.Name}胜出"); + winRound++; + } + } + + if (a.ThrowPunch == 2)//石头 + { + if (b.ThrowPunch == a.ThrowPunch) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧。"); + } + else if (b.ThrowPunch == 3) + { + Console.WriteLine($"笨蛋,{a.Name}输了"); + winRoundOp++; + } + else if (b.ThrowPunch == 1) + { + Console.WriteLine($"恭喜,{a.Name}胜出"); + winRound++; + } + } + if (a.ThrowPunch == 3)//布 + { + if (b.ThrowPunch == a.ThrowPunch) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧。"); + } + else if (b.ThrowPunch == 1) + { + Console.WriteLine($"笨蛋,{a.Name}输了"); + winRoundOp++; + } + else if (b.ThrowPunch == 2) + { + Console.WriteLine($"恭喜,{a.Name}胜出"); + winRound++; + } + } + + + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\216\350\213\261\347\276\244/.keep" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\216\350\213\261\347\276\244/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\216\350\213\261\347\276\244/\344\275\234\344\270\232/Father.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\216\350\213\261\347\276\244/\344\275\234\344\270\232/Father.cs" new file mode 100644 index 0000000000000000000000000000000000000000..250fba309a47b7dfb413f285dd250aaa227d8716 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\216\350\213\261\347\276\244/\344\275\234\344\270\232/Father.cs" @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo +{ + class Father + { + public string Name { get; set; } + + public Father() + { + } + + public Father(string name) + { + Name = name; + } + public virtual string Xingwei() + { + return null; + } + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\216\350\213\261\347\276\244/\344\275\234\344\270\232/Game.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\216\350\213\261\347\276\244/\344\275\234\344\270\232/Game.cs" new file mode 100644 index 0000000000000000000000000000000000000000..bedb9d465bb06312e4d1f0227b7b6c6319a8bbe6 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\216\350\213\261\347\276\244/\344\275\234\344\270\232/Game.cs" @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo +{ + class Game + { + internal bool Gaming(Role r, Player p) + { + int sum=0; + int rNum=0; + int pNum=0; + while (true) + { + sum++; + string A = r.Xingwei(); + string B = p.Xingwei(); + Console.WriteLine($"{p.Name} 出拳:{B}"); + Console.WriteLine($"{r.Name} 出拳:{A} "); + IsWin(A, B, p.Name, ref rNum, ref pNum); + while (true) + { + Console.WriteLine("是否开始下一轮?"); + string s = Console.ReadLine(); + if (s == "y") + { + break; + } + else if (s == "n") + { + bool v = EndGame(r.Name,p.Name,sum,rNum,pNum); + return v; + } + else + { + Console.WriteLine("您输入有误,请重新输入"); + continue; + } + } + + } + + } + + private bool EndGame(string name1, string name2, int sum, int rNum, int pNum) + { + Console.WriteLine("==================================="); + Console.WriteLine($"{name1} VS {name2}"); + Console.WriteLine($"对战次数:{sum}"); + Console.WriteLine(); + Console.WriteLine("姓名\t得分"); + Console.WriteLine($"{name1}\t{rNum}"); + Console.WriteLine($"{name2}\t{pNum}"); + if (rNum > pNum) + { + Console.WriteLine($"结果:{name1}赢了,{name2}输了"); + } + else if (rNum < pNum) + { + Console.WriteLine($"结果:{name2}赢了,{name1}输了"); + + } + else { + Console.WriteLine("平局"); + } + Console.WriteLine("要开始下一局吗?(y/n)"); + string s = Console.ReadLine(); + if (s=="n") { + return false; + } + else if (s=="y") + { + return true; + } + return true; + } + + public void IsWin(string A, string B, string name, ref int rNum, ref int pNum) + { + + if ((A == "剪刀" && B == "布") || (A == "布" && B == "石头") || (A=="石头" && B=="剪刀")) + { + rNum++; + Console.WriteLine($"笨蛋,{name}输了"); + } + else if (A==B) + { + Console.WriteLine($"和局,真衰!嘿嘿,等着瞧吧!"); + } + else + { + pNum++; + Console.WriteLine($"恭喜,{name}赢了!"); + } + + + } + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\216\350\213\261\347\276\244/\344\275\234\344\270\232/Player.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\216\350\213\261\347\276\244/\344\275\234\344\270\232/Player.cs" new file mode 100644 index 0000000000000000000000000000000000000000..5d3a8bb03674571b60090e8887bca2399b40cb4e --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\216\350\213\261\347\276\244/\344\275\234\344\270\232/Player.cs" @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo +{ + class Player : Father + { + public Player(string Name) : base(Name) + { + + } + public Player() { } + + public override string Xingwei() + { + base.Xingwei(); + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布"); + int a = int.Parse(Console.ReadLine()); + switch (a) + { + case 1: + return "剪刀"; + case 2: + return "石头"; + case 3: + return "布"; + default: + break; + } + + return null; + + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\216\350\213\261\347\276\244/\344\275\234\344\270\232/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\216\350\213\261\347\276\244/\344\275\234\344\270\232/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..c068dd1bc844235c652f843891194b7f8e3e84df --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\216\350\213\261\347\276\244/\344\275\234\344\270\232/Program.cs" @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo +{ + + class Program + { + static void Main(string[] args) + { + Console.WriteLine("-----------------欢迎进入游戏世界-----------------"); + Console.WriteLine(); + while (true) + { + Console.WriteLine("********************"); + Console.WriteLine("*****猜拳,开始*****"); + Console.WriteLine("********************"); + + + //Console.WriteLine("请输入您的姓名:"); + //string str = Console.ReadLine(); + //Console.WriteLine($"{a} VS {str} 对战"); + //Console.WriteLine("开始游戏吗?"); + + Console.WriteLine("请选择对方角色:1.刘备 2.孙权 3.曹操"); + int a = int.Parse(Console.ReadLine()); + Role r = new Role(); + switch (a) + { + case 1: + r = new Role("刘备"); + break; + case 2: + r = new Role("孙权"); + break; + case 3: + r = new Role("曹操"); + break; + default: + break; + } + Player p = new Player(); + Console.WriteLine("请输入您的名字:"); + p.Name = Console.ReadLine(); + + Console.WriteLine($"{p.Name} VS {r.Name} 对战"); + Console.WriteLine("开始游戏吗 "); + string xuan = Console.ReadLine(); + if (xuan == "n") + { + return; + } + Game g = new Game(); + bool v = g.Gaming(r, p); + if (v==false) + { + Console.WriteLine("系统退出"); + return; + } + } + + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\216\350\213\261\347\276\244/\344\275\234\344\270\232/Role.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\216\350\213\261\347\276\244/\344\275\234\344\270\232/Role.cs" new file mode 100644 index 0000000000000000000000000000000000000000..57d62c48c91e551cb80bc5477f52b483761e4a2a --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\216\350\213\261\347\276\244/\344\275\234\344\270\232/Role.cs" @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo +{ + class Role : Father + { + public Role(string Name):base(Name) + { + } + public Role() { } + public override string Xingwei() + { + base.Xingwei(); + + Random r = new Random(); + int v = r.Next(1,4); + + switch (v) + { + case 1: + return "剪刀"; + case 2: + return "石头"; + case 3: + return "布"; + default: + break; + } + + return null; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\250\344\270\226\347\221\236/.keep" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\250\344\270\226\347\221\236/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\250\344\270\226\347\221\236/Info.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\250\344\270\226\347\221\236/Info.cs" new file mode 100644 index 0000000000000000000000000000000000000000..66a257adcfa820e06022a81eecb7eeb5104ba2f2 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\250\344\270\226\347\221\236/Info.cs" @@ -0,0 +1,10 @@ +namespace 三式 +{ + class Info + { + + public string Name { get; set; } + public int PunchId { get; set; } + public string PunchName { get; set; } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\250\344\270\226\347\221\236/Player.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\250\344\270\226\347\221\236/Player.cs" new file mode 100644 index 0000000000000000000000000000000000000000..d56052a1342e31e8a795380ad712eb1490bdb8b0 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\250\344\270\226\347\221\236/Player.cs" @@ -0,0 +1,18 @@ +namespace 三式 +{ + class Player : Info + { + public void PlayerName(string name) + { + Name = name; + } + public void PlayerPunch(int x) + { + PunchId = x; + if (PunchId == 1) { PunchName = "石头"; } + else if (PunchId == 2) { PunchName = "剪刀"; } + else if (PunchId == 3) { PunchName = "布"; } + } + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\250\344\270\226\347\221\236/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\250\344\270\226\347\221\236/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..6b5741b08af65d6de39ae2fd80f443d7840f0648 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\250\344\270\226\347\221\236/Program.cs" @@ -0,0 +1,150 @@ +using System; + +namespace 三式 +{ + class Program + { + static void Main(string[] args) + { + Robot robot = new Robot(); + Player player = new Player(); + Referee referee = new Referee(); + Teller teller = new Teller(); + int x; + int Winner; + string str; + bool PD; + bool PD1; + while (true) + { + PD = true; + PD1 = true; + Console.WriteLine("*******************欢迎进入游戏世界*******************"); + Console.WriteLine(); + Console.WriteLine("******************"); + Console.WriteLine("*****猜拳开始*****"); + Console.WriteLine("******************"); + Console.WriteLine("出拳规则:1.石头 2.剪刀 3.布"); + Console.WriteLine("请选择你的对手:(1.刘备 2.孙权 3.曹操)"); + while (true) + { + str = Console.ReadLine(); + if (str == "1" || str == "2" || str == "3") + { + robot.RobotName(str); + break; + } + else + { + Console.WriteLine("请输入正确的号码!"); + continue; + } + } + Console.WriteLine("请输入你的名字:"); + player.PlayerName(Console.ReadLine()); + teller.VS(robot.Name, player.Name); + while (PD) + { + Console.WriteLine("开始游戏吗?(y/n)"); + while (true) + { + str = Console.ReadLine(); + if (str == "y" || str == "n") + { + break; + } + else + { + Console.WriteLine("输入错误,请重新输入!"); + continue; + } + } + if (str == "y") + { + while (PD1) + { + Console.WriteLine("请出拳: 1.石头 2.剪刀 3.布"); + while (true) + { + str = Console.ReadLine(); + if (str == "1" || str == "2" || str == "3") + { + break; + } + else + { + Console.WriteLine("输入错误,请重试!( 1.石头 2.剪刀 3.布)"); + continue; + } + } + x = int.Parse(str); + player.PlayerPunch(x);//记录玩家出拳Id + Random random = new Random(); + int y = random.Next(1, 4); + robot.RobotPunch(y);//记录机器人出拳Id + Winner = referee.PK(player.PunchId, robot.PunchId); + teller.Say(Winner, player.Name, robot.Name, player.PunchName, robot.PunchName); + Console.WriteLine("继续游戏吗?(y/n)"); + while (true) + { + str = Console.ReadLine(); + if (str == "y") + { + break; + } + else if (str == "n") + { + teller.Over(player.Name, robot.Name, referee.Round, referee.Deuce,referee.PlayerWin, referee.RobotWin); + PD1 = false; + break; + } + else + { + Console.WriteLine("输入错误,请重试!"); + continue; + } + } + + } + break; + } + else if (str == "n") + { + Console.WriteLine(); + Console.WriteLine("请输入:1.继续游戏 2.退出程序"); + str = Console.ReadLine(); + while (true) + { + if (str == "1") { break; } + else if (str == "2") { Environment.Exit(0); } + else + { + Console.WriteLine("输入错误,请重新输入!"); + continue; + } + } + } + } + Console.WriteLine(); + Console.WriteLine("请输入:1.重新开始游戏 2.退出程序"); + str = Console.ReadLine(); + while (true) + { + if (str == "1") + { + break; + } + else if (str == "2") + { + Environment.Exit(0); + } + else + { + Console.WriteLine("输入错误,请重新输入!"); + continue; + } + } + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\250\344\270\226\347\221\236/Referee.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\250\344\270\226\347\221\236/Referee.cs" new file mode 100644 index 0000000000000000000000000000000000000000..db36235bdb8c5623e05754a2b9ab0cd935971f99 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\250\344\270\226\347\221\236/Referee.cs" @@ -0,0 +1,21 @@ +namespace 三式 +{ + class Referee + { + public int Round = 0;//回合数 + public int PlayerWin = 0;//玩家胜场 + public int RobotWin = 0;//机器人胜场 + public int Deuce = 0;//平局数 + public int PK(int x, int y) + { + if ((x - y) == -1) { Round++; PlayerWin++; return 1; }// return 1;表示玩家胜 + else if ((x - y) == 1) { Round++; RobotWin++; return 2; }//表示机器人胜 + else if ((x - y) == 2) { Round++; PlayerWin++; return 1; }// 表示玩家胜 + else if ((x - y) == -2) { Round++; RobotWin++; return 2; }//表示机器人胜 + else if ((x - y) == 0) { Round++; Deuce++; return 3; }//表示平局 + else { return 0; }//这行不可能发生 + } + + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\250\344\270\226\347\221\236/Robot.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\250\344\270\226\347\221\236/Robot.cs" new file mode 100644 index 0000000000000000000000000000000000000000..dd7c8ef954ff40d8c31ed24d5a2f97d3ed6753e0 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\250\344\270\226\347\221\236/Robot.cs" @@ -0,0 +1,29 @@ +using System; +namespace 三式 +{ + class Robot : Info + { + public void RobotName(string str) + { + switch (str) + { + case "1": + Name = "刘备"; + break; + case "2": + Name = "孙权"; + break; + case "3": + Name = "曹操"; + break; + } + } + public void RobotPunch(int x) + { + + if (x == 1) { PunchId = 1; PunchName = "石头"; } + else if (x == 2) { PunchId = 2; PunchName = "剪刀"; } + else if (x == 3) { PunchId = 3; PunchName = "布"; } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\250\344\270\226\347\221\236/Teller.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\250\344\270\226\347\221\236/Teller.cs" new file mode 100644 index 0000000000000000000000000000000000000000..f6b0e417d52c6081460248b27fc977598feddc1a --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\235\250\344\270\226\347\221\236/Teller.cs" @@ -0,0 +1,37 @@ +using System; + +namespace 三式 +{ + class Teller + { + public void VS(string playerName, string robotName) + { + Console.WriteLine("{0} VS {1} 对战", playerName, robotName); + } + public void Say(int Winner, string playerName, string robotName, string playerPunchName, string robotPunchName) + { + Console.WriteLine("选手 出拳"); + Console.WriteLine(playerName + " | " + playerPunchName); + Console.WriteLine(robotName + " | " + robotPunchName); + if (Winner == 1) { Console.WriteLine("都怪你,{0}这轮输了啦!", robotName); } + else if (Winner == 2) { Console.WriteLine("嘻嘻,{0}这轮赢了!", robotName); } + else if(Winner==3){ Console.WriteLine("居然平局了,真晦气!"); } + } + public void Over(string playerName, string robotName, int round,int deuce, int playerWin, int RobotWin) + { + Console.WriteLine("{0} VS {1}", playerName, robotName); + Console.WriteLine("**************"); + Console.WriteLine("对战次数:{0}", round); + Console.WriteLine("平局次数:{0}",deuce); + Console.WriteLine(); + Console.WriteLine("姓名 胜场"); + Console.WriteLine(); + Console.WriteLine("{0} {1}", playerName, playerWin); + Console.WriteLine("{0} {1}", robotName, RobotWin); + Console.WriteLine("**************"); + if (playerWin > RobotWin) { Console.WriteLine("{0}赢了,芜湖!!!", playerName); } + else if (playerWin < RobotWin) { Console.WriteLine("{0}赢了啦,我超勇的!", robotName); } + else { Console.WriteLine("平局了,真晦气!"); } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\200\235\345\260\271/.keep" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\200\235\345\260\271/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\200\235\345\260\271/BattleInfo.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\200\235\345\260\271/BattleInfo.cs" new file mode 100644 index 0000000000000000000000000000000000000000..c6afb6bb3bdd419f39bbda6ad8dc07c3dc18f8c5 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\200\235\345\260\271/BattleInfo.cs" @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 猜拳 +{ + abstract class BattleInfo + { + private string _name; + private int _throwPunch; + private string _throwPunchChinese; + + public BattleInfo(string name) + { + Name = name; + + } + + public string Name { get => _name; set => _name = value; } + public int ThrowPunch { get => _throwPunch; set => _throwPunch = value; } + public string ThrowPunchChinese { get => _throwPunchChinese; set => _throwPunchChinese = value; } + + //出拳的信息 + public virtual string Rule() + { + return $"{Name}:出拳:{ThrowPunchChinese}"; + } + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\200\235\345\260\271/Opponent.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\200\235\345\260\271/Opponent.cs" new file mode 100644 index 0000000000000000000000000000000000000000..407d957b7e43451f72cbdbcdbb9a2ea3c05c1f31 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\200\235\345\260\271/Opponent.cs" @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 猜拳 +{ + class Opponent:BattleInfo + { + public Opponent(string name) : base(name) + { + } + + //出拳的信息 + public override string Rule () + { + return $"{Name}:出拳:{ThrowPunchChinese}"; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\200\235\345\260\271/Player.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\200\235\345\260\271/Player.cs" new file mode 100644 index 0000000000000000000000000000000000000000..379c1cafd9e45c62b69e06e473071a66c5c77a09 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\200\235\345\260\271/Player.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 猜拳 +{ + class Player : BattleInfo + { + + public Player(string name) : base(name) + { + } + + + //出拳的信息 + public override string Rule() + { + return $"{Name}:出拳:{ThrowPunchChinese}"; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\200\235\345\260\271/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\200\235\345\260\271/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..0f1ea987a58b91e14b7d6a98da884526fedaa906 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\200\235\345\260\271/Program.cs" @@ -0,0 +1,199 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 猜拳 +{ + enum Fight + { + 剪刀, + 石头, + 巴掌 + } + class Program + { + + static Random ran = new Random(); + static int winRound = 0; + static int winRoundOp = 0; + + static int battleCount = 0; + static Opponent op; + static Player gamer; + 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.曹操"); + string opponenter = Console.ReadLine(); + switch (opponenter) + { + case "1": + op = new Opponent("刘备"); + Console.WriteLine("hoho~,旗鼓相当的对手");//可以用继承 把刘备曹操孙权,各些成一个类 + break; + + case "2": + op = new Opponent("孙权"); + break; + + case "3": + op = new Opponent("曹操"); + break; + } + + Console.WriteLine("请输入您的姓名"); + string userName = Console.ReadLine(); + gamer = new Player(userName); + + Console.WriteLine(); + while (true) + { + Battling(); + + + Console.WriteLine("你是否还想继续游戏 Y/N"); + string choose = Console.ReadLine(); + if (choose.Equals("n", StringComparison.OrdinalIgnoreCase)) + { + break; + } + else + { + continue; + } + + + + } + Console.WriteLine("==========================="); + Console.WriteLine($"{op.Name} vs {gamer.Name}"); + Console.WriteLine("对战次数{0}", battleCount); + Console.WriteLine(@"姓名 得分 +{0} {1} +{2} {3}", gamer.Name, winRound, op.Name, battleCount - winRound); + Console.WriteLine("是否想再来battle一把 Y/N"); + string choose2 = Console.ReadLine(); + if (choose2.Equals("n",StringComparison.OrdinalIgnoreCase)) + { + break; + } + else + { + continue; + } + } + Console.WriteLine("结束了,别再来作业来了好吗"); + + + + + + + + + Console.ReadKey(); + } + + private static void Battling() + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.巴掌");//把出拳写成一个方法 + + int throwPunch = int.Parse(Console.ReadLine()); + gamer.ThrowPunch = throwPunch; + Change(gamer); + Console.WriteLine(gamer.Rule());//把出拳的内容 原本是数字 换成中文 + + op.ThrowPunch = ran.Next(1, 4); + Change(op); + + Console.WriteLine(op.Rule()); + JudgeRule(gamer, op); + battleCount++; + } + + static void Change(BattleInfo a) + { + if (a.ThrowPunch == 1) + { + a.ThrowPunchChinese = "剪刀"; + } + else if (a.ThrowPunch == 2) + { + a.ThrowPunchChinese = "石头"; + } + else if (a.ThrowPunch == 3) + { + a.ThrowPunchChinese = "布"; + } + + + } + static void JudgeRule(Player a, Opponent b)//前者是玩家,后者人机 + { + //1.剪刀 2.石头 3.布 + if (a.ThrowPunch == 1)//剪刀 + { + if (b.ThrowPunch == a.ThrowPunch) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧。"); + } + else if (b.ThrowPunch == 2) + { + Console.WriteLine($"笨蛋,{a.Name}输了"); + winRoundOp++; + } + else if (b.ThrowPunch == 3) + { + Console.WriteLine($"恭喜,{a.Name}胜出"); + winRound++; + } + } + + if (a.ThrowPunch == 2)//石头 + { + if (b.ThrowPunch == a.ThrowPunch) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧。"); + } + else if (b.ThrowPunch == 3) + { + Console.WriteLine($"笨蛋,{a.Name}输了"); + winRoundOp++; + } + else if (b.ThrowPunch == 1) + { + Console.WriteLine($"恭喜,{a.Name}胜出"); + winRound++; + } + } + if (a.ThrowPunch == 3)//布 + { + if (b.ThrowPunch == a.ThrowPunch) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧。"); + } + else if (b.ThrowPunch == 1) + { + Console.WriteLine($"笨蛋,{a.Name}输了"); + winRoundOp++; + } + else if (b.ThrowPunch == 2) + { + Console.WriteLine($"恭喜,{a.Name}胜出"); + winRound++; + } + } + + + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\265\267\345\263\260/.keep" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\265\267\345\263\260/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\265\267\345\263\260/Info.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\265\267\345\263\260/Info.cs" new file mode 100644 index 0000000000000000000000000000000000000000..27414a76e2ab21aac8d2de8b0c0ef8e711b4b281 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\265\267\345\263\260/Info.cs" @@ -0,0 +1,10 @@ +?namespace ȭ +{ + class Info + { + + public string Name { get; set; } + public int PunchId { get; set; } + public string PunchName { get; set; } + } +} \ No newline at end of file diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\265\267\345\263\260/Player.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\265\267\345\263\260/Player.cs" new file mode 100644 index 0000000000000000000000000000000000000000..fce8eeee6adc2ab47287f7ddb63389995d30fc0e --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\265\267\345\263\260/Player.cs" @@ -0,0 +1,18 @@ +namespace ȭ +{ + class Player : Info + { + public void PlayerName(string name) + { + Name = name; + } + public void PlayerPunch(int x) + { + PunchId = x; + if (PunchId == 1) { PunchName = "ʯͷ"; } + else if (PunchId == 2) { PunchName = ""; } + else if (PunchId == 3) { PunchName = ""; } + } + + } +} \ No newline at end of file diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\265\267\345\263\260/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\265\267\345\263\260/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..2264dab8f04cb912eb7bc77d619347aed30d2dbb --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\265\267\345\263\260/Program.cs" @@ -0,0 +1,150 @@ +?using System; + +namespace ȭ +{ + class Program + { + static void Main(string[] args) + { + Robot robot = new Robot(); + Player player = new Player(); + Referee referee = new Referee(); + Teller teller = new Teller(); + int x; + int Winner; + string str; + bool PD; + bool PD1; + while (true) + { + PD = true; + PD1 = true; + Console.WriteLine("*******************ӭϷ*******************"); + Console.WriteLine(); + Console.WriteLine("******************"); + Console.WriteLine("*****ȭʼ*****"); + Console.WriteLine("******************"); + Console.WriteLine("ȭ1.ʯͷ 2. 3."); + Console.WriteLine("ѡĶ֣1. 2.Ȩ 3.ܲ٣"); + while (true) + { + str = Console.ReadLine(); + if (str == "1" || str == "2" || str == "3") + { + robot.RobotName(str); + break; + } + else + { + Console.WriteLine("ȷĺ룡"); + continue; + } + } + Console.WriteLine("֣"); + player.PlayerName(Console.ReadLine()); + teller.VS(robot.Name, player.Name); + while (PD) + { + Console.WriteLine("ʼϷ𣿣y/n"); + while (true) + { + str = Console.ReadLine(); + if (str == "y" || str == "n") + { + break; + } + else + { + Console.WriteLine("룡"); + continue; + } + } + if (str == "y") + { + while (PD1) + { + Console.WriteLine("ȭ 1.ʯͷ 2. 3."); + while (true) + { + str = Console.ReadLine(); + if (str == "1" || str == "2" || str == "3") + { + break; + } + else + { + Console.WriteLine("ԣ( 1.ʯͷ 2. 3.)"); + continue; + } + } + x = int.Parse(str); + player.PlayerPunch(x);//¼ҳȭId + Random random = new Random(); + int y = random.Next(1, 4); + robot.RobotPunch(y);//¼˳ȭId + Winner = referee.PK(player.PunchId, robot.PunchId); + teller.Say(Winner, player.Name, robot.Name, player.PunchName, robot.PunchName); + Console.WriteLine("Ϸ𣿣y/n"); + while (true) + { + str = Console.ReadLine(); + if (str == "y") + { + break; + } + else if (str == "n") + { + teller.Over(player.Name, robot.Name, referee.Round, referee.Deuce,referee.PlayerWin, referee.RobotWin); + PD1 = false; + break; + } + else + { + Console.WriteLine("ԣ"); + continue; + } + } + + } + break; + } + else if (str == "n") + { + Console.WriteLine(); + Console.WriteLine("룺1.Ϸ 2.˳"); + str = Console.ReadLine(); + while (true) + { + if (str == "1") { break; } + else if (str == "2") { Environment.Exit(0); } + else + { + Console.WriteLine("룡"); + continue; + } + } + } + } + Console.WriteLine(); + Console.WriteLine("룺1.¿ʼϷ 2.˳"); + str = Console.ReadLine(); + while (true) + { + if (str == "1") + { + break; + } + else if (str == "2") + { + Environment.Exit(0); + } + else + { + Console.WriteLine("룡"); + continue; + } + } + } + } + } +} \ No newline at end of file diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\265\267\345\263\260/Referee.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\265\267\345\263\260/Referee.cs" new file mode 100644 index 0000000000000000000000000000000000000000..4624e478f1cf6341b758a9d3086a854a7692c468 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\265\267\345\263\260/Referee.cs" @@ -0,0 +1,21 @@ +?namespace ȭ +{ + class Referee + { + public int Round = 0;//غ + public int PlayerWin = 0;//ʤ + public int RobotWin = 0;//ʤ + public int Deuce = 0;//ƽ + public int PK(int x, int y) + { + if ((x - y) == -1) { Round++; PlayerWin++; return 1; }// return 1;ʾʤ + else if ((x - y) == 1) { Round++; RobotWin++; return 2; }//ʾʤ + else if ((x - y) == 2) { Round++; PlayerWin++; return 1; }// ʾʤ + else if ((x - y) == -2) { Round++; RobotWin++; return 2; }//ʾʤ + else if ((x - y) == 0) { Round++; Deuce++; return 3; }//ʾƽ + else { return 0; }//вܷ + } + + + } +} \ No newline at end of file diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\265\267\345\263\260/Robot.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\265\267\345\263\260/Robot.cs" new file mode 100644 index 0000000000000000000000000000000000000000..6a3511838e520b0e31ec00e15dc8b9cca728aa44 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\265\267\345\263\260/Robot.cs" @@ -0,0 +1,29 @@ +using System; +namespace ȭ +{ + class Robot : Info + { + public void RobotName(string str) + { + switch (str) + { + case "1": + Name = ""; + break; + case "2": + Name = "Ȩ"; + break; + case "3": + Name = "ܲ"; + break; + } + } + public void RobotPunch(int x) + { + + if (x == 1) { PunchId = 1; PunchName = "ʯͷ"; } + else if (x == 2) { PunchId = 2; PunchName = ""; } + else if (x == 3) { PunchId = 3; PunchName = ""; } + } + } +} \ No newline at end of file diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\265\267\345\263\260/Teller.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\265\267\345\263\260/Teller.cs" new file mode 100644 index 0000000000000000000000000000000000000000..22ce0d15a9c1e30c058800f665c0fb720a6895dd --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\236\227\346\265\267\345\263\260/Teller.cs" @@ -0,0 +1,37 @@ +using System; + +namespace ȭ +{ + class Teller + { + public void VS(string playerName, string robotName) + { + Console.WriteLine("{0} VS {1} ս", playerName, robotName); + } + public void Say(int Winner, string playerName, string robotName, string playerPunchName, string robotPunchName) + { + Console.WriteLine("ѡ ȭ"); + Console.WriteLine(playerName + " | " + playerPunchName); + Console.WriteLine(robotName + " | " + robotPunchName); + if (Winner == 1) { Console.WriteLine(",{0}", robotName); } + else if (Winner == 2) { Console.WriteLine("{0}Ӯˣ", robotName); } + else if(Winner==3){ Console.WriteLine("Ȼƽˣ"); } + } + public void Over(string playerName, string robotName, int round,int deuce, int playerWin, int RobotWin) + { + Console.WriteLine("{0} VS {1}", playerName, robotName); + Console.WriteLine("**************"); + Console.WriteLine("ս{0}", round); + Console.WriteLine("ƽִ{0}",deuce); + Console.WriteLine(); + Console.WriteLine(" ʤ"); + Console.WriteLine(); + Console.WriteLine("{0} {1}", playerName, playerWin); + Console.WriteLine("{0} {1}", robotName, RobotWin); + Console.WriteLine("**************"); + if (playerWin > RobotWin) { Console.WriteLine("{0}Ӯˣߺ", playerName); } + else if (playerWin < RobotWin) { Console.WriteLine("{0}Ӯҳµģ", robotName); } + else { Console.WriteLine("ƽˣ"); } + } + } +} \ No newline at end of file diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\242\201\351\223\266\350\212\235/.keep" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\242\201\351\223\266\350\212\235/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\242\201\351\223\266\350\212\235/1/BattleInfo.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\242\201\351\223\266\350\212\235/1/BattleInfo.cs" new file mode 100644 index 0000000000000000000000000000000000000000..0f494c8f93cef9c80177d108cd159fedcf84c32c --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\242\201\351\223\266\350\212\235/1/BattleInfo.cs" @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 猜拳 +{ + abstract class BattleInfo + { + private string _name; + private int _throwPunch; + private string _throwPunchChinese; + + public BattleInfo(string name) + { + Name = name; + + } + + public string Name { get => _name; set => _name = value; } + public int ThrowPunch { get => _throwPunch; set => _throwPunch = value; } + public string ThrowPunchChinese { get => _throwPunchChinese; set => _throwPunchChinese = value; } + + + public virtual string Rule() + { + return $"{Name}:出拳:{ThrowPunchChinese}"; + } + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\242\201\351\223\266\350\212\235/1/Opponent.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\242\201\351\223\266\350\212\235/1/Opponent.cs" new file mode 100644 index 0000000000000000000000000000000000000000..85c0a659490452c029e72375560cbc29f43f71d5 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\242\201\351\223\266\350\212\235/1/Opponent.cs" @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 猜拳 +{ + class Opponent:BattleInfo + { + public Opponent(string name) : base(name) + { + } + + + public override string Rule () + { + return $"{Name}:出拳:{ThrowPunchChinese}"; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\242\201\351\223\266\350\212\235/1/Player.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\242\201\351\223\266\350\212\235/1/Player.cs" new file mode 100644 index 0000000000000000000000000000000000000000..e27558090ee791ebdc945eb45fb1c805bfad2236 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\242\201\351\223\266\350\212\235/1/Player.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 猜拳 +{ + class Player : BattleInfo + { + + public Player(string name) : base(name) + { + } + + + + public override string Rule() + { + return $"{Name}:出拳:{ThrowPunchChinese}"; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\242\201\351\223\266\350\212\235/1/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\242\201\351\223\266\350\212\235/1/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..25155a7cef993b322013bbd5e7d8a5f33a06ae79 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\242\201\351\223\266\350\212\235/1/Program.cs" @@ -0,0 +1,199 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 猜拳 +{ + enum Fight + { + 剪刀, + 石头, + 布 + } + class Program + { + + static Random ran = new Random(); + static int winRound = 0; + static int winRoundOp = 0; + + static int battleCount = 0; + static Opponent op; + static Player gamer; + 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.曹操"); + string opponenter = Console.ReadLine(); + switch (opponenter) + { + case "1": + op = new Opponent("刘备"); + Console.WriteLine("哈,旗鼓相当的对手"); + break; + + case "2": + op = new Opponent("孙权"); + break; + + case "3": + op = new Opponent("曹操"); + break; + } + + Console.WriteLine("请输入您的姓名"); + string userName = Console.ReadLine(); + gamer = new Player(userName); + + Console.WriteLine(); + while (true) + { + Battling(); + + + Console.WriteLine("你是否还想继续游戏 Y/N"); + string choose = Console.ReadLine(); + if (choose.Equals("n", StringComparison.OrdinalIgnoreCase)) + { + break; + } + else + { + continue; + } + + + + } + Console.WriteLine("==========================="); + Console.WriteLine($"{op.Name} vs {gamer.Name}"); + Console.WriteLine("对战次数{0}", battleCount); + Console.WriteLine(@"姓名 得分 +{0} {1} +{2} {3}", gamer.Name, winRound, op.Name, battleCount - winRound); + Console.WriteLine("是否想再来一把 Y/N"); + string choose2 = Console.ReadLine(); + if (choose2.Equals("n",StringComparison.OrdinalIgnoreCase)) + { + break; + } + else + { + continue; + } + } + Console.WriteLine("结束了,别再来了好吗"); + + + + + + + + + Console.ReadKey(); + } + + private static void Battling() + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布"); + + int throwPunch = int.Parse(Console.ReadLine()); + gamer.ThrowPunch = throwPunch; + Change(gamer); + Console.WriteLine(gamer.Rule()); + + op.ThrowPunch = ran.Next(1, 4); + Change(op); + + Console.WriteLine(op.Rule()); + JudgeRule(gamer, op); + battleCount++; + } + + static void Change(BattleInfo a) + { + if (a.ThrowPunch == 1) + { + a.ThrowPunchChinese = "剪刀"; + } + else if (a.ThrowPunch == 2) + { + a.ThrowPunchChinese = "石头"; + } + else if (a.ThrowPunch == 3) + { + a.ThrowPunchChinese = "布"; + } + + + } + static void JudgeRule(Player a, Opponent b) + { + //1.剪刀 2.石头 3.布 + if (a.ThrowPunch == 1)//剪刀 + { + if (b.ThrowPunch == a.ThrowPunch) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧。"); + } + else if (b.ThrowPunch == 2) + { + Console.WriteLine($"笨蛋,{a.Name}输了"); + winRoundOp++; + } + else if (b.ThrowPunch == 3) + { + Console.WriteLine($"恭喜,{a.Name}胜出"); + winRound++; + } + } + + if (a.ThrowPunch == 2)//石头 + { + if (b.ThrowPunch == a.ThrowPunch) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧。"); + } + else if (b.ThrowPunch == 3) + { + Console.WriteLine($"笨蛋,{a.Name}输了"); + winRoundOp++; + } + else if (b.ThrowPunch == 1) + { + Console.WriteLine($"恭喜,{a.Name}胜出"); + winRound++; + } + } + if (a.ThrowPunch == 3)//布 + { + if (b.ThrowPunch == a.ThrowPunch) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧。"); + } + else if (b.ThrowPunch == 1) + { + Console.WriteLine($"笨蛋,{a.Name}输了"); + winRoundOp++; + } + else if (b.ThrowPunch == 2) + { + Console.WriteLine($"恭喜,{a.Name}胜出"); + winRound++; + } + } + + + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\256\267\346\231\250\346\227\255/.keep" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\256\267\346\231\250\346\227\255/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\256\267\346\231\250\346\227\255/FG.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\256\267\346\231\250\346\227\255/FG.cs" new file mode 100644 index 0000000000000000000000000000000000000000..75f75ed442f12ddc70ec5bc2d58ade4684afa914 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\256\267\346\231\250\346\227\255/FG.cs" @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class FG:Program + { + public static Random ran = new Random(); + public string[] arr = { "", "剪刀", "石头", "布" }; + public virtual void PlayFG() + { + + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\256\267\346\231\250\346\227\255/NPC.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\256\267\346\231\250\346\227\255/NPC.cs" new file mode 100644 index 0000000000000000000000000000000000000000..d1e76f0fd4bc69178b1408363ef8ec7cdb8f760a --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\256\267\346\231\250\346\227\255/NPC.cs" @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class NPC:FG + { + private string name; + public string Name + { + get { return this.name; } + set { this.name = value; } + } + public override void PlayFG() + { + Console.Write(this.name + ": 出拳:"); + } + public NPC() { } + public NPC(string name) + { + this.name = name; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\256\267\346\231\250\346\227\255/Player.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\256\267\346\231\250\346\227\255/Player.cs" new file mode 100644 index 0000000000000000000000000000000000000000..fbe3210a76d10b29276cdfcb8dd7f27c123bf78e --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\256\267\346\231\250\346\227\255/Player.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Player:FG + { + private string name; + public override void PlayFG() + { + + } + public string Name + { + get { return this.name; } + set { this.name = value; } + } + public Player(string name) + { + this.name = name; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\256\267\346\231\250\346\227\255/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\256\267\346\231\250\346\227\255/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..01a01ba941852b17076e7edd8af601ece4bb5d73 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\256\267\346\231\250\346\227\255/Program.cs" @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Program + { + public static void Main(string[] args) + { + Dictionary list = new Dictionary(); + Random ran = new Random(); + Console.WriteLine("----------欢 迎 进 入 游 戏 世 界----------"); + Console.WriteLine(); + Console.WriteLine("----------------猜 拳 开 始----------------"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + NPC n1 = new NPC("刘备"); + NPC n2 = new NPC("孙权"); + NPC n3 = new NPC("曹操"); + list.Add(1,n1); + list.Add(2,n2); + list.Add(3,n3); + Console.WriteLine("请选择对方角色:1.刘备 2.孙权 3.曹操"); + int a = int.Parse(Console.ReadLine()); + Console.WriteLine("请输入你的姓名:"); + Player p = new Player(Console.ReadLine()); + Console.WriteLine(p.Name + " VS " + list[a].Name); + Referee R = new Referee(); + R.begin(p.Name, list[a].Name) ; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\256\267\346\231\250\346\227\255/Referee.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\256\267\346\231\250\346\227\255/Referee.cs" new file mode 100644 index 0000000000000000000000000000000000000000..182572cc234abcb8e95151ce07ca33dc8ed6b1cb --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\256\267\346\231\250\346\227\255/Referee.cs" @@ -0,0 +1,185 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Referee:NPC + { + public static int nnum = 0; + public static int pnum = 0; + public static int num = 0; + public void begin(string pname , string nname) + { + Random ran = new Random(); + Console.WriteLine("开始游戏吗(y / n)"); + char b = char.Parse(Console.ReadLine()); + if (b == 'y') + { + while (true) + { + int r = ran.Next(1, 4); + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应的数字)"); + int a = int.Parse(Console.ReadLine()); + Console.WriteLine(pname + ":出拳:" + arr[a]); + NPC npc = new NPC(nname); + npc.PlayFG(); + Console.WriteLine(arr[r]); + if (arr[a] == "剪刀") + { + if (arr[r] == "剪刀") + { + Console.WriteLine("平局啦!嘿嘿,真晦气!"); + } + if (arr[r] == "石头") + { + Console.WriteLine(pname + "笨蛋,输啦"); + nnum++; + } + if (arr[r] == "布") + { + Console.WriteLine("恭喜" + pname + ",赢啦"); + pnum++; + } + num++; + Console.WriteLine("要继续游戏吗?(y / n)"); + char c2 = char.Parse(Console.ReadLine()); + if (c2 == 'y') + { + } + else if (c2 == 'n') + { + break; + } + } + if (arr[a] == "石头") + { + if (arr[r] == "剪刀") + { + Console.WriteLine("恭喜" + pname + ",赢啦"); + pnum++; + } + if (arr[r] == "石头") + { + Console.WriteLine("平局啦!嘿嘿,真晦气!"); + } + if (arr[r] == "布") + { + Console.WriteLine(pname + "笨蛋,输啦"); + nnum++; + } + num++; + Console.WriteLine("要继续游戏吗?(y / n)"); + char c2 = char.Parse(Console.ReadLine()); + if (c2 == 'y') + { + } + else if (c2 == 'n') + { + break; + } + } + if (arr[a] == "布") + { + if (arr[r] == "剪刀") + { + Console.WriteLine(pname + "笨蛋,输啦"); + nnum++; + } + if (arr[r] == "石头") + { + Console.WriteLine("恭喜" + pname + ",赢啦"); + pnum++; + } + if (arr[r] == "布") + { + Console.WriteLine("平局啦!嘿嘿,真晦气!"); + } + num++; + Console.WriteLine("要继续游戏吗?(y / n)"); + char c2 = char.Parse(Console.ReadLine()); + if (c2 == 'y') + { + } + else if (c2 == 'n') + { + break; + } + } + } + if (nnum > pnum) + { + Console.WriteLine("笨蛋"+pname+","+nname+"赢了"); + } + else if (pnum > nnum) + { + Console.WriteLine("恭喜"+pname+"赢了"); + } + else + { + Console.WriteLine("平局啦"); + } + Console.WriteLine("本轮结束,是否开始下一轮:(y / n)"); + char c1 = char.Parse(Console.ReadLine()); + if (c1 == 'y') + { + begin(pname, nname); + } + else if (c1 == 'n') + { + END(pname , nname); + } + else + { + Console.WriteLine("你的输入有误!"); + } + } + else if(b == 'n') + { + Console.WriteLine("已退出!"); + } + else + { + Console.WriteLine("您输入的有误!请重新输入!"); + begin(pname , nname); + } + } + public static void END(string pname , string nname) + { + Console.WriteLine("===================================="); + Console.WriteLine(pname + "VS" + nname); + Console.WriteLine("对战次数:"+num); + Console.WriteLine(); + Console.WriteLine("姓名\t得分"); + Console.WriteLine(pname + "\t" + pnum); + Console.WriteLine(nname + "\t" + nnum); + if (pnum>nnum) + { + Console.WriteLine(pname+"赢," +nname+"笨蛋"); + } + if (nnum>pnum) + { + Console.WriteLine(nname+"赢," +pname+"笨蛋"); + } + Console.WriteLine("要重新开始游戏吗?(y / n)"); + char c2 = char.Parse(Console.ReadLine()); + if (c2 == 'y') + { + num = 0; + pnum = 0; + nnum = 0; + Main(null); + } + else if(c2 == 'n') + { + Console.WriteLine("已退出!"); + } + else + { + Console.WriteLine("输入错误!默认退出!"); + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\275\230\346\231\266\345\251\267/.keep" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\275\230\346\231\266\345\251\267/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\275\230\346\231\266\345\251\267/Computer.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\275\230\346\231\266\345\251\267/Computer.cs" new file mode 100644 index 0000000000000000000000000000000000000000..f17330a8c0d3bb5137d1e710f4ad968e0707daef --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\275\230\346\231\266\345\251\267/Computer.cs" @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Computer : Father + { + public Computer() + { + } + + public Computer(string name) : base(name) + { + } + public override string chuquan() + { + Random r = new Random(); + int random = r.Next(1, 4); + switch (random) + { + case 1: + Console.WriteLine("剪刀"); + break; + case 2: + return "石头"; + break; + case 3: + return "布"; + break; + + } + return base.chuquan(); + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\275\230\346\231\266\345\251\267/Father.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\275\230\346\231\266\345\251\267/Father.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b78d2cfc39773d59373ad9f419b6fd938108bdd9 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\275\230\346\231\266\345\251\267/Father.cs" @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{//父类 共有1,名字 + class Father + { + public string Name { get; set; } + + public Father() { } + public Father(string name) + { + this.Name = name; + } + + public virtual string chuquan() + { + + return null; + } + + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\275\230\346\231\266\345\251\267/Game.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\275\230\346\231\266\345\251\267/Game.cs" new file mode 100644 index 0000000000000000000000000000000000000000..7a6dbb6c3feb2472e653e72867f2ff174f046636 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\275\230\346\231\266\345\251\267/Game.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Game + { + internal bool Gaming(Computer computer, Users u) + { + int sum = 0; int usum = 0; int csum = 0; + while (true) + { + string computerchuquan = computer.chuquan(); + string userschuquan = u.chuquan(); + Console.WriteLine($"{u.Name}: 出拳:{userschuquan}"); + Console.WriteLine($"{computer.Name}: 出拳:{computerchuquan}"); + + return true; + } + + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\275\230\346\231\266\345\251\267/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\275\230\346\231\266\345\251\267/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..bf34eac66212be0d2e49b22d1ea4e702c500bc1c --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\275\230\346\231\266\345\251\267/Program.cs" @@ -0,0 +1,67 @@ +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(); + Console.WriteLine("请选择对方角色:1:刘备 2:孙权 3:曹操"); + Computer computer = new Computer(); + string num = Console.ReadLine(); + switch (num) + { + case "1": + Console.WriteLine("刘备"); + computer=new Computer("刘备"); + break; + case "2": + Console.WriteLine("孙权"); + computer = new Computer("孙权"); + break; + case "3": + Console.WriteLine("曹操"); + computer = new Computer("曹操"); + break; + } + Users u = new Users(); + Console.WriteLine("请输入你的姓名:"); + u.Name = Console.ReadLine(); + + Console.WriteLine($"{u.Name} VS {computer.Name} 对战"); + Console.WriteLine(); + Console.WriteLine("开始游戏吗?(Y/N)"); + string xuanze = Console.ReadLine(); + switch (xuanze) + { + case "Y": + Game game = new Game(); + bool g = game.Gaming(computer,u); + + //返回gaming + break; + case "N": + return; + break; + } + + + + + + + Console.ReadKey(); + + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\275\230\346\231\266\345\251\267/Users.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\275\230\346\231\266\345\251\267/Users.cs" new file mode 100644 index 0000000000000000000000000000000000000000..2ace8926813ef7fb87a39d71b77019aadc871915 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\275\230\346\231\266\345\251\267/Users.cs" @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Users:Father + { + public Users() { } + public Users(string name):base (name) + { + + } + + public override string chuquan() + { + Console.WriteLine("请出拳:1,剪刀 2,石头 3,布(输入相应数字)"); + string num = Console.ReadLine(); + switch (num) + { + case "1": + return "剪刀"; + break; + case "2": + return "石头"; + break; + case "3": + return "布"; + break; + } + return base.chuquan(); + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\204\246\346\230\216\345\220\233/.keep" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\204\246\346\230\216\345\220\233/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\204\246\346\230\216\345\220\233/Computer.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\204\246\346\230\216\345\220\233/Computer.cs" new file mode 100644 index 0000000000000000000000000000000000000000..03ee43564e868a039c47b0a6f0f66b14979dba33 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\204\246\346\230\216\345\220\233/Computer.cs" @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace P1 +{ + class Computer + { + private string _name; + public string Name { get {return this._name; } set { this._name = value; } } + + public int Com() + { + Random random = new Random(); + int com = random.Next(1, 4); + switch (com) + { + case 1: + Console.WriteLine($"{this.Name}:出拳: 剪刀"); + break; + case 2: + Console.WriteLine($"{this.Name}:出拳: 石头"); + break; + case 3: + Console.WriteLine($"{this.Name}:出拳: 布"); + break; + } + return com; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\204\246\346\230\216\345\220\233/Person.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\204\246\346\230\216\345\220\233/Person.cs" new file mode 100644 index 0000000000000000000000000000000000000000..0997624d91fae0e38d606b333af2f9e241b06844 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\204\246\346\230\216\345\220\233/Person.cs" @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace P1 +{ + class Person + { + private string _name; + + public string Name { get {return this._name; } set {this._name=value; } } + + public int Per() + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布 (输入相应数字):"); + int per = int.Parse(Console.ReadLine()); + switch (per) + { + case 1: + Console.WriteLine($"{this.Name}:出拳: 剪刀"); + break; + case 2: + Console.WriteLine($"{this.Name}:出拳: 石头"); + break; + case 3: + Console.WriteLine($"{this.Name}:出拳: 布"); + break; + } + return per; + } + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\204\246\346\230\216\345\220\233/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\204\246\346\230\216\345\220\233/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..15c4433c9eb41617def1ca346eeffa26c096c867 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\204\246\346\230\216\345\220\233/Program.cs" @@ -0,0 +1,142 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace P1 +{ + class Program + { + static void Main(string[] args) + { + Person person = new Person(); + Computer computer = new Computer(); + int count = 0; + int score1 = 0; + int score2 = 0; + Console.WriteLine("----------欢迎进入游戏世界----------"); + Console.WriteLine("*************************************"); + Console.WriteLine("**************猜拳,开始*************"); + Console.WriteLine("*************************************"); + a: Console.WriteLine("出拳规则:1.剪刀2.石头3.布"); + Console.WriteLine("请选择对方角色<1:刘备2:孙权3:曹操>"); + int key = int.Parse(Console.ReadLine()); + if (key == 1) + { + computer.Name = "刘备"; + } + if (key == 2) + { + computer.Name = "孙权"; + } + if (key == 3) + { + computer.Name = "曹操"; + } + Console.WriteLine("请输入您的姓名:"); + person.Name = Console.ReadLine(); + Console.WriteLine($"{person.Name} vs {computer.Name}对战"); + Console.WriteLine("开始游戏吗?"); + string ks = Console.ReadLine(); + while (Xh(ks)) + { + if (ks == "y") + { + int per = person.Per(); + int com = computer.Com(); + + if (per == 1 && com == 1) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + else if (per == 1 && com == 2) + { + Console.WriteLine($"笨蛋,{person.Name}输了"); + score2++; + } + + else if (per == 1 && com == 3) + { + Console.WriteLine($"恭喜,{person.Name}赢了"); + score1++; + } + else if (per == 2 && com == 1) + { + Console.WriteLine($"恭喜,{person.Name}赢了"); + score1++; + } + else if (per == 2 && com == 2) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + else if (per == 2 && com == 3) + { + Console.WriteLine($"笨蛋,{person.Name}输了"); + score2++; + } + else if (per == 3 && com == 1) + { + Console.WriteLine($"笨蛋,{person.Name}输了"); + score2++; + } + else if (per == 3 && com == 2) + { + Console.WriteLine($"恭喜,{person.Name}赢了"); + score1++; + } + else if (per == 3 && com == 3) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + Console.WriteLine("是否开始下一轮?"); + ks = Console.ReadLine(); + Xh(ks); + count++; + if (ks=="n") + { + Console.WriteLine("*************************************"); + Console.WriteLine($"{computer.Name} vs {person.Name}对战"); + Console.WriteLine($"对战次数: {count}"); + Console.WriteLine(); + Console.WriteLine("姓名"+"\t"+"得分"); + Console.WriteLine($"{person.Name}\t{score1}"); + Console.WriteLine($"{computer.Name}\t{score2}"); + if (score1>score2) + { + Console.WriteLine($"结果:{person.Name}赢,{computer.Name}笨蛋"); + } + else if (score1 < score2) + { + Console.WriteLine($"结果:{computer.Name}赢,{person.Name}笨蛋"); + } + else if (score1 == score2) + { + Console.WriteLine($"恭喜你们!{computer.Name}和{person.Name}平局!"); + } + Console.WriteLine("要开始下一局吗?"); + string sf = Console.ReadLine(); + switch (sf) { + case "y": + goto a; + case "n": + Console.WriteLine("系统退出!!!!!"); + break; + } + } + } + } + } + + private static bool Xh(string ks) + { + bool b; + if (ks == "y") + { b = true; } + else { b = false; } + return b; + } + } +} + + diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\216\213\345\206\240\346\235\260/.keep" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\216\213\345\206\240\346\235\260/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\216\213\345\206\240\346\235\260/Duisho.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\216\213\345\206\240\346\235\260/Duisho.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b315f7b9b6d190864c894db6c46e5cd3b4e322c2 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\216\213\345\206\240\346\235\260/Duisho.cs" @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Duisho + { + private string name; + + public string Name { get => name; set => name = value; } + public void Mingzi() + { + Console.WriteLine("请选择对方角色《1.刘备;2.孙权;3.曹操》"); + int a = int.Parse(Console.ReadLine()); + if (a==1) + { + name = "刘备"; + } + if (a==2) + { + name = "孙权"; + } + if (a==3) + { + name = "曹操"; + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\216\213\345\206\240\346\235\260/PK.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\216\213\345\206\240\346\235\260/PK.cs" new file mode 100644 index 0000000000000000000000000000000000000000..da2cfac620c0e8ac25d67f378ced355e5899de0e --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\216\213\345\206\240\346\235\260/PK.cs" @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class PK + { + private string wchu;//玩家出拳 + private string dchu;//对手出拳 + int c; + int z; + int ying=0; + int shu=0; + + public string Dchu { get => dchu; set => dchu = value; } + public string Wchu { get => wchu; set => wchu = value; } + public int Ying { get => ying; set => ying = value; } + public int Shu { get => shu; set => shu = value; } + + public void Wjuedou() + { + Console.WriteLine("请出拳:1.剪刀;2.石头;3.布《请输入相应数字》"); + c = int.Parse(Console.ReadLine()); + switch (c) + { + case 1: + wchu = "剪刀"; + break; + case 2: + wchu = "石头"; + break; + case 3: + wchu = "布"; + break; + } + } + public void Djuedou() + { + Random ran = new Random(); + z=ran.Next(1,4); + switch (z) + { + case 1: + dchu= "剪刀"; + break; + case 2: + dchu = "石头"; + break; + case 3: + dchu = "布"; + break; + } + } + public void panding() + { + if ( c== 1 && z == 1 || c == 2 && z == 2 || c == 3 && z == 3) + { Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); } + else if (c == 1 && z == 3 || c == 2 && z == 1 || c == 3 && z == 2) + { + Console.WriteLine("恭喜你呐,赢啦"); + Ying++; + } + else if (c == 1 && z == 2 || c == 2 && z == 3 || c == 3 && z == 1) + { + Console.WriteLine("笨蛋,输啦"); + Shu++; + } + else + { + Console.WriteLine("输错了,重新输入"); + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\216\213\345\206\240\346\235\260/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\216\213\345\206\240\346\235\260/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..3a1b3b939199045db360db2a6d40b113a6f82603 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\216\213\345\206\240\346\235\260/Program.cs" @@ -0,0 +1,96 @@ +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) + { + Duisho d = new Duisho();//对手 + Wanjia w = new Wanjia();//玩家 + PK p = new PK();//PK + Console.WriteLine("----------欢迎进入游戏世界----------"); + Console.WriteLine("----------猜拳 开始----------"); + Console.WriteLine("出拳规则:1.剪刀,2.石头,3.布"); + while (true) + { + d.Mingzi(); + w.Mingzi(); + Console.WriteLine("{0} vs {1}", w.Name, d.Name); + Console.WriteLine("开始游戏吗?《y/n》"); + string b = Console.ReadLine(); + bool F = true; + switch (b) + { + case "y": + p.Wjuedou(); + p.Djuedou(); + Console.WriteLine("{0}:出拳:{1}", w.Name, p.Wchu); + Console.WriteLine("{0}:出拳:{1}", d.Name, p.Dchu); + p.panding(); + while (F) + { + int index = 0; + index++; + Console.WriteLine("是否开始下一轮?《y/n》"); + string e = Console.ReadLine(); + switch (e) + { + case "y": + p.Wjuedou(); + p.Djuedou(); + Console.WriteLine("{0}:出拳:{1}", w.Name, p.Wchu); + Console.WriteLine("{0}:出拳:{1}", d.Name, p.Dchu); + p.panding(); + break; + case "n": + Console.WriteLine("-------------------------"); + Console.WriteLine("{0} vs {1}", w.Name, d.Name); + Console.WriteLine("对战次数{0}", index); + Console.WriteLine("姓名\t得分"); + Console.WriteLine("{0}\t{1}", w.Name, p.Ying); + Console.WriteLine("{0}\t{1}", d.Name, p.Shu); + if (p.Ying > p.Shu) + { + Console.WriteLine("结果:{0}赢了,{1}笨蛋", w.Name, d.Name); + } + else if (p.Ying == p.Shu) + { + Console.WriteLine("结果:{0}与{1}和局", w.Name, d.Name); + } + else if (p.Ying < p.Shu) + { + Console.WriteLine("结果:{0}赢了,{1}笨蛋", d.Name, w.Name); + } + F = false; + break; + } + } + + + break; + case "n": + Console.WriteLine("程序结束"); + break; + } + Console.WriteLine("要开始下一局? Y/N"); + string t = Console.ReadLine(); + if (t=="y") + { + continue; + } + else if(t=="n") + { + Console.WriteLine("程序结束"); + break; + } + } + Console.ReadKey(); + + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\216\213\345\206\240\346\235\260/Wanjia.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\216\213\345\206\240\346\235\260/Wanjia.cs" new file mode 100644 index 0000000000000000000000000000000000000000..bf3343717e2406fdf289f8e975eff75f90e17ce8 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\216\213\345\206\240\346\235\260/Wanjia.cs" @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Wanjia + { + private string name; + + public string Name { get => name; set => name = value; } + public void Mingzi() + { + Console.WriteLine("请输入你的名字"); + name = Console.ReadLine(); + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\216\213\350\277\234\346\226\271/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\216\213\350\277\234\346\226\271/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..8618e39f7092a5fd81eb09285dd6cdd9a3b7081c --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\216\213\350\277\234\346\226\271/Program.cs" @@ -0,0 +1,197 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace lazy +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("----------------欢迎进入游戏世界----------------"); + Console.WriteLine("*******************************"); + Console.WriteLine("********心里博弈之猜拳*********"); + Console.WriteLine("*******************************"); + Console.WriteLine("游戏规则:1、剪刀 2、石头 3、布"); + NPC d = new NPC(); + Player w = new Player(); + Mora m = new Mora(); + while (true) + { + bool Q = true; + d.NPCname(); + w.Playername(); + Console.WriteLine("{0} vs {1}",w.Name,d.Name); + Console.WriteLine("要开始对局吗?(y/n)"); + string yn = Console.ReadLine(); + switch (yn) + { + case "y": + m.morap(); + m.moran(); + Console.WriteLine("{0}: 出招:{1}",w.Name,m.PlayerMora); + Console.WriteLine("{0}: 出招:{1}",d.Name,m.NPCMora); + m.Theending(); + while (Q) + { + int record = 0; + record++; + Console.WriteLine("是否开始下一轮?(y/n)"); + string q = Console.ReadLine(); + switch (q) + { + case "y": + m.morap(); + m.moran(); + Console.WriteLine("{0}: 出招:{1}", w.Name, m.PlayerMora); + Console.WriteLine("{0}: 出招:{1}", d.Name, m.NPCMora); + m.Theending(); + break; + case "n": + Console.WriteLine("====================================="); + Console.WriteLine("{0} vs {1}",w.Name,d.Name); + Console.WriteLine("对战次数:" + record); + Console.WriteLine("姓名\t得分 "); + Console.WriteLine("{0}\t{1}",w.Name,m.Win1); + Console.WriteLine("{0}\t{1}",d.Name,m.Defeat1); + if (m.Win1>m.Defeat1) + { + Console.WriteLine("结果:{0}赢,{1}不行不行",w.Name,d.Name); + } + else if (m.Win1 name; set => name = value; } + public void NPCname() + { + Console.WriteLine("请选择对方角色:1、刘备2、孙权 3、曹操"); + int enemy = int.Parse(Console.ReadLine()); + switch (enemy) + { + case 1: + Name = "刘备"; + break; + case 2: + Name = "孙权"; + break; + case 3: + Name = "曹操"; + break; + + } + Console.WriteLine("我是{0}不斩无名之辈。阁下,告诉我你的名字:", Name); + } + } + class Player + { + public string name; + + public string Name { get => name; set => name = value; } + public void Playername() + { + Name =Console.ReadLine(); + } + } + class Mora + { + private string playerMora; + private string nPCMora; + private int Win = 0; + private int Defeat = 0; + private int a; + private int b; + + public string PlayerMora { get => playerMora; set => playerMora = value; } + public string NPCMora { get => nPCMora; set => nPCMora = value; } + public int A { get => a; set => a = value; } + public int B { get => b; set => b = value; } + public int Win1 { get => Win; set => Win = value; } + public int Defeat1 { get => Defeat; set => Defeat = value; } + + public void morap() + { + Console.WriteLine("请选择你的招式:1、剪刀 2、石头 3、布 <输入数字即可>"); + A = int.Parse(Console.ReadLine()); + switch (A) + { + case 1: + PlayerMora = "剪刀"; + break; + case 2: + PlayerMora = "石头"; + break; + case 3: + PlayerMora = "布"; + break; + } + } + public void moran() + { + Random random = new Random(); + B = random.Next(1, 4); + switch (B) + { + case 1: + NPCMora = "剪刀"; + break; + case 2: + NPCMora = "石头"; + break; + case 3: + NPCMora = "布"; + break; + } + } + public void Theending() + { + if (A==B) + { + Console.WriteLine("和局?你真不行。"); + } + else if (A==1 && B==3 || A==2 && B==1 || A==3 && B==2) + { + Console.WriteLine("不错,你赢了。"); + Win1++; + } + else if(B == 1 && A == 3 || B == 2 && A == 1 || B == 3 && A == 2) + { + Console.WriteLine("输的真惨!!!"); + Defeat1++; + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\250\213\346\226\207\345\220\233/Computer.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\250\213\346\226\207\345\220\233/Computer.cs" new file mode 100644 index 0000000000000000000000000000000000000000..03ee43564e868a039c47b0a6f0f66b14979dba33 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\250\213\346\226\207\345\220\233/Computer.cs" @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace P1 +{ + class Computer + { + private string _name; + public string Name { get {return this._name; } set { this._name = value; } } + + public int Com() + { + Random random = new Random(); + int com = random.Next(1, 4); + switch (com) + { + case 1: + Console.WriteLine($"{this.Name}:出拳: 剪刀"); + break; + case 2: + Console.WriteLine($"{this.Name}:出拳: 石头"); + break; + case 3: + Console.WriteLine($"{this.Name}:出拳: 布"); + break; + } + return com; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\250\213\346\226\207\345\220\233/Person.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\250\213\346\226\207\345\220\233/Person.cs" new file mode 100644 index 0000000000000000000000000000000000000000..0997624d91fae0e38d606b333af2f9e241b06844 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\250\213\346\226\207\345\220\233/Person.cs" @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace P1 +{ + class Person + { + private string _name; + + public string Name { get {return this._name; } set {this._name=value; } } + + public int Per() + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布 (输入相应数字):"); + int per = int.Parse(Console.ReadLine()); + switch (per) + { + case 1: + Console.WriteLine($"{this.Name}:出拳: 剪刀"); + break; + case 2: + Console.WriteLine($"{this.Name}:出拳: 石头"); + break; + case 3: + Console.WriteLine($"{this.Name}:出拳: 布"); + break; + } + return per; + } + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\250\213\346\226\207\345\220\233/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\250\213\346\226\207\345\220\233/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..15c4433c9eb41617def1ca346eeffa26c096c867 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\250\213\346\226\207\345\220\233/Program.cs" @@ -0,0 +1,142 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace P1 +{ + class Program + { + static void Main(string[] args) + { + Person person = new Person(); + Computer computer = new Computer(); + int count = 0; + int score1 = 0; + int score2 = 0; + Console.WriteLine("----------欢迎进入游戏世界----------"); + Console.WriteLine("*************************************"); + Console.WriteLine("**************猜拳,开始*************"); + Console.WriteLine("*************************************"); + a: Console.WriteLine("出拳规则:1.剪刀2.石头3.布"); + Console.WriteLine("请选择对方角色<1:刘备2:孙权3:曹操>"); + int key = int.Parse(Console.ReadLine()); + if (key == 1) + { + computer.Name = "刘备"; + } + if (key == 2) + { + computer.Name = "孙权"; + } + if (key == 3) + { + computer.Name = "曹操"; + } + Console.WriteLine("请输入您的姓名:"); + person.Name = Console.ReadLine(); + Console.WriteLine($"{person.Name} vs {computer.Name}对战"); + Console.WriteLine("开始游戏吗?"); + string ks = Console.ReadLine(); + while (Xh(ks)) + { + if (ks == "y") + { + int per = person.Per(); + int com = computer.Com(); + + if (per == 1 && com == 1) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + else if (per == 1 && com == 2) + { + Console.WriteLine($"笨蛋,{person.Name}输了"); + score2++; + } + + else if (per == 1 && com == 3) + { + Console.WriteLine($"恭喜,{person.Name}赢了"); + score1++; + } + else if (per == 2 && com == 1) + { + Console.WriteLine($"恭喜,{person.Name}赢了"); + score1++; + } + else if (per == 2 && com == 2) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + else if (per == 2 && com == 3) + { + Console.WriteLine($"笨蛋,{person.Name}输了"); + score2++; + } + else if (per == 3 && com == 1) + { + Console.WriteLine($"笨蛋,{person.Name}输了"); + score2++; + } + else if (per == 3 && com == 2) + { + Console.WriteLine($"恭喜,{person.Name}赢了"); + score1++; + } + else if (per == 3 && com == 3) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + Console.WriteLine("是否开始下一轮?"); + ks = Console.ReadLine(); + Xh(ks); + count++; + if (ks=="n") + { + Console.WriteLine("*************************************"); + Console.WriteLine($"{computer.Name} vs {person.Name}对战"); + Console.WriteLine($"对战次数: {count}"); + Console.WriteLine(); + Console.WriteLine("姓名"+"\t"+"得分"); + Console.WriteLine($"{person.Name}\t{score1}"); + Console.WriteLine($"{computer.Name}\t{score2}"); + if (score1>score2) + { + Console.WriteLine($"结果:{person.Name}赢,{computer.Name}笨蛋"); + } + else if (score1 < score2) + { + Console.WriteLine($"结果:{computer.Name}赢,{person.Name}笨蛋"); + } + else if (score1 == score2) + { + Console.WriteLine($"恭喜你们!{computer.Name}和{person.Name}平局!"); + } + Console.WriteLine("要开始下一局吗?"); + string sf = Console.ReadLine(); + switch (sf) { + case "y": + goto a; + case "n": + Console.WriteLine("系统退出!!!!!"); + break; + } + } + } + } + } + + private static bool Xh(string ks) + { + bool b; + if (ks == "y") + { b = true; } + else { b = false; } + return b; + } + } +} + + diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\273\203\346\226\207\346\265\251/.keep" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\273\203\346\226\207\346\265\251/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\273\203\346\226\207\346\265\251/Game.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\273\203\346\226\207\346\265\251/Game.cs" new file mode 100644 index 0000000000000000000000000000000000000000..d0fad88a18fb38e3cd6244ac5b29bacef9af39b0 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\273\203\346\226\207\346\265\251/Game.cs" @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Game + { + private object userName; + private object wayName; + + public bool Gaming(Way way, User user) + { + int sum = 0; + int lNum = 0; + int nNum = 0; + while (true) + { + string wayAction; + string userAction; + userAction = user.Action(); + Console.WriteLine(user.Name + " :出拳: " + userAction); + wayAction = way.Action(); + Console.WriteLine(way.Name + " :出拳: " + wayAction); + IsWin(wayAction, userAction, user.Name, ref nNum); + + //Console.WriteLine(IsWin(wayAction, userAction, user.Name, ref lNum, ref nNum)); + + sum++; + while (true) + { + Console.WriteLine("是否开始下一轮?(1.继续 / 2.停止)"); + string a = Console.ReadLine(); + if (a == "1") + { + break; + } + else if (a == "2") + { + return EndGame(way.Name, user.Name, sum, lNum, nNum); + } + else + { + Console.WriteLine("输入错误,请重新输入!"); + continue; + } + } + } + } + + private void IsWin(string wayAction, string userAction, string name, ref int nNum) + { + throw new NotImplementedException(); + } + + private bool EndGame(string name1, string name2, int sum, int lNum, int nNum) + { + Console.WriteLine("========================="); + Console.WriteLine("对战次数:" + sum); + + Console.WriteLine("姓名 \t 得分"); + Console.WriteLine(userName + "\t" + nNum); + Console.WriteLine(wayName + "\t" + lNum); + if (lNum > nNum) + { + Console.WriteLine($"{userName}赢了,{wayName}输了"); + } + else + { + Console.WriteLine("平局"); + } + while (true) + { + Console.WriteLine("要开始下一局吗?(y/n)"); + string a = Console.ReadLine(); + switch (a) + { + case "y": + return true; + case "n": + return false; + default: + Console.WriteLine("选择错误,请重新输入!"); + continue; + } + } + } + + public void IsWin(string wayAction, string userAction, string name, ref int lNum, ref int nNum) + { + string str; + if ((wayAction == "剪刀" && userAction == "布") || (wayAction == "石头" && userAction == "剪刀") || wayAction == "布" && userAction == "石头") + { + lNum++; + Console.WriteLine($"笨蛋,{name}输了"); + } + else if (wayAction == userAction) + { + Console.WriteLine($"和局,太可惜了!"); + } + else + { + nNum++; + Console.WriteLine($"恭喜,{name}赢了!"); + } + + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\273\203\346\226\207\346\265\251/Person.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\273\203\346\226\207\346\265\251/Person.cs" new file mode 100644 index 0000000000000000000000000000000000000000..ef4bc6ae5e446beb47c134ac51581ad526c81c53 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\273\203\346\226\207\346\265\251/Person.cs" @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Person + { + public string Name { get; set; } + public Person() + { + + } + public Person(string name) + { + Name = name; + } + public virtual string Action() + { + return null; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\273\203\346\226\207\346\265\251/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\273\203\346\226\207\346\265\251/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..8b85581e3b7e9eef5d9df16267ff0921bebc7dae --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\273\203\346\226\207\346\265\251/Program.cs" @@ -0,0 +1,88 @@ +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("-----------------欢迎进入游戏世界!-----------------"); + while (true) + { + Console.WriteLine("**********************"); + Console.WriteLine("********猜拳,开始******"); + Console.WriteLine("**********************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Way way = WayCreate(); + User user = UserCreate(); + bool IsStart = Start(); + if (!IsStart) + { + Console.WriteLine("系统退出!"); + return; + } + else + { + Console.WriteLine(way.Name + " VS " + user.Name + " 对战 "); + } + Game game = new Game(); + bool IsCountine = game.Gaming(way, user); + if (!IsCountine) + { + Console.WriteLine("系统退出!"); + return; + } + } + } + public static bool Start() + { + while (true) + { + Console.WriteLine("开始游戏吗?(y/n)"); + string a = Console.ReadLine(); + switch (a) + { + case "y": + return true; + case "n": + return false; + default: + Console.WriteLine("选择错误,请重新输入!"); + continue; + } + } + } + private static Way WayCreate() + { + while (true) + { + Console.WriteLine("请选择对方角色<1.刘备 2.孙权 3.曹操"); + Console.Write("请选择:"); + string a = Console.ReadLine(); + switch (a) + { + case "1": + return new Way("刘备"); + case "2": + return new Way("孙权"); + case "3": + return new Way("曹操"); + default: + Console.WriteLine("选择错误,请重新输入!"); + continue; + } + } + } + + private static User UserCreate() + { + Console.WriteLine("请输入您的姓名"); + string userName = Console.ReadLine(); + return new User(userName); + } + } + } diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\273\203\346\226\207\346\265\251/User.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\273\203\346\226\207\346\265\251/User.cs" new file mode 100644 index 0000000000000000000000000000000000000000..7359bb6e39abec2a63dfae21ddd386d3da60944f --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\273\203\346\226\207\346\265\251/User.cs" @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class User:Person + { + public User() + { + + } + public User(string name) : base(name) + { + + } + + public string Name { get; internal set; } + + public override string Action() + { + while (true) + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布 (请输入相应的数字:)"); + string a = Console.ReadLine(); + switch (a) + { + case "1": + return " 剪刀"; + case "2": + return " 石头"; + case "3": + return " 布"; + default: + Console.WriteLine("选择错误,请重新输入!"); + continue; + } + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\273\203\346\226\207\346\265\251/Way.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\273\203\346\226\207\346\265\251/Way.cs" new file mode 100644 index 0000000000000000000000000000000000000000..06fa27635116cbfae7c849c79b79256a0824d3d0 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\273\203\346\226\207\346\265\251/Way.cs" @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Way:Person + { + public Way() + { + + } + public Way(string name) : base(name) + { + + } + public override string Action() + { + Random random = new Random(); + int num = random.Next(1, 4); + switch (num) + { + case 1: + return "剪刀"; + case 2: + return "石头"; + case 3: + return "布"; + } + return ""; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\277\201\346\231\266\350\276\211/.keep" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\277\201\346\231\266\350\276\211/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\277\201\346\231\266\350\276\211/Duisho.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\277\201\346\231\266\350\276\211/Duisho.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b315f7b9b6d190864c894db6c46e5cd3b4e322c2 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\277\201\346\231\266\350\276\211/Duisho.cs" @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Duisho + { + private string name; + + public string Name { get => name; set => name = value; } + public void Mingzi() + { + Console.WriteLine("请选择对方角色《1.刘备;2.孙权;3.曹操》"); + int a = int.Parse(Console.ReadLine()); + if (a==1) + { + name = "刘备"; + } + if (a==2) + { + name = "孙权"; + } + if (a==3) + { + name = "曹操"; + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\277\201\346\231\266\350\276\211/PK.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\277\201\346\231\266\350\276\211/PK.cs" new file mode 100644 index 0000000000000000000000000000000000000000..da2cfac620c0e8ac25d67f378ced355e5899de0e --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\277\201\346\231\266\350\276\211/PK.cs" @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class PK + { + private string wchu;//玩家出拳 + private string dchu;//对手出拳 + int c; + int z; + int ying=0; + int shu=0; + + public string Dchu { get => dchu; set => dchu = value; } + public string Wchu { get => wchu; set => wchu = value; } + public int Ying { get => ying; set => ying = value; } + public int Shu { get => shu; set => shu = value; } + + public void Wjuedou() + { + Console.WriteLine("请出拳:1.剪刀;2.石头;3.布《请输入相应数字》"); + c = int.Parse(Console.ReadLine()); + switch (c) + { + case 1: + wchu = "剪刀"; + break; + case 2: + wchu = "石头"; + break; + case 3: + wchu = "布"; + break; + } + } + public void Djuedou() + { + Random ran = new Random(); + z=ran.Next(1,4); + switch (z) + { + case 1: + dchu= "剪刀"; + break; + case 2: + dchu = "石头"; + break; + case 3: + dchu = "布"; + break; + } + } + public void panding() + { + if ( c== 1 && z == 1 || c == 2 && z == 2 || c == 3 && z == 3) + { Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); } + else if (c == 1 && z == 3 || c == 2 && z == 1 || c == 3 && z == 2) + { + Console.WriteLine("恭喜你呐,赢啦"); + Ying++; + } + else if (c == 1 && z == 2 || c == 2 && z == 3 || c == 3 && z == 1) + { + Console.WriteLine("笨蛋,输啦"); + Shu++; + } + else + { + Console.WriteLine("输错了,重新输入"); + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\277\201\346\231\266\350\276\211/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\277\201\346\231\266\350\276\211/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..3a1b3b939199045db360db2a6d40b113a6f82603 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\277\201\346\231\266\350\276\211/Program.cs" @@ -0,0 +1,96 @@ +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) + { + Duisho d = new Duisho();//对手 + Wanjia w = new Wanjia();//玩家 + PK p = new PK();//PK + Console.WriteLine("----------欢迎进入游戏世界----------"); + Console.WriteLine("----------猜拳 开始----------"); + Console.WriteLine("出拳规则:1.剪刀,2.石头,3.布"); + while (true) + { + d.Mingzi(); + w.Mingzi(); + Console.WriteLine("{0} vs {1}", w.Name, d.Name); + Console.WriteLine("开始游戏吗?《y/n》"); + string b = Console.ReadLine(); + bool F = true; + switch (b) + { + case "y": + p.Wjuedou(); + p.Djuedou(); + Console.WriteLine("{0}:出拳:{1}", w.Name, p.Wchu); + Console.WriteLine("{0}:出拳:{1}", d.Name, p.Dchu); + p.panding(); + while (F) + { + int index = 0; + index++; + Console.WriteLine("是否开始下一轮?《y/n》"); + string e = Console.ReadLine(); + switch (e) + { + case "y": + p.Wjuedou(); + p.Djuedou(); + Console.WriteLine("{0}:出拳:{1}", w.Name, p.Wchu); + Console.WriteLine("{0}:出拳:{1}", d.Name, p.Dchu); + p.panding(); + break; + case "n": + Console.WriteLine("-------------------------"); + Console.WriteLine("{0} vs {1}", w.Name, d.Name); + Console.WriteLine("对战次数{0}", index); + Console.WriteLine("姓名\t得分"); + Console.WriteLine("{0}\t{1}", w.Name, p.Ying); + Console.WriteLine("{0}\t{1}", d.Name, p.Shu); + if (p.Ying > p.Shu) + { + Console.WriteLine("结果:{0}赢了,{1}笨蛋", w.Name, d.Name); + } + else if (p.Ying == p.Shu) + { + Console.WriteLine("结果:{0}与{1}和局", w.Name, d.Name); + } + else if (p.Ying < p.Shu) + { + Console.WriteLine("结果:{0}赢了,{1}笨蛋", d.Name, w.Name); + } + F = false; + break; + } + } + + + break; + case "n": + Console.WriteLine("程序结束"); + break; + } + Console.WriteLine("要开始下一局? Y/N"); + string t = Console.ReadLine(); + if (t=="y") + { + continue; + } + else if(t=="n") + { + Console.WriteLine("程序结束"); + break; + } + } + Console.ReadKey(); + + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\277\201\346\231\266\350\276\211/Wanjia.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\277\201\346\231\266\350\276\211/Wanjia.cs" new file mode 100644 index 0000000000000000000000000000000000000000..bf3343717e2406fdf289f8e975eff75f90e17ce8 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\347\277\201\346\231\266\350\276\211/Wanjia.cs" @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Wanjia + { + private string name; + + public string Name { get => name; set => name = value; } + public void Mingzi() + { + Console.WriteLine("请输入你的名字"); + name = Console.ReadLine(); + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\202\226\346\265\267\346\231\237/.keep" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\202\226\346\265\267\346\231\237/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\202\226\346\265\267\346\231\237/Game.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\202\226\346\265\267\346\231\237/Game.cs" new file mode 100644 index 0000000000000000000000000000000000000000..8a35c7ad021fb074410fdfba6deb19219b1442b9 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\202\226\346\265\267\346\231\237/Game.cs" @@ -0,0 +1,112 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp4 +{ + class Game + { + + public bool Gaming(Player player, System NPC) + { + int sum = 0; + int num = 0; + int nun = 0; + while (true) + { + string playerName; + playerName = player.Hello(); + Console.WriteLine(player.Name + " 出拳 " + playerName); + string NPCName; + NPCName = NPC.Hello(); + Console.WriteLine(NPC.Name + " 出拳 " + NPCName); + Console.WriteLine(Judge(playerName, NPCName, player.Name, ref num, ref nun)); + + sum++; + while (true) + { + Console.WriteLine("是否开始下一轮?"); + string nextround = Console.ReadLine(); + if (nextround == "y") + { + break; + } + else + { + return EndGame(player.Name, NPC.Name, sum, num, nun); + } + } + } + } + private bool EndGame(string PlayerName, string NPCName, int sum, int hNum, int uNum) + { + Console.WriteLine("==================================="); + Console.WriteLine("对战次数:" + sum); + + Console.WriteLine("姓名\t得分"); + Console.WriteLine(PlayerName + "\t" + hNum); + Console.WriteLine(NPCName + "\t" + uNum); + if (hNum > uNum) + { + Console.WriteLine($"{PlayerName}赢了,{NPCName}输了"); + } + else if (hNum < uNum) + { + Console.WriteLine($"{PlayerName}赢了,{NPCName}输了"); + } + else + { + Console.WriteLine("平局"); + } + while (true) + { + Console.WriteLine("要开始下一局吗?(y/n)"); + string nextround = Console.ReadLine(); + switch (nextround) + { + case "y": + return true; + case "n": + return false; + default: + Console.WriteLine("选择错误,请重新输入"); + continue; + } + } + } + public string Judge(string A, string B, string name, ref int num, ref int nun) + { + string str; + if ((A == "剪刀" && B == "布") || (A == "石头" && B == "剪刀") || A == "布" && B == "石头") + { + num++; + str = "赢"; + } + else if (A == B) + { + + str = "平局"; + } + else + { + nun++; + str = "输"; + } + if (str == "赢") + { + return $"笨蛋,{name}输了"; + + } + else if (str == "输") + { + return $"恭喜,{name}赢了"; + } + else + { + return "平局,真衰!嘿嘿,等着瞧吧!"; + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\202\226\346\265\267\346\231\237/Person.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\202\226\346\265\267\346\231\237/Person.cs" new file mode 100644 index 0000000000000000000000000000000000000000..045ba7c046269d9c60e3d75ba8da516d8504b21d --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\202\226\346\265\267\346\231\237/Person.cs" @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp4 +{ + class Person + { + private string name; + public string Name + { + get { return this.name; } + set { this.name = value; } + } + public Person() + { + + } + public Person(string name) + { + Name = name; + } + public virtual string Hello() + { + return null; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\202\226\346\265\267\346\231\237/Player.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\202\226\346\265\267\346\231\237/Player.cs" new file mode 100644 index 0000000000000000000000000000000000000000..4556711205ec187fcae8e054a8425032d2f43224 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\202\226\346\265\267\346\231\237/Player.cs" @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp4 +{ + class Player:Person + { + public Player() + { + + } + public Player(string name):base(name) + { + + } + public override string Hello() + { + while (true) + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应的数字:)"); + int Fingerguessing = int.Parse(Console.ReadLine()); + switch (Fingerguessing) + { + case 1: + return "剪刀"; + case 2: + return "石头"; + case 3: + return "布"; + default: + break; + } + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\202\226\346\265\267\346\231\237/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\202\226\346\265\267\346\231\237/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..8c5174523b4024e2b533912dc313f7877de78f38 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\202\226\346\265\267\346\231\237/Program.cs" @@ -0,0 +1,85 @@ + +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("出拳规则:1.剪刀 2.石头 3.布"); + Player player = UserName(); + System NPC = Begin(); + bool choose = Choose(); + if (!choose) + { + Console.WriteLine("退出"); + return; + } + else + { + Console.WriteLine(player.Name + " VS " + NPC.Name + " 对战"); + } + Game g = new Game(); + bool result = g.Gaming(player, NPC); + if (!result) + { + Console.WriteLine("退出程序"); + return; + } + Console.ReadKey(); + } + public static bool Choose() + { + while (true) + { + Console.WriteLine("开始游戏吗?"); + string choose = Console.ReadLine(); + switch (choose) + { + case "y": + return true; + case "n": + return false; + default: + continue; + } + } + + } + public static Player UserName() + { + Console.WriteLine("请输入您的姓名:"); + string username = Console.ReadLine(); + return new Player(username); + } + public static System Begin() + { + while (true) + { + Console.WriteLine("请选择对方角色<1.刘备 2.孙权 3.曹操>"); + int NPC = int.Parse(Console.ReadLine()); + switch (NPC) + { + case 1: + return new System("刘备"); + case 2: + return new System("孙权"); + case 3: + return new System("曹操"); + default: + Console.WriteLine("请按上述数字所表示内容输入"); + continue; + } + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\202\226\346\265\267\346\231\237/System.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\202\226\346\265\267\346\231\237/System.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b0f23e9ae7e7531b1d6033d3e926c70d2f375eb4 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\202\226\346\265\267\346\231\237/System.cs" @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp4 +{ + class System:Person + { + public System() + { + + } + public System(string name ):base(name) + { + + } + public override string Hello() + { + Random random = new Random(); + int punch = random.Next(1,4); + switch (punch) + { + case 1: + return "剪刀"; + case 2: + return "石头"; + case 3: + return "布"; + default: + break; + } + return ""; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\203\241\346\264\245\345\215\216/GameSystem.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\203\241\346\264\245\345\215\216/GameSystem.cs" new file mode 100644 index 0000000000000000000000000000000000000000..f4a821a5d98f79874b2ce8b14b7645c08ca0e39a --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\203\241\346\264\245\345\215\216/GameSystem.cs" @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo01 +{ + class GameSystem + { + public bool Gaming(Hero hero, Users users) + { + int sum = 0; + int hNum = 0; + int uNum = 0; + while (true) + { + string heroAction; + string userAction; + userAction = users.Action(); + Console.WriteLine(users.Name + ": 出拳: " + userAction); + heroAction = hero.Action(); + Console.WriteLine(hero.Name + ": 出拳: " + heroAction); + Console.WriteLine(IsWin(heroAction, userAction, users.Name, ref hNum, ref uNum)); + sum++; + while (true) + { + Console.WriteLine("是否开始下一轮?(1.继续/0.停止)"); + string chioce = Console.ReadLine(); + if (chioce == "1") + { + break; + } + else if (chioce == "0") + { + return EndGame(hero.Name, users.Name, sum, hNum, uNum); + } + else + { + Console.WriteLine("输入错误,请重新输入"); + continue; + } + } + } + } + + private bool EndGame(string heroName, string userName, int sum, int hNum, int uNum) + { + Console.WriteLine("==================================="); + Console.WriteLine("对战次数:" + sum); + + Console.WriteLine("姓名\t得分"); + Console.WriteLine(heroName + "\t" + hNum); + Console.WriteLine(userName + "\t" + uNum); + if (hNum > uNum) + { + Console.WriteLine($"{heroName}赢了,{userName}输了"); + } + else if (hNum < uNum) + { + Console.WriteLine($"{userName}赢了,{heroName}输了"); + } + else + { + Console.WriteLine("平局"); + } + while (true) + { + Console.WriteLine("要开始下一局吗?(y/n)"); + string chioce = Console.ReadLine(); + switch (chioce) + { + case "y": + return true; + case "n": + return false; + default: + Console.WriteLine("选择错误,请重新输入"); + continue; + } + } + } + + public string IsWin(string A, string B, string name, ref int hNum, ref int uNum) + { + string str; + if ((A == "剪刀" && B == "布") || (A == "石头" && B == "剪刀") || A == "布" && B == "石头") + { + hNum++; + str = "赢"; + } + else if (A == B) + { + + str = "平局"; + } + else + { + uNum++; + str = "输"; + } + if (str == "赢") + { + return $"笨蛋,{name}输了"; + + } + else if (str == "输") + { + return $"恭喜,{name}赢了"; + } + else + { + return "平局,再来"; + } + + } + } + } diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\203\241\346\264\245\345\215\216/Hero.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\203\241\346\264\245\345\215\216/Hero.cs" new file mode 100644 index 0000000000000000000000000000000000000000..7cde214c22144e1d13cea94b7aa1d570c8a9b2e3 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\203\241\346\264\245\345\215\216/Hero.cs" @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo01 +{ + class Hero:Person + { + public Hero() + { + } + + public Hero(string name) : base(name) + { + + } + public void HeroCreate() + { + while (true) + { + Console.WriteLine("请选择对方角色<1.刘备 2.孙权 3.曹操>"); + Console.Write("请选择:"); + string chioce = Console.ReadLine(); + switch (chioce) + { + case "1": + this.Name = "刘备"; + return; + case "2": + this.Name = "孙权"; + return; + case "3": + this.Name = "曹操"; + return; + default: + Console.WriteLine("选择错误,请重新输入"); + continue; + } + } + } + + public override string Action() + { + Random rd = new Random(); + int num = rd.Next(1, 4); + switch (num) + { + case 1: + return "剪刀"; + case 2: + return "石头"; + case 3: + return "布"; + } + return ""; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\203\241\346\264\245\345\215\216/Person.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\203\241\346\264\245\345\215\216/Person.cs" new file mode 100644 index 0000000000000000000000000000000000000000..d9ca448a0c94852ae11a593b6f92670045c21b75 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\203\241\346\264\245\345\215\216/Person.cs" @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo01 +{ + class Person + { + public string Name { get; set; } + + public Person() + { + } + + public Person(string name) + { + Name = name; + } + + public virtual string Action() + { + return null; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\203\241\346\264\245\345\215\216/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\203\241\346\264\245\345\215\216/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..22909272e4421b40b6750627ab7f706245871e68 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\203\241\346\264\245\345\215\216/Program.cs" @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo01 +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("-----------欢 迎 进 入 游 戏 世 界------------"); + while (true) + { + Console.WriteLine("****************************"); + Console.WriteLine("**********猜拳开始**********"); + Console.WriteLine("****************************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Users users = UsersCreate(); + Hero hero = new Hero(); + hero.HeroCreate(); + + bool IsStart = Start(); + if (!IsStart) + { + Console.WriteLine("系统退出"); + return; + } + else + { + Console.WriteLine(users.Name + " VS " + hero.Name+ " 对战"); + } + GameSystem game = new GameSystem(); + bool IsConutinue = game.Gaming(hero, users); + if (!IsConutinue) + { + Console.WriteLine("系统退出"); + return; + } + } + + + + + } + + private static Users UsersCreate() + { + + Console.WriteLine("请输入您的姓名"); + string usersName = Console.ReadLine(); + return new Users(usersName); + } + + private static bool Start() + { + while (true) + { + Console.WriteLine("开始游戏吗?(y/n)"); + string chioce = Console.ReadLine(); + switch (chioce) + { + case "y": + return true; + case "n": + return false; + default: + Console.WriteLine("选择错误,请重新输入"); + continue; + } + } + } + } +} \ No newline at end of file diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\203\241\346\264\245\345\215\216/Users.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\203\241\346\264\245\345\215\216/Users.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b6061eaf9b9e2146f72110c62dfc266a4a4457f3 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\203\241\346\264\245\345\215\216/Users.cs" @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo01 +{ + class Users:Person + { + public Users() + { + + } + public Users(string name) : base(name) + { + + } + + public override string Action() + { + while (true) + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应数字)"); + string chioce = Console.ReadLine(); + switch (chioce) + { + case "1": + return "剪刀"; + case "2": + return "石头"; + case "3": + return "布"; + default: + Console.WriteLine("选择错误,请重新输入"); + continue; + } + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\213\217\346\231\272\351\276\231/NPC.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\213\217\346\231\272\351\276\231/NPC.cs" new file mode 100644 index 0000000000000000000000000000000000000000..c5ad4d47c24f6481fe2f57655c80d6ebec06ac71 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\213\217\346\231\272\351\276\231/NPC.cs" @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class NPC : PunchesWay + { + private string computerName; + + public string ComputerName { get => computerName; set => computerName = value; } + + public void select() + { + Console.WriteLine("刘备出的是:"); + } + + public int adc() + { + Random r = new Random(); + int num = r.Next(1,4); + return num; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\213\217\346\231\272\351\276\231/Program(8).cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\213\217\346\231\272\351\276\231/Program(8).cs" new file mode 100644 index 0000000000000000000000000000000000000000..4b759f504f97f7bfb0bbe384800668205d3dc952 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\213\217\346\231\272\351\276\231/Program(8).cs" @@ -0,0 +1,67 @@ +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) + { + NPC n = new NPC(); + PunchesWay p = new PunchesWay(); + Console.WriteLine("----------欢迎进入游戏世界----------"); + Console.WriteLine("**********************************"); + Console.WriteLine("**************猜拳,开始**********"); + Console.WriteLine("***********************8**********"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Console.WriteLine("请选择对方角色:<1:刘备 2:孙权 3:曹操>"); + int key = int.Parse(Console.ReadLine()); + switch (key) + { + case 1: + n.ComputerName = "刘备"; + break; + } + Console.WriteLine("请输入您的姓名:"); + string str = Console.ReadLine(); + p.Name = str; + + Console.WriteLine(str + "vs" + n.ComputerName + "对战"); + Console.WriteLine("开始游戏吗?"); + string a = Console.ReadLine(); + switch (a) + { + case "y": + a: Console.WriteLine("请出拳:1.石头 2.剪刀 3.布"); + int num = int.Parse(Console.ReadLine()); + bool flag = p.dc(n.ComputerName, num); + if (flag) goto a; + + + break; + case "n": + Console.WriteLine("请出拳:1.石头 2.剪刀 3.布"); + + int key3 = int.Parse(Console.ReadLine()); + break; + + case "2": + break; + + + } + + + + + + + } + + + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\213\217\346\231\272\351\276\231/PunchesWay.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\213\217\346\231\272\351\276\231/PunchesWay.cs" new file mode 100644 index 0000000000000000000000000000000000000000..94efa5f1ae2ff63690e61a93d95f7121bd43c683 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\213\217\346\231\272\351\276\231/PunchesWay.cs" @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + public class PunchesWay + { + + public int choice; + + private string name; + + public string Name { get => name; set => name = value; } + public PunchesWay() { } + public PunchesWay(int Choice) + { + this.Choice = Choice; + + } + public int Choice { get => choice; set => choice = value; } + + /// + /// 通过该方法判断玩家输赢 + /// + /// 电脑名字 + /// 输入的猜拳数字 + public bool dc(string name, int num) + { + NPC n = new NPC(); + int num2 = n.adc(); + if (num == 1) + { + if (num2 == 1) + { + Console.WriteLine("平局"); + return true; + } + else if (num2 == 2) + { + Console.WriteLine(name + "赢了"); + } + else + { + Console.WriteLine(this.name + "赢了"); + } + + + } + else if (num == 2) + { + if (num2 == 2) + { + Console.WriteLine("平局"); + return true; + } + else if (num2 == 1) + { + Console.WriteLine(name + "赢了"); + } + else + { + Console.WriteLine(this.name + "赢了"); + } + } + else + { + if (num2 == 3) + { + Console.WriteLine("平局"); + return true; + } + else if (num2 == 2) + { + Console.WriteLine(name + "赢了"); + } + else + { + Console.WriteLine(this.name + "赢了"); + } + } + return false; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\213\217\346\235\234\345\206\233/.keep" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\213\217\346\235\234\345\206\233/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\213\217\346\235\234\345\206\233/Judgment.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\213\217\346\235\234\345\206\233/Judgment.cs" new file mode 100644 index 0000000000000000000000000000000000000000..641fd20fe281f2d2a82ddfcc2babe95bf2118e14 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\213\217\346\235\234\345\206\233/Judgment.cs" @@ -0,0 +1,159 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Judgment + { + public static void Test() + { + //接对方角色名 + string ing = "未命名"; + Boolean tr = true; + while (tr) + { + Console.WriteLine("请选择对方角色<1.刘备 2.孙权 3.曹操>"); + int key = int.Parse(Console.ReadLine()); + switch (key) + { + case 1: + ing = "刘备"; + tr = false; + break; + case 2: + ing = "孙权"; + tr = false; + break; + case 3: + ing = "曹操"; + tr = false; + break; + default: + Console.WriteLine("输入错误,请重新输入!"); + break; + } + } + Opposite oppo = new Opposite(ing); + //游戏次数 + int z = 0; + //刘备赢多少 + int g = 0; + //我赢的次数 + int t = 0; + Console.WriteLine("请输入您的姓名"); + string Name = Console.ReadLine(); + Oneself oneself = new Oneself(Name); + oneself.Test01(); + Console.WriteLine("开始游戏吗?"); + string k = Console.ReadLine(); + Boolean n = true; + while (n) + { + switch (k) + { + case "y": + z++; + Console.WriteLine(); + int e = 0; + while (true) + { + try + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布"); + e = int.Parse(Console.ReadLine()); + oneself.Test03(e); + break; + } + catch (Exception) + { + Console.WriteLine("输入错误,请重新输入"); + } + } + oneself.Test(); + int a = Opposite.Test01(); + oppo.Test(); + if (a == e) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + else if ((e == 1 && a == 3) || (e == 2 && a == 1) || (e == 3 && a == 2)) + { + Console.WriteLine("恭喜,{0}赢了", oneself.name); + t++; + } + else + { + Console.WriteLine("笨蛋,{0}输了", oneself.name); + g++; + } + Console.WriteLine("是否开始下一轮比赛"); + string q = Console.ReadLine(); + switch (q) + { + case "y": + n = true; + break; + case "n": + n = false; + Console.WriteLine("==============================================="); + oneself.Test01(); + Console.WriteLine("对战次数:{0}", z); + + Console.WriteLine(); + Console.WriteLine("姓名\t得分"); + Console.WriteLine("{0} \t{1}", oneself.name, t); + Console.WriteLine("{0} \t{1}", Opposite.Name, g); + if (t == g) + { + Console.WriteLine("平局,{0},{1},两个笨蛋",oppo.name,oneself.name); + } + else if (t > g) + { + Console.WriteLine("{0}赢,{1}笨蛋", oneself.name, Opposite.Name); + } + else if (t < g) + { + Console.WriteLine("{0}赢,{1}笨蛋", Opposite.Name, oneself.name); + } + Console.WriteLine("要进行下一局比赛吗?"); + string ke = Console.ReadLine(); + switch (ke) + { + case "y": + n = true; + z = 0; + g = 0; + t = 0; + break; + case "n": + Console.WriteLine("系统退出"); + n = false; + break; + default: + break; + } + break; + default: + Console.WriteLine("输入错误,请重新输入!"); + Console.WriteLine("是否开始下一轮比赛"); + q = Console.ReadLine(); + break; + } + break; + case "n": + Console.WriteLine("系统退出"); + n = false; + break; + default: + Console.WriteLine("输入错误,请重新输入!"); + Console.WriteLine("开始游戏吗?"); + k = Console.ReadLine(); + break; + } + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\213\217\346\235\234\345\206\233/Oneself.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\213\217\346\235\234\345\206\233/Oneself.cs" new file mode 100644 index 0000000000000000000000000000000000000000..5050a81ffe507ab63327fdebf3d5ee2324341c2b --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\213\217\346\235\234\345\206\233/Oneself.cs" @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Oneself : Person + { + public string name { get; set; } + public static string chu { get; set; } + public Oneself(string name) + { + this.name = name; + } + public void Test01() + { + Console.WriteLine("{0} vs {1} 对战", Name, this.name); + } + + public void Test03(int key) + { + + switch (key) + { + case 1: + chu = "剪刀"; + break; + case 2: + chu = "石头"; + break; + case 3: + chu = "布"; + break; + default: + break; + } + } + public override void Test() + { + Console.WriteLine("{0}:出拳:{1}", name, chu); + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\213\217\346\235\234\345\206\233/Opposite.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\213\217\346\235\234\345\206\233/Opposite.cs" new file mode 100644 index 0000000000000000000000000000000000000000..9f572ac6cf8d315c2016e0a34e3cc399330406a1 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\213\217\346\235\234\345\206\233/Opposite.cs" @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Opposite : Person + { + public string name { get; set; } + public static string a { get; set; } + public Opposite(string name) + { + this.name = name; + Name = name; + } + public static int Test01() + { + Random ran = new Random(); + int key = ran.Next(3) + 1; + switch (key) + { + case 1: + a = "剪刀"; + break; + case 2: + a = "石头"; + break; + case 3: + a = "布"; + break; + default: + break; + } + return key; + } + public override void Test() + { + Console.WriteLine("{0}:出拳:{1}", name, a); + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\213\217\346\235\234\345\206\233/Person.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\213\217\346\235\234\345\206\233/Person.cs" new file mode 100644 index 0000000000000000000000000000000000000000..f87b5cfcd4634874dbf27823863f5457d9e60f13 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\213\217\346\235\234\345\206\233/Person.cs" @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + abstract class Person + { + public static string Name { get; set; } + public abstract void Test(); + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\213\217\346\235\234\345\206\233/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\213\217\346\235\234\345\206\233/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..db67e90854b6d93ab3e379965deabd658bc9f3ff --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\213\217\346\235\234\345\206\233/Program.cs" @@ -0,0 +1,25 @@ +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.布"); + Judgment.Test(); + + Console.ReadKey(); + } + } + +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\224\241\350\245\277\346\266\233/Gz.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\224\241\350\245\277\346\266\233/Gz.cs" new file mode 100644 index 0000000000000000000000000000000000000000..414278201e5ebf730c79738b25f137f726d312e4 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\224\241\350\245\277\346\266\233/Gz.cs" @@ -0,0 +1,105 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp12 +{ + class Gz + { + public Gz() { } + public Gz(string chu, string dchu) + { + Chu = chu; + Dchu = dchu; + } + + public string Chu { get; set; } + public string Dchu { get; set; } + + public void Cq(int a) + { + switch (a) + { + case 1: + Chu = "剪刀"; + break; + case 2: + Chu = "石头"; + break; + case 3: + Chu = "布"; + break; + default: + Console.WriteLine("输入错误"); + break; + } + } + public void Ca(int c) + { + switch (c) + { + case 1: + Dchu = "剪刀"; + break; + case 2: + Dchu = "石头"; + break; + case 3: + Dchu = "布"; + break; + default: + break; + } + } + //public void Pbai() + //{ + // if (gz1.Chu=="剪刀") + // { + // if (gz1.Dchu=="剪刀") + // { + // Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + // } + // if (gz1.Dchu == "石头") + // { + // Console.WriteLine($"笨蛋,{p2.Sname}输了"); + // } + // if (gz1.Dchu=="布") + // { + // Console.WriteLine($"恭喜,{p2.Sname}赢了"); + // } + // } + // if (gz1.Chu == "石头") + // { + // if (gz1.Dchu == "剪刀") + // { + // Console.WriteLine($"恭喜,{p2.Sname}赢了"); + // } + // if (gz1.Dchu == "石头") + // { + // Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + // } + // if (gz1.Dchu == "布") + // { + // Console.WriteLine($"笨蛋,{p2.Sname}输了"); + // } + // } + // if (gz1.Chu == "布") + // { + // if (gz1.Dchu == "剪刀") + // { + // Console.WriteLine($"笨蛋,{p2.Sname}输了"); + // } + // if (gz1.Dchu == "石头") + // { + // Console.WriteLine($"恭喜,{p2.Sname}赢了"); + // } + // if (gz1.Dchu == "布") + // { + // Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + // } + // } + //} + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\224\241\350\245\277\346\266\233/Part.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\224\241\350\245\277\346\266\233/Part.cs" new file mode 100644 index 0000000000000000000000000000000000000000..3326416ea9abf04b186bdb5127285124aad5b95c --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\224\241\350\245\277\346\266\233/Part.cs" @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp12 +{ + class Part + { + public Part() { } + public Part(string name) + { + Name = name; + } + + public string Name { get; set; } + + public void Sp() + { + Console.WriteLine("请选择对方的游戏角色:1、刘备,2、孙权,3、曹操"); + int key = int.Parse(Console.ReadLine()); + switch (key) + { + case 1: + Name = "刘备"; + break; + case 2: + Name = "孙权"; + break; + case 3: + Name = "曹操"; + break; + default: + Console.WriteLine("输入错误,请重新选择:"); + break; + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\224\241\350\245\277\346\266\233/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\224\241\350\245\277\346\266\233/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..58817d93e6948aee06c42862a9ac49261e6f29b9 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\224\241\350\245\277\346\266\233/Program.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp12 +{ + class Program + { + static void Main(string[] args) + { + Player player = new Player(); + + Console.WriteLine("----------欢迎进入游戏世界---------"); + Console.WriteLine("****************"); + Console.WriteLine("***猜拳,开始***"); + Console.WriteLine("****************"); + Console.WriteLine("出拳规则:1、剪刀,2、石头,3、布"); + player.Sw(); + + Console.ReadKey(); + } + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\224\241\350\245\277\346\266\233/player.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\224\241\350\245\277\346\266\233/player.cs" new file mode 100644 index 0000000000000000000000000000000000000000..956493571b9ff39b0d86d103e6925c95e4cfa11e --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\224\241\350\245\277\346\266\233/player.cs" @@ -0,0 +1,154 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp12 +{ + class Player + { + Part p1 = new Part(); + Gz gz = new Gz(); + Random ra = new Random(); + public string Sname { get; set; } + public Player() { } + public Player(string sname) + { + Sname = sname; + } + public void Sw() + { + Console.WriteLine("请输入你的姓名:"); + Sname = Console.ReadLine(); + p1.Sp(); + Console.WriteLine($"{Sname} vs {p1.Name} 对战"); + Console.WriteLine("开始游戏吗?"); + string start = Console.ReadLine(); + switch (start) + { + case "y": + Wan(); + break; + case "n": + Buwan(); + break; + default: + Console.WriteLine("输入错误,请重新选择:"); + break; + } + } + public void Wan() + { + int score = 0; + int score1 = 0; + int s = 0; + while (true) + { + Console.WriteLine("请出拳:1.剪刀,2.石头,3.布(输入相应的数字)"); + int a = int.Parse(Console.ReadLine()); + gz.Cq(a); + Console.WriteLine($"{Sname}:出拳:{gz.Chu} "); + int c = ra.Next(1, 4); + gz.Ca(c); + Console.WriteLine($"{p1.Name}:出拳:{gz.Dchu}"); + + if (gz.Chu == "剪刀") + { + if (gz.Dchu == "剪刀") + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + if (gz.Dchu == "石头") + { + Console.WriteLine($"笨蛋,{Sname}输了"); + score1++; + } + if (gz.Dchu == "布") + { + Console.WriteLine($"恭喜,{Sname}赢了"); + score++; + } + } + if (gz.Chu == "石头") + { + if (gz.Dchu == "剪刀") + { + Console.WriteLine($"恭喜,{Sname}赢了"); + score++; + } + if (gz.Dchu == "石头") + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + if (gz.Dchu == "布") + { + Console.WriteLine($"笨蛋,{Sname}输了"); + score1++; + } + } + if (gz.Chu == "布") + { + if (gz.Dchu == "剪刀") + { + Console.WriteLine($"笨蛋,{Sname}输了"); + score1++; + } + if (gz.Dchu == "石头") + { + Console.WriteLine($"恭喜,{Sname}赢了"); + score++; + } + if (gz.Dchu == "布") + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + } + s++; + Console.WriteLine("是否开始下一轮?"); + string l = Console.ReadLine(); + if (l=="y") + { + + } + if (l=="n") + { + Console.WriteLine("===================="); + Console.WriteLine($"{p1.Name} vs {Sname}"); + Console.WriteLine($"对战次数 { s}"); + Console.WriteLine(); + Console.WriteLine("姓名 得分"); + Console.WriteLine($"{Sname} {score}"); + Console.WriteLine($"{p1.Name} {score1}"); + if (score>score1) + { + Console.WriteLine($"我{Sname}赢了,{p1.Name}是大笨蛋"); + } + if (score < score1) + { + Console.WriteLine($"我{p1.Name}赢了,{Sname}是大笨蛋"); + } + if (score == score1) + { + Console.WriteLine($"晦气呀,谁都没有赢。"); + } + Console.WriteLine("要开始下一局吗?"); + string p = Console.ReadLine(); + if (p == "y") + { + Sw(); + } + if (p == "n") + { + Buwan(); + break; + } + } + } + } + public void Buwan() + { + Console.WriteLine("系统退出"); + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\242\201\345\235\232/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\242\201\345\235\232/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..dd70fa70fe3873fc0597d54a74ac53c411824e7e --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\242\201\345\235\232/Program.cs" @@ -0,0 +1,147 @@ +using System; + +namespace ConsoleApp1 +{ + + class Program + { + static void Main(string[] args) + { + Random rn = new Random(); + Console.WriteLine("---------------欢迎进入游戏世界----------------------"); + Console.WriteLine("****************************************************"); + Console.WriteLine("*************猜拳,开始*****************************"); + Console.WriteLine("****************************************************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Console.WriteLine("请选择对方角色(1.刘备 2.孙权 3.曹操)"); + int NPC = int.Parse(Console.ReadLine()); + string nam = "刘备"; + if (NPC==2) + { + nam= "孙权"; + } + if (NPC == 3) + { + nam = "曹操"; + } + Npc npc = new Npc(nam); + + Console.WriteLine("请输入你的角色名"); + Player player = new Player(Console.ReadLine()); + Console.WriteLine(player.Name+"VS"+npc.Name+" 对战"); + Console.WriteLine("开始游戏吗?(y/n)"); + string begin = Console.ReadLine(); + int fenshu1= 0; + int fenshu2 = 0; + while (Judge(begin)) + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应数字)"); + int ab = int.Parse(Console.ReadLine()); + if (ab==1){Console.WriteLine(player.Name + ": 出拳: 剪刀" );} + if (ab==2){Console.WriteLine(player.Name + ": 出拳: 石头");} + if (ab==3){Console.WriteLine(player.Name + ": 出拳: 布");} + int ac=rn.Next(0,3); + if (ac==1){Console.WriteLine(npc.Name + ": 出拳: 剪刀"); } + if (ac==2){Console.WriteLine(npc.Name + ": 出拳: 石头");} + if (ac==3){Console.WriteLine(npc.Name + ": 出拳: 布"); } + + if (ab==1) + { + if (ac==3) { + Console.WriteLine("恭喜,{0}赢了", player.Name); + fenshu1++;} + if (ac==2) + { + Console.WriteLine("笨蛋,{0}输了",player.Name ); + fenshu2++; + } + } + if (ab==2) + { + if (ac==1) { + Console.WriteLine("恭喜,{0}赢了", player.Name); + fenshu1++;} + if (ac==3) + { + Console.WriteLine("笨蛋,{0}输了",player.Name ); + fenshu2++; + } + } + if (ab==3) + { + if (ac==2) { + Console.WriteLine("恭喜,{0}赢了", player.Name); + fenshu1++;} + if (ac==1) + { + Console.WriteLine("笨蛋,{0}输了",player.Name ); + fenshu2++; + } + } + if (ac==ab) + { + Console.WriteLine("嘻嘻,和局{0}走着瞧.....", player.Name); + } + + + + + + + + + Console.WriteLine("是否开始下一轮?(y/n)"); + begin = Console.ReadLine(); + Judge(begin); + + } + Console.WriteLine("***姓名******得分******"); + Console.WriteLine(" "+ player.Name+" "+fenshu1); + Console.WriteLine(" " + npc.Name + " " + fenshu2); + if (fenshu1 > fenshu2) + {Console.WriteLine(player.Name + "赢了,这个" + npc.Name + "就是逊了啦");} + else { Console.WriteLine(npc.Name + "赢了,这个" +player.Name + "就是逊了啦"); } + Console.ReadKey(); + } + public static bool Judge(string begin) + { + bool whether; + if (begin == "y") + { whether = true; } + else { whether = false; } + return whether; + } + } + + class Role + { + + public string Name { get; set; }//角色名字 + public virtual void Throw() { }//出拳的方法 + public Role(string Name) { + this.Name = Name; + } + } + + class Player : Role//玩家 + { + + public override void Throw() + { + int a = int.Parse(Console.ReadLine()); + } + + public Player(string Name):base(Name){ } + + } + class Npc : Role//NPC + { + + public override void Throw()//讲骚话 + { + } + public Npc(string Name) : base(Name) { } + } + + +} \ No newline at end of file diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\246\203\347\245\232\345\233\275/.keep" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\246\203\347\245\232\345\233\275/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\246\203\347\245\232\345\233\275/Father.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\246\203\347\245\232\345\233\275/Father.cs" new file mode 100644 index 0000000000000000000000000000000000000000..cc587b4b78dfa714cb8e2f8a33365759aade4fc2 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\246\203\347\245\232\345\233\275/Father.cs" @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + enum Houquan + { + /// + /// 剪刀 + /// + 剪刀, + /// + /// 石头 + /// + 石头, + /// + /// 布 + /// + 布 + } + enum Computer + { + /// + /// 刘备 + /// + 刘备, + /// + /// 孙权 + /// + 孙权, + /// + /// 曹操 + /// + 曹操 + } + abstract class Father + { + public Houquan CQ { get; set; } + public Computer DN { get; set; } + public Father( Houquan CQ,Computer DN) + { + this.CQ = CQ; + this.DN = DN; + } + public Father() { } + static public void TwoPhone() + { + while (true) + { + + } + } + public abstract void LiuBei(); + public abstract void SunQuan(); + public abstract void CaoCao(); + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\246\203\347\245\232\345\233\275/Player.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\246\203\347\245\232\345\233\275/Player.cs" new file mode 100644 index 0000000000000000000000000000000000000000..a3945d5c69db8f7ebac069e42cb6d84754fc18e1 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\246\203\347\245\232\345\233\275/Player.cs" @@ -0,0 +1,335 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Player : Father + { + public string name { get; set; } + public Player() { } + public Player(string name,Houquan CQ,Computer DN):base(CQ,DN) + { + this.name = name; + } + public override void LiuBei() + { + int UU = 1; + int JJ = 0; + int KK = 0; + Boolean q = true; + while (q) + { + Random ran = new Random(); + int b; + b = ran.Next(1, 4); + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应数字:)"); + int a = int.Parse(Console.ReadLine()); + if (a == 1 && b == 1 ) + { + Console.WriteLine("{0}:出拳:{1}", this.name, Houquan.剪刀); + Console.WriteLine("{0}:出拳:{1}", Computer.刘备, Houquan.剪刀); + Console.WriteLine("和局,真衰,嘿嘿,等着瞧吧!"); + } + if (a == 2 && b == 2) + { + Console.WriteLine("{0}:出拳:{1}", this.name, Houquan.石头); + Console.WriteLine("{0}:出拳:{1}", Computer.刘备, Houquan.石头); + Console.WriteLine("和局,真衰,嘿嘿,等着瞧吧!"); + } + if (a == 3 && b == 3) + { + Console.WriteLine("{0}:出拳:{1}", this.name, Houquan.布); + Console.WriteLine("{0}:出拳:{1}", Computer.刘备, Houquan.布); + Console.WriteLine("和局,真衰,嘿嘿,等着瞧吧!"); + } + if (a < b && a == 1 && b == 2) + { + Console.WriteLine("{0}:出拳:{1}", this.name, Houquan.剪刀); + Console.WriteLine("{0}:出拳:{1}", Computer.刘备, Houquan.石头); + Console.WriteLine("笨蛋,{0}输了", this.name); + JJ++; + } + if (a == 1 && b == 3) + { + Console.WriteLine("{0}:出拳:{1}", this.name, Houquan.剪刀); + Console.WriteLine("{0}:出拳:{1}", Computer.刘备, Houquan.布); + Console.WriteLine("恭喜,{0}赢了", this.name); + KK++; + } + if (a == 2 && b == 3) + { + Console.WriteLine("{0}:出拳:{1}", this.name, Houquan.石头); + Console.WriteLine("{0}:出拳:{1}", Computer.刘备, Houquan.布); + Console.WriteLine("笨蛋,{0}输了", this.name); + JJ++; + } + if (a == 3 && b == 1) + { + Console.WriteLine("{0}:出拳:{1}", this.name, Houquan.布); + Console.WriteLine("{0}:出拳:{1}", Computer.刘备, Houquan.剪刀); + Console.WriteLine("笨蛋,{0}输了", this.name); + JJ++; + } + if (a == 3 && b == 2) + { + Console.WriteLine("{0}:出拳:{1}", this.name, Houquan.布); + Console.WriteLine("{0}:出拳:{1}", Computer.刘备, Houquan.石头); + Console.WriteLine("恭喜,{0}赢了", this.name); + KK++; + } + if (a ==3 && b == 2) + { + Console.WriteLine("{0}:出拳:{1}", this.name, Houquan.布); + Console.WriteLine("{0}:出拳:{1}", Computer.刘备, Houquan.石头); + Console.WriteLine("恭喜,{0}赢了", this.name); + KK++; + } + if(a>3) + { + Console.WriteLine("是不是输错了,再试一次吧!!"); + UU--; + } + Console.WriteLine("是否开始下一轮?"); + string QQ = Console.ReadLine(); + if (QQ=="n") + { + break; + } + UU++; + } + Console.WriteLine("================================================="); + Console.WriteLine("{0} VS {1}",Computer.刘备,this.name); + Console.WriteLine("对战次数:{0}",UU); + Console.WriteLine("姓名\t得分"); + Console.WriteLine("{0}\t{1}",this.name,KK); + Console.WriteLine("{0}\t{1}",Computer.刘备,JJ); + if (JJ > KK) + { + Console.WriteLine("结果:{0}赢,{1}笨蛋",Computer.刘备,this.name); + } + if (JJ < KK) + { + Console.WriteLine("结果:{0}赢,{1}笨蛋", this.name, Computer.刘备); + } + if (JJ==KK) + { + Console.WriteLine("结果:喔喔,你们平分秋色啦!!!"); + } + } + + public override void SunQuan() + { + int UU = 1; + int JJ = 0; + int KK = 0; + Boolean q = true; + while (q) + { + Random ran = new Random(); + int b; + b = ran.Next(1, 4); + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应数字:)"); + int a = int.Parse(Console.ReadLine()); + if (a == 1 && b == 1) + { + Console.WriteLine("{0}:出拳:{1}", this.name, Houquan.剪刀); + Console.WriteLine("{0}:出拳:{1}", Computer.孙权, Houquan.剪刀); + Console.WriteLine("和局,真衰,嘿嘿,等着瞧吧!"); + } + if (a == 2 && b == 2) + { + Console.WriteLine("{0}:出拳:{1}", this.name, Houquan.石头); + Console.WriteLine("{0}:出拳:{1}", Computer.孙权, Houquan.石头); + Console.WriteLine("和局,真衰,嘿嘿,等着瞧吧!"); + } + if (a == 3 && b == 3) + { + Console.WriteLine("{0}:出拳:{1}", this.name, Houquan.布); + Console.WriteLine("{0}:出拳:{1}", Computer.孙权, Houquan.布); + Console.WriteLine("和局,真衰,嘿嘿,等着瞧吧!"); + } + if (a < b && a == 1 && b == 2) + { + Console.WriteLine("{0}:出拳:{1}", this.name, Houquan.剪刀); + Console.WriteLine("{0}:出拳:{1}", Computer.孙权, Houquan.石头); + Console.WriteLine("笨蛋,{0}输了", this.name); + JJ++; + } + if (a == 1 && b == 3) + { + Console.WriteLine("{0}:出拳:{1}", this.name, Houquan.剪刀); + Console.WriteLine("{0}:出拳:{1}", Computer.孙权, Houquan.布); + Console.WriteLine("恭喜,{0}赢了", this.name); + KK++; + } + if (a == 2 && b == 3) + { + Console.WriteLine("{0}:出拳:{1}", this.name, Houquan.石头); + Console.WriteLine("{0}:出拳:{1}", Computer.孙权, Houquan.布); + Console.WriteLine("笨蛋,{0}输了", this.name); + JJ++; + } + if (a == 3 && b == 1) + { + Console.WriteLine("{0}:出拳:{1}", this.name, Houquan.布); + Console.WriteLine("{0}:出拳:{1}", Computer.孙权, Houquan.剪刀); + Console.WriteLine("笨蛋,{0}输了", this.name); + JJ++; + } + if (a == 3 && b == 2) + { + Console.WriteLine("{0}:出拳:{1}", this.name, Houquan.布); + Console.WriteLine("{0}:出拳:{1}", Computer.孙权, Houquan.石头); + Console.WriteLine("恭喜,{0}赢了", this.name); + KK++; + } + if (a == 3 && b == 2) + { + Console.WriteLine("{0}:出拳:{1}", this.name, Houquan.布); + Console.WriteLine("{0}:出拳:{1}", Computer.孙权, Houquan.石头); + Console.WriteLine("恭喜,{0}赢了", this.name); + KK++; + } + if (a > 3) + { + Console.WriteLine("是不是输错了,再试一次吧!!"); + UU--; + } + Console.WriteLine("是否开始下一轮?"); + string QQ = Console.ReadLine(); + if (QQ == "n") + { + break; + } + UU++; + } + Console.WriteLine("================================================="); + Console.WriteLine("{0} VS {1}", Computer.孙权, this.name); + Console.WriteLine("对战次数:{0}", UU); + Console.WriteLine("姓名\t得分"); + Console.WriteLine("{0}\t{1}", this.name, KK); + Console.WriteLine("{0}\t{1}", Computer.孙权, JJ); + if (JJ > KK) + { + Console.WriteLine("结果:{0}赢,{1}笨蛋", Computer.孙权, this.name); + } + if (JJ < KK) + { + Console.WriteLine("结果:{0}赢,{1}笨蛋", this.name, Computer.孙权); + } + if (JJ == KK) + { + Console.WriteLine("结果:喔喔,你们平分秋色啦!!!"); + } + } + + public override void CaoCao() + { + int UU = 1; + int JJ = 0; + int KK = 0; + Boolean q = true; + while (q) + { + Random ran = new Random(); + int b; + b = ran.Next(1, 4); + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应数字:)"); + int a = int.Parse(Console.ReadLine()); + if (a == 1 && b == 1) + { + Console.WriteLine("{0}:出拳:{1}", this.name, Houquan.剪刀); + Console.WriteLine("{0}:出拳:{1}", Computer.曹操, Houquan.剪刀); + Console.WriteLine("和局,真衰,嘿嘿,等着瞧吧!"); + } + if (a == 2 && b == 2) + { + Console.WriteLine("{0}:出拳:{1}", this.name, Houquan.石头); + Console.WriteLine("{0}:出拳:{1}", Computer.曹操, Houquan.石头); + Console.WriteLine("和局,真衰,嘿嘿,等着瞧吧!"); + } + if (a == 3 && b == 3) + { + Console.WriteLine("{0}:出拳:{1}", this.name, Houquan.布); + Console.WriteLine("{0}:出拳:{1}", Computer.曹操, Houquan.布); + Console.WriteLine("和局,真衰,嘿嘿,等着瞧吧!"); + } + if (a < b && a == 1 && b == 2) + { + Console.WriteLine("{0}:出拳:{1}", this.name, Houquan.剪刀); + Console.WriteLine("{0}:出拳:{1}", Computer.曹操, Houquan.石头); + Console.WriteLine("笨蛋,{0}输了", this.name); + JJ++; + } + if (a == 1 && b == 3) + { + Console.WriteLine("{0}:出拳:{1}", this.name, Houquan.剪刀); + Console.WriteLine("{0}:出拳:{1}", Computer.曹操, Houquan.布); + Console.WriteLine("恭喜,{0}赢了", this.name); + KK++; + } + if (a == 2 && b == 3) + { + Console.WriteLine("{0}:出拳:{1}", this.name, Houquan.石头); + Console.WriteLine("{0}:出拳:{1}", Computer.曹操, Houquan.布); + Console.WriteLine("笨蛋,{0}输了", this.name); + JJ++; + } + if (a == 3 && b == 1) + { + Console.WriteLine("{0}:出拳:{1}", this.name, Houquan.布); + Console.WriteLine("{0}:出拳:{1}", Computer.曹操, Houquan.剪刀); + Console.WriteLine("笨蛋,{0}输了", this.name); + JJ++; + } + if (a == 3 && b == 2) + { + Console.WriteLine("{0}:出拳:{1}", this.name, Houquan.布); + Console.WriteLine("{0}:出拳:{1}", Computer.曹操, Houquan.石头); + Console.WriteLine("恭喜,{0}赢了", this.name); + KK++; + } + if (a == 3 && b == 2) + { + Console.WriteLine("{0}:出拳:{1}", this.name, Houquan.布); + Console.WriteLine("{0}:出拳:{1}", Computer.曹操, Houquan.石头); + Console.WriteLine("恭喜,{0}赢了", this.name); + KK++; + } + if (a > 3) + { + Console.WriteLine("是不是输错了,再试一次吧!!"); + UU--; + } + Console.WriteLine("是否开始下一轮?"); + string QQ = Console.ReadLine(); + if (QQ == "n") + { + break; + } + UU++; + } + Console.WriteLine("================================================="); + Console.WriteLine("{0} VS {1}", Computer.刘备, this.name); + Console.WriteLine("对战次数:{0}", UU); + Console.WriteLine("姓名\t得分"); + Console.WriteLine("{0}\t{1}", this.name, KK); + Console.WriteLine("{0}\t{1}", Computer.刘备, JJ); + if (JJ > KK) + { + Console.WriteLine("结果:{0}赢,{1}笨蛋", Computer.刘备, this.name); + } + if (JJ < KK) + { + Console.WriteLine("结果:{0}赢,{1}笨蛋", this.name, Computer.刘备); + } + if (JJ == KK) + { + Console.WriteLine("结果:喔喔,你们平分秋色啦!!!"); + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\246\203\347\245\232\345\233\275/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\246\203\347\245\232\345\233\275/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..a6338425f4771d6be61caf5f40af42e7f7e3c277 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\246\203\347\245\232\345\233\275/Program.cs" @@ -0,0 +1,96 @@ +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 a = int.Parse(Console.ReadLine()); + switch (a) + { + case 1: + KLO(); + Console.WriteLine("要开始下一局吗?"); + string XX = Console.ReadLine(); + switch (XX) + { + case "y": + KLO(); + break; + case "n": + Console.WriteLine("系统退出!!!"); + break; + } + break; + case 2: + DDE(); + Console.WriteLine("要开始下一局吗?"); + string WW = Console.ReadLine(); + switch (WW) + { + case "y": + DDE(); + break; + case "n": + Console.WriteLine("系统退出!!!"); + break; + } + break; + case 3: + SSS(); + Console.WriteLine("要开始下一局吗?"); + string RR = Console.ReadLine(); + switch (RR) + { + case "y": + SSS(); + break; + case "n": + Console.WriteLine("系统退出!!!"); + break; + } + break; + + } + Console.ReadKey(); + } + static public void KLO() + { + Player pla = new Player(); + Console.WriteLine("请输入您的名字:"); + string name = Console.ReadLine(); + pla.DN = Computer.刘备; + pla.name = name; + pla.LiuBei(); + } + static public void DDE() + { + Player pla = new Player(); + Console.WriteLine("请输入您的名字:"); + string name = Console.ReadLine(); + pla.DN = Computer.孙权; + pla.name = name; + pla.SunQuan(); + } + static public void SSS() + { + Player pla = new Player(); + Console.WriteLine("请输入您的名字:"); + string name = Console.ReadLine(); + pla.DN = Computer.曹操; + pla.name = name; + pla.CaoCao(); + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\277\252\345\212\233\344\272\232\345\260\224/.keep" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\277\252\345\212\233\344\272\232\345\260\224/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\277\252\345\212\233\344\272\232\345\260\224/Game.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\277\252\345\212\233\344\272\232\345\260\224/Game.cs" new file mode 100644 index 0000000000000000000000000000000000000000..d0fad88a18fb38e3cd6244ac5b29bacef9af39b0 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\277\252\345\212\233\344\272\232\345\260\224/Game.cs" @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Game + { + private object userName; + private object wayName; + + public bool Gaming(Way way, User user) + { + int sum = 0; + int lNum = 0; + int nNum = 0; + while (true) + { + string wayAction; + string userAction; + userAction = user.Action(); + Console.WriteLine(user.Name + " :出拳: " + userAction); + wayAction = way.Action(); + Console.WriteLine(way.Name + " :出拳: " + wayAction); + IsWin(wayAction, userAction, user.Name, ref nNum); + + //Console.WriteLine(IsWin(wayAction, userAction, user.Name, ref lNum, ref nNum)); + + sum++; + while (true) + { + Console.WriteLine("是否开始下一轮?(1.继续 / 2.停止)"); + string a = Console.ReadLine(); + if (a == "1") + { + break; + } + else if (a == "2") + { + return EndGame(way.Name, user.Name, sum, lNum, nNum); + } + else + { + Console.WriteLine("输入错误,请重新输入!"); + continue; + } + } + } + } + + private void IsWin(string wayAction, string userAction, string name, ref int nNum) + { + throw new NotImplementedException(); + } + + private bool EndGame(string name1, string name2, int sum, int lNum, int nNum) + { + Console.WriteLine("========================="); + Console.WriteLine("对战次数:" + sum); + + Console.WriteLine("姓名 \t 得分"); + Console.WriteLine(userName + "\t" + nNum); + Console.WriteLine(wayName + "\t" + lNum); + if (lNum > nNum) + { + Console.WriteLine($"{userName}赢了,{wayName}输了"); + } + else + { + Console.WriteLine("平局"); + } + while (true) + { + Console.WriteLine("要开始下一局吗?(y/n)"); + string a = Console.ReadLine(); + switch (a) + { + case "y": + return true; + case "n": + return false; + default: + Console.WriteLine("选择错误,请重新输入!"); + continue; + } + } + } + + public void IsWin(string wayAction, string userAction, string name, ref int lNum, ref int nNum) + { + string str; + if ((wayAction == "剪刀" && userAction == "布") || (wayAction == "石头" && userAction == "剪刀") || wayAction == "布" && userAction == "石头") + { + lNum++; + Console.WriteLine($"笨蛋,{name}输了"); + } + else if (wayAction == userAction) + { + Console.WriteLine($"和局,太可惜了!"); + } + else + { + nNum++; + Console.WriteLine($"恭喜,{name}赢了!"); + } + + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\277\252\345\212\233\344\272\232\345\260\224/Person.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\277\252\345\212\233\344\272\232\345\260\224/Person.cs" new file mode 100644 index 0000000000000000000000000000000000000000..ef4bc6ae5e446beb47c134ac51581ad526c81c53 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\277\252\345\212\233\344\272\232\345\260\224/Person.cs" @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Person + { + public string Name { get; set; } + public Person() + { + + } + public Person(string name) + { + Name = name; + } + public virtual string Action() + { + return null; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\277\252\345\212\233\344\272\232\345\260\224/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\277\252\345\212\233\344\272\232\345\260\224/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..8b85581e3b7e9eef5d9df16267ff0921bebc7dae --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\277\252\345\212\233\344\272\232\345\260\224/Program.cs" @@ -0,0 +1,88 @@ +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("-----------------欢迎进入游戏世界!-----------------"); + while (true) + { + Console.WriteLine("**********************"); + Console.WriteLine("********猜拳,开始******"); + Console.WriteLine("**********************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Way way = WayCreate(); + User user = UserCreate(); + bool IsStart = Start(); + if (!IsStart) + { + Console.WriteLine("系统退出!"); + return; + } + else + { + Console.WriteLine(way.Name + " VS " + user.Name + " 对战 "); + } + Game game = new Game(); + bool IsCountine = game.Gaming(way, user); + if (!IsCountine) + { + Console.WriteLine("系统退出!"); + return; + } + } + } + public static bool Start() + { + while (true) + { + Console.WriteLine("开始游戏吗?(y/n)"); + string a = Console.ReadLine(); + switch (a) + { + case "y": + return true; + case "n": + return false; + default: + Console.WriteLine("选择错误,请重新输入!"); + continue; + } + } + } + private static Way WayCreate() + { + while (true) + { + Console.WriteLine("请选择对方角色<1.刘备 2.孙权 3.曹操"); + Console.Write("请选择:"); + string a = Console.ReadLine(); + switch (a) + { + case "1": + return new Way("刘备"); + case "2": + return new Way("孙权"); + case "3": + return new Way("曹操"); + default: + Console.WriteLine("选择错误,请重新输入!"); + continue; + } + } + } + + private static User UserCreate() + { + Console.WriteLine("请输入您的姓名"); + string userName = Console.ReadLine(); + return new User(userName); + } + } + } diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\277\252\345\212\233\344\272\232\345\260\224/User.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\277\252\345\212\233\344\272\232\345\260\224/User.cs" new file mode 100644 index 0000000000000000000000000000000000000000..7359bb6e39abec2a63dfae21ddd386d3da60944f --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\277\252\345\212\233\344\272\232\345\260\224/User.cs" @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class User:Person + { + public User() + { + + } + public User(string name) : base(name) + { + + } + + public string Name { get; internal set; } + + public override string Action() + { + while (true) + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布 (请输入相应的数字:)"); + string a = Console.ReadLine(); + switch (a) + { + case "1": + return " 剪刀"; + case "2": + return " 石头"; + case "3": + return " 布"; + default: + Console.WriteLine("选择错误,请重新输入!"); + continue; + } + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\277\252\345\212\233\344\272\232\345\260\224/Way.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\277\252\345\212\233\344\272\232\345\260\224/Way.cs" new file mode 100644 index 0000000000000000000000000000000000000000..06fa27635116cbfae7c849c79b79256a0824d3d0 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\350\277\252\345\212\233\344\272\232\345\260\224/Way.cs" @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Way:Person + { + public Way() + { + + } + public Way(string name) : base(name) + { + + } + public override string Action() + { + Random random = new Random(); + int num = random.Next(1, 4); + switch (num) + { + case 1: + return "剪刀"; + case 2: + return "石头"; + case 3: + return "布"; + } + return ""; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\202\261\346\236\227\346\236\253/Npc.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\202\261\346\236\227\346\236\253/Npc.cs" new file mode 100644 index 0000000000000000000000000000000000000000..7f1c736cce053c2f3f55f8d24817ba249d406b51 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\202\261\346\236\227\346\236\253/Npc.cs" @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace demo9 +{ + class Npc + { + private string name; + + public string Name { get => name; set => name = value; } + + public void NpcName() + { + Console.WriteLine("请选择对方角色:1、刘备2、孙权 3、曹操"); + int enemy = int.Parse(Console.ReadLine()); + + switch (enemy) + { + case 1: + name = "刘备"; + break; + case 2: + name = "孙权"; + break; + case 3: + name = "曹操"; + break; + } + Console.WriteLine("我是{0},不落青云,不斩无名,问君其名:",name); + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\202\261\346\236\227\346\236\253/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\202\261\346\236\227\346\236\253/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..d03960d771d38c8c11f7eadcac2dcb685d81d2e5 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\202\261\346\236\227\346\236\253/Program.cs" @@ -0,0 +1,94 @@ +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("游戏规则:1、剪刀 2、石头 3、布"); + Npc d = new Npc(); + player w = new player(); + mora m = new mora(); + while (true) + { + bool Q = true; + d.NpcName(); + w.PlayerName(); + Console.WriteLine("{0} vs {1}", w.Name, d.Name); + Console.WriteLine("要开始对局吗?(y/n)"); + string yn = Console.ReadLine(); + switch (yn) + { + case "y": + m.morap(); + m.moran(); + Console.WriteLine("{0}: 出招:{1}", w.Name, m.PlayerMora); + Console.WriteLine("{0}: 出招:{1}", d.Name, m.NPCMora); + m.tend(); + while (Q) + { + int record = 0; + record++; + Console.WriteLine("是否开始下一轮?(y/n)"); + string q = Console.ReadLine(); + switch (q) + { + case "y": + m.morap(); + m.moran(); + Console.WriteLine("{0}: 出招:{1}", w.Name, m.PlayerMora); + Console.WriteLine("{0}: 出招:{1}", d.Name, m.NPCMora); + m.tend(); + break; + case "n": + Console.WriteLine("====================================="); + Console.WriteLine("{0} vs {1}", w.Name, d.Name); + Console.WriteLine("对战次数:" + record); + Console.WriteLine("姓名\t得分 "); + Console.WriteLine("{0}\t{1}", w.Name, m.Win1); + Console.WriteLine("{0}\t{1}", d.Name, m.Defeat1); + if (m.Win1 > m.Defeat1) + { + Console.WriteLine("结果:{0}赢,{1}不行不行", w.Name, d.Name); + } + else if (m.Win1 < m.Defeat1) + { + Console.WriteLine("结果:{0}赢,{1}不行不行", d.Name, w.Name); + } + else if (m.Win1 == m.Defeat1) + { + Console.WriteLine("结果:平局"); + } + Q = false; + break; + } + } + break; + case "n": + Console.WriteLine("不玩你进来干嘛???"); + break; + } + Console.WriteLine("是否开始下一局?(y/n)"); + string u = Console.ReadLine(); + if (u == "y") + { + continue; + } + else if (u == "n") + { + Console.WriteLine("游戏结束!"); + break; + } + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\202\261\346\236\227\346\236\253/mora.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\202\261\346\236\227\346\236\253/mora.cs" new file mode 100644 index 0000000000000000000000000000000000000000..d150ec608f15565a807692a0ca26a16a686479ab --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\202\261\346\236\227\346\236\253/mora.cs" @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace demo9 +{ + class mora + { + private string playerMora; + private string nPCMora; + private int Win = 0; + private int Defeat = 0; + private int a; + private int b; + + public string PlayerMora { get => playerMora; set => playerMora = value; } + public string NPCMora { get => nPCMora; set => nPCMora = value; } + public int Win1 { get => Win; set => Win = value; } + public int Defeat1 { get => Defeat; set => Defeat = value; } + public int A { get => a; set => a = value; } + public int B { get => b; set => b = value; } + + public void morap() + { + Console.WriteLine("请出拳:1.石头 2.剪刀 3.布"); + int A = int.Parse(Console.ReadLine()); + + switch (A) + { + case 1: + playerMora = "石头"; + break; + case 2: + playerMora = "剪刀"; + break; + case 3: + playerMora = "布"; + break; + } + } + + public void moran() + { + Random ra = new Random(); + B = ra.Next(1, 4); + + switch (B) + { + case 1: + playerMora = "石头"; + break; + case 2: + playerMora = "剪刀"; + break; + case 3: + playerMora = "布"; + break; + } + } + + public void tend() + { + if (A == B) + { + Console.WriteLine("和局?那就看下一把吧QWQ"); + } + else if (A ==1 && B ==3 || A == 2 && B == 1 || A == 3 && B == 2 ) + { + Console.WriteLine("可恶,被你赢了QWQ"); + Win1++; + } + else if (B == 1 && A == 3 || B == 2 && A == 1 || B == 3 && A == 2) + { + Console.WriteLine("输了QAQ"); + Defeat1++; + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\202\261\346\236\227\346\236\253/player.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\202\261\346\236\227\346\236\253/player.cs" new file mode 100644 index 0000000000000000000000000000000000000000..a283d36d7eebf56966677777b8c4bedb4e4637d1 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\202\261\346\236\227\346\236\253/player.cs" @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace demo9 +{ + class player + { + private string name; + + public string Name { get => name; set => name = value; } + + public void PlayerName() + { + name = Console.ReadLine(); + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\203\255\346\214\257\347\201\277/.keep" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\203\255\346\214\257\347\201\277/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\203\255\346\214\257\347\201\277/All.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\203\255\346\214\257\347\201\277/All.cs" new file mode 100644 index 0000000000000000000000000000000000000000..25ecdc8fcb0d46449e675655959186235a012e73 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\203\255\346\214\257\347\201\277/All.cs" @@ -0,0 +1,25 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class All:PK + { + public string name; + public string Name + { + get { return this.name; } + set { this.name = value; } + } + public All() { } + public All(string name) + { + this.name = name; + } + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\203\255\346\214\257\347\201\277/Judge.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\203\255\346\214\257\347\201\277/Judge.cs" new file mode 100644 index 0000000000000000000000000000000000000000..9ae643353da8c2342c3545ab3a8eb57727c58d3f --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\203\255\346\214\257\347\201\277/Judge.cs" @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Judge + { + public void Determine(int p1, int p2) + { + //1剪刀 2石头 3布 + //1 3 1-3=-2 在玩家出1剪刀的情况下,计算机出3布,玩家赢 + //2 1 2-1=1 在玩家出2石头的情况下,计算机出1剪刀,玩家赢 + //3 2 3-2=1 在玩家出3布的情况下,计算机出2石头,玩家赢 + if (p1 - p2 == -2 || p1 - p2 == 1) + { + Console.WriteLine("恭喜,赢了!"); + } + else if (p1 == p2) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + else + { + Console.WriteLine("笨蛋,输了!"); + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\203\255\346\214\257\347\201\277/PK.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\203\255\346\214\257\347\201\277/PK.cs" new file mode 100644 index 0000000000000000000000000000000000000000..e491de28f615a192489f65be6cdb8e4e52a0d2ed --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\203\255\346\214\257\347\201\277/PK.cs" @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class PK:Program + { + public static Random ran = new Random(); + public string[] q = { "", "剪刀", "石头", "布" }; + public virtual void PKinfo() + { + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\203\255\346\214\257\347\201\277/Player.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\203\255\346\214\257\347\201\277/Player.cs" new file mode 100644 index 0000000000000000000000000000000000000000..2b6075a8c0b6bbb0ce78e026ad0f6470eabe2deb --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\203\255\346\214\257\347\201\277/Player.cs" @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp2 +{ + class Player : PK + { + + private string name; + public string Name + { + get { return this.name; } + set { this.name = value; } + } + public Player(string name) + { + this.name = name; + } + public override void PKinfo() + { + base.PKinfo(); + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\203\255\346\214\257\347\201\277/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\203\255\346\214\257\347\201\277/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..cef77a1b7f918d7aaa14951f9a7598916fd65ee0 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\203\255\346\214\257\347\201\277/Program.cs" @@ -0,0 +1,32 @@ +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) + { + Dictionary list = new Dictionary(); + Random ran = new Random(); + Console.WriteLine("------------欢迎进入游戏世界------------"); + Console.WriteLine("***************************"); + Console.WriteLine("*********猜拳,开始*********"); + Console.WriteLine("***************************"); + Console.WriteLine("出拳规则:1.剪刀,2.石头,3.布"); + while (true) + { + Console.WriteLine("请选择对方角色:1.刘备 2.孙权 3.曹操"); + int a = int.Parse(Console.ReadLine()); + Console.WriteLine("请输入你的姓名:"); + Player p = new Player(Console.ReadLine()); + Console.WriteLine(p.Name + " VS " + a); + Computer c = new Computer(); + c.go(p.Name, a); + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\230\256\345\273\272\351\234\226/GameSystem.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\230\256\345\273\272\351\234\226/GameSystem.cs" new file mode 100644 index 0000000000000000000000000000000000000000..f4a821a5d98f79874b2ce8b14b7645c08ca0e39a --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\230\256\345\273\272\351\234\226/GameSystem.cs" @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo01 +{ + class GameSystem + { + public bool Gaming(Hero hero, Users users) + { + int sum = 0; + int hNum = 0; + int uNum = 0; + while (true) + { + string heroAction; + string userAction; + userAction = users.Action(); + Console.WriteLine(users.Name + ": 出拳: " + userAction); + heroAction = hero.Action(); + Console.WriteLine(hero.Name + ": 出拳: " + heroAction); + Console.WriteLine(IsWin(heroAction, userAction, users.Name, ref hNum, ref uNum)); + sum++; + while (true) + { + Console.WriteLine("是否开始下一轮?(1.继续/0.停止)"); + string chioce = Console.ReadLine(); + if (chioce == "1") + { + break; + } + else if (chioce == "0") + { + return EndGame(hero.Name, users.Name, sum, hNum, uNum); + } + else + { + Console.WriteLine("输入错误,请重新输入"); + continue; + } + } + } + } + + private bool EndGame(string heroName, string userName, int sum, int hNum, int uNum) + { + Console.WriteLine("==================================="); + Console.WriteLine("对战次数:" + sum); + + Console.WriteLine("姓名\t得分"); + Console.WriteLine(heroName + "\t" + hNum); + Console.WriteLine(userName + "\t" + uNum); + if (hNum > uNum) + { + Console.WriteLine($"{heroName}赢了,{userName}输了"); + } + else if (hNum < uNum) + { + Console.WriteLine($"{userName}赢了,{heroName}输了"); + } + else + { + Console.WriteLine("平局"); + } + while (true) + { + Console.WriteLine("要开始下一局吗?(y/n)"); + string chioce = Console.ReadLine(); + switch (chioce) + { + case "y": + return true; + case "n": + return false; + default: + Console.WriteLine("选择错误,请重新输入"); + continue; + } + } + } + + public string IsWin(string A, string B, string name, ref int hNum, ref int uNum) + { + string str; + if ((A == "剪刀" && B == "布") || (A == "石头" && B == "剪刀") || A == "布" && B == "石头") + { + hNum++; + str = "赢"; + } + else if (A == B) + { + + str = "平局"; + } + else + { + uNum++; + str = "输"; + } + if (str == "赢") + { + return $"笨蛋,{name}输了"; + + } + else if (str == "输") + { + return $"恭喜,{name}赢了"; + } + else + { + return "平局,再来"; + } + + } + } + } diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\230\256\345\273\272\351\234\226/Hero.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\230\256\345\273\272\351\234\226/Hero.cs" new file mode 100644 index 0000000000000000000000000000000000000000..7cde214c22144e1d13cea94b7aa1d570c8a9b2e3 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\230\256\345\273\272\351\234\226/Hero.cs" @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo01 +{ + class Hero:Person + { + public Hero() + { + } + + public Hero(string name) : base(name) + { + + } + public void HeroCreate() + { + while (true) + { + Console.WriteLine("请选择对方角色<1.刘备 2.孙权 3.曹操>"); + Console.Write("请选择:"); + string chioce = Console.ReadLine(); + switch (chioce) + { + case "1": + this.Name = "刘备"; + return; + case "2": + this.Name = "孙权"; + return; + case "3": + this.Name = "曹操"; + return; + default: + Console.WriteLine("选择错误,请重新输入"); + continue; + } + } + } + + public override string Action() + { + Random rd = new Random(); + int num = rd.Next(1, 4); + switch (num) + { + case 1: + return "剪刀"; + case 2: + return "石头"; + case 3: + return "布"; + } + return ""; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\230\256\345\273\272\351\234\226/Person.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\230\256\345\273\272\351\234\226/Person.cs" new file mode 100644 index 0000000000000000000000000000000000000000..d9ca448a0c94852ae11a593b6f92670045c21b75 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\230\256\345\273\272\351\234\226/Person.cs" @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo01 +{ + class Person + { + public string Name { get; set; } + + public Person() + { + } + + public Person(string name) + { + Name = name; + } + + public virtual string Action() + { + return null; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\230\256\345\273\272\351\234\226/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\230\256\345\273\272\351\234\226/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..22909272e4421b40b6750627ab7f706245871e68 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\230\256\345\273\272\351\234\226/Program.cs" @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo01 +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("-----------欢 迎 进 入 游 戏 世 界------------"); + while (true) + { + Console.WriteLine("****************************"); + Console.WriteLine("**********猜拳开始**********"); + Console.WriteLine("****************************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Users users = UsersCreate(); + Hero hero = new Hero(); + hero.HeroCreate(); + + bool IsStart = Start(); + if (!IsStart) + { + Console.WriteLine("系统退出"); + return; + } + else + { + Console.WriteLine(users.Name + " VS " + hero.Name+ " 对战"); + } + GameSystem game = new GameSystem(); + bool IsConutinue = game.Gaming(hero, users); + if (!IsConutinue) + { + Console.WriteLine("系统退出"); + return; + } + } + + + + + } + + private static Users UsersCreate() + { + + Console.WriteLine("请输入您的姓名"); + string usersName = Console.ReadLine(); + return new Users(usersName); + } + + private static bool Start() + { + while (true) + { + Console.WriteLine("开始游戏吗?(y/n)"); + string chioce = Console.ReadLine(); + switch (chioce) + { + case "y": + return true; + case "n": + return false; + default: + Console.WriteLine("选择错误,请重新输入"); + continue; + } + } + } + } +} \ No newline at end of file diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\230\256\345\273\272\351\234\226/Users.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\230\256\345\273\272\351\234\226/Users.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b6061eaf9b9e2146f72110c62dfc266a4a4457f3 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\230\256\345\273\272\351\234\226/Users.cs" @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo01 +{ + class Users:Person + { + public Users() + { + + } + public Users(string name) : base(name) + { + + } + + public override string Action() + { + while (true) + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应数字)"); + string chioce = Console.ReadLine(); + switch (chioce) + { + case "1": + return "剪刀"; + case "2": + return "石头"; + case "3": + return "布"; + default: + Console.WriteLine("选择错误,请重新输入"); + continue; + } + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\231\210\345\256\207\347\277\224/GameSystem.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\231\210\345\256\207\347\277\224/GameSystem.cs" new file mode 100644 index 0000000000000000000000000000000000000000..482cf1c0a9c72d0d4822b868735eb661e1a6ed00 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\231\210\345\256\207\347\277\224/GameSystem.cs" @@ -0,0 +1,140 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class GameSystem + { + public bool Gaming(Hero hero, User user) { + int sum = 0; + int hNum = 0; + int uNum = 0; + while (true) + { + string heroAction; + string userAction; + userAction = user.Action(); + Console.WriteLine(user.Name + ": 出拳: " + userAction); + heroAction = hero.Action(); + Console.WriteLine(hero.Name + ": 出拳: " + heroAction); + Console.WriteLine(IsWin(heroAction, userAction, user.Name, ref hNum, ref uNum)); + sum++; + while (true) + { + Console.WriteLine("是否开始下一轮?(1.继续/0.停止)"); + string chioce = Console.ReadLine(); + if (chioce=="1") + { + break; + } + else if (chioce == "0") + { + return EndGame(hero.Name, user.Name, sum, hNum, uNum); + } + else + { + Console.WriteLine("输入错误,请重新输入"); + continue; + } + } + } + } + + private bool EndGame(string heroName, string userName, int sum, int hNum, int uNum) + { + Console.WriteLine("==================================="); + Console.WriteLine("对战次数:"+ sum); + + Console.WriteLine("姓名\t得分"); + Console.WriteLine(heroName+"\t"+ hNum); + Console.WriteLine(userName + "\t"+ uNum); + if (hNum > uNum) + { + Console.WriteLine($"{heroName}赢了,{userName}输了"); + } + else if (hNum < uNum) + { + Console.WriteLine($"{userName}赢了,{heroName}输了"); + } + else { + Console.WriteLine("平局"); + } + while (true) + { + Console.WriteLine("要开始下一局吗?(y/n)"); + string chioce = Console.ReadLine(); + switch (chioce) + { + case "y": + return true; + case "n": + return false; + default: + Console.WriteLine("选择错误,请重新输入"); + continue; + } + } + } + + public string IsWin(string A, string B,string name,ref int hNum, ref int uNum) { + string str; + if ((A == "剪刀" && B == "布")||(A == "石头" && B == "剪刀")|| A == "布" && B == "石头") + { + hNum++; + str = "赢"; + } + else if (A==B) + { + + str = "平局"; + } + else + { + uNum++; + str = "输"; + } + if (str == "赢") + { + return $"笨蛋,{name}输了"; + + } + else if (str == "输") + { + return $"恭喜,{name}赢了"; + } + else { + return "平局,再来"; + } + +/* else if (A == "石头" && B == "剪刀") + { + if () + { + hNum++; + return $"笨蛋,{name}输了"; + } + else if (B == "布") + { + uNum++; + return $"恭喜,{name}赢了"; + } + } + else if (A == "布" && B == "剪刀") + { + uNum++; + return $"恭喜,{name}赢了"; + } + else if (A == "布" && B == "石头") + { + hNum++; + return $"笨蛋,{name}输了"; + } + else*/ + + } + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\231\210\345\256\207\347\277\224/Hero.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\231\210\345\256\207\347\277\224/Hero.cs" new file mode 100644 index 0000000000000000000000000000000000000000..97a3ca4d022dbbcb1b21893bc731cab723ca9a8c --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\231\210\345\256\207\347\277\224/Hero.cs" @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Hero : Person + { + public Hero() + { + } + + public Hero(string name) : base(name) + { + } + + public override string Action() + { + Random rd = new Random(); + int num = rd.Next(1, 4); + switch (num) + { + case 1: + return "剪刀"; + case 2: + return "石头"; + case 3: + return "布"; + } + return ""; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\231\210\345\256\207\347\277\224/Person.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\231\210\345\256\207\347\277\224/Person.cs" new file mode 100644 index 0000000000000000000000000000000000000000..8cd8fbae87867bb106ce8fb540f769fca7f7070a --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\231\210\345\256\207\347\277\224/Person.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Person + { + public string Name { get; set; } + + public Person() + { + } + + public Person(string name) + { + Name = name; + } + + public virtual string Action() { + return null; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\231\210\345\256\207\347\277\224/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\231\210\345\256\207\347\277\224/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..7d9f26216a7831dab96c938d101e7149c4abfd3c --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\231\210\345\256\207\347\277\224/Program.cs" @@ -0,0 +1,91 @@ +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("-------欢 迎 进 入 游 戏 世 界-------"); + while (true) + { + Console.WriteLine("*******************************"); + Console.WriteLine("**********猜拳,开始***********"); + Console.WriteLine("*******************************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + Hero hero = HeroCreate(); + User user = UserCreate(); + bool IsStart = Start(); + if (!IsStart) + { + Console.WriteLine("系统退出"); + return; + } + else + { + Console.WriteLine(hero.Name + " VS " + user.Name + " 对战"); + } + + GameSystem gm = new GameSystem(); + bool IsConutinue = gm.Gaming(hero, user); + if (!IsConutinue) + { + Console.WriteLine("系统退出"); + return; + } + } + } + + public static bool Start() + { + while (true) + { + Console.WriteLine("开始游戏吗?(y/n)"); + string chioce = Console.ReadLine(); + switch (chioce) + { + case "y": + return true; + case "n": + return false; + default: + Console.WriteLine("选择错误,请重新输入"); + continue; + } + } + } + public static Hero HeroCreate() + { + while (true) + { + Console.WriteLine("请选择对方角色<1.刘备 2.孙权 3.曹操>"); + Console.Write("请选择:"); + string chioce = Console.ReadLine(); + switch (chioce) + { + case "1": + return new Hero("刘备"); + case "2": + return new Hero("孙权"); + case "3": + return new Hero("曹操"); + default: + Console.WriteLine("选择错误,请重新输入"); + continue; + } + } + } + public static User UserCreate() + { + + Console.WriteLine("请输入您的姓名"); + string userName = Console.ReadLine(); + return new User(userName); + } + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\231\210\345\256\207\347\277\224/User.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\231\210\345\256\207\347\277\224/User.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b003d8d38748cb77a70be111784eddbfd5c4e051 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\231\210\345\256\207\347\277\224/User.cs" @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class User : Person + { + public User() + { + } + + public User(string name) : base(name) + { + } + + public override string Action() + { + while (true) + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应数字)"); + string chioce = Console.ReadLine(); + switch (chioce) + { + case "1": + return "剪刀"; + case "2": + return "石头"; + case "3": + return "布"; + default: + Console.WriteLine("选择错误,请重新输入"); + continue; + } + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\231\210\346\200\235\351\224\220/.keep" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\231\210\346\200\235\351\224\220/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\231\210\346\200\235\351\224\220/punch.zip" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\231\210\346\200\235\351\224\220/punch.zip" new file mode 100644 index 0000000000000000000000000000000000000000..2069d71b23a57383350a0f2854c1d8c3d7117477 Binary files /dev/null and "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\231\210\346\200\235\351\224\220/punch.zip" differ diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\231\210\350\277\233\345\220\211/.keep" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\231\210\350\277\233\345\220\211/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\231\210\350\277\233\345\220\211/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\231\210\350\277\233\345\220\211/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..bc894fdb25af1ddb220f1ad25d3961e9f471ae3c --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\231\210\350\277\233\345\220\211/Program.cs" @@ -0,0 +1,202 @@ +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) + { + int playscore = 0; + int compsocre = 0; + int count = 0; + + Game g1 = new Game("剪刀"); + Game g2 = new Game("石头"); + Game g3 = new Game("布"); + List games = new List() { g1, g2, g3 }; + + Competitor competitor1 = new Competitor(); + Gameplayer gameplayer1 = new Gameplayer(); + + Console.WriteLine("请选择对方角色<1.刘备 2.孙权 3.曹操>"); + int key2 = int.Parse(Console.ReadLine()); + Console.WriteLine("请输入你的姓名"); + gameplayer1.Name = Console.ReadLine(); + + switch (key2) + { + case 1: + competitor1.Name = "刘备"; + break; + case 2: + competitor1.Name = "孙权"; + break; + case 3: + competitor1.Name = "曹操"; + break; + } + Console.WriteLine("开始游戏吗?"); + string key = Console.ReadLine(); + while (true) + { + while (key.Equals("y", StringComparison.OrdinalIgnoreCase)) + { + + Console.WriteLine($"{gameplayer1.Name} VS {competitor1.Name}"); + + Random ran = new Random(); + int a = ran.Next(0, 3); + Console.WriteLine("请出拳:1.剪刀,2.石头,3.布(请输入相应数字:)"); + int key1 = int.Parse(Console.ReadLine()); + switch (key1) + { + case 1: + if (!(key1 - 1 == a)) + { + Console.WriteLine($"{gameplayer1.Name}:出:{games[key1 - 1]}\n{competitor1.Name}:出:{games[a]}"); + + if (games[a].A.Equals("石头")) + { + count++; + compsocre++; + Console.WriteLine($"笨蛋 ,{gameplayer1.Name}输了"); + } + if (games[a].A.Equals("布")) + { + count++; + playscore++; + Console.WriteLine($"恭喜 ,{gameplayer1.Name}赢了"); + } + } + else + { + count++; + Console.WriteLine($"{gameplayer1.Name}:出:{games[key1 - 1]}\n{competitor1.Name}:出:{games[a]}"); + + Console.WriteLine("平局"); + } + + break; + case 2: + if (!(key1 - 1 == a)) + { + if (games[a].A.Equals("布")) + { + count++; + compsocre++; + Console.WriteLine($"笨蛋 ,{gameplayer1.Name}输了"); + } + if (games[a].A.Equals("剪刀")) + { + count++; + playscore++; + Console.WriteLine($"恭喜 ,{gameplayer1.Name}赢了"); + } + } + else + { + count++; + Console.WriteLine($"{gameplayer1.Name}:出:{games[key1 - 1]}\n{competitor1.Name}:出:{games[a]}"); + + Console.WriteLine("平局"); + } + break; + case 3: + + if (!(key1 - 1 == a)) + { + if (games[a].A.Equals("剪刀")) + { + count++; + compsocre++; + Console.WriteLine($"笨蛋 ,{gameplayer1.Name}输了"); + } + if (games[a].A.Equals("石头")) + { + count++; + playscore++; + Console.WriteLine($"恭喜 ,{gameplayer1.Name}赢了"); + } + } + else + { + count++; + Console.WriteLine($"{gameplayer1.Name}:出:{games[key1 - 1]}\n{competitor1.Name}:出:{games[a]}"); + + Console.WriteLine("平局"); + } + break; + } + + Console.WriteLine("是否进行下一轮:"); + string b = Console.ReadLine(); + if (b == "Y" || b == "y") + { + } + else if (b == "n" || b == "N") + { + Console.WriteLine($"{gameplayer1.Name} VS {competitor1.Name}"); + Console.WriteLine($"对战次数:{count}\n\n姓名\t得分\n{gameplayer1.Name}\t{playscore}\n{competitor1.Name}\t{compsocre}"); + if (playscore > compsocre) + { + Console.WriteLine($"结果:{gameplayer1.Name}赢了,{competitor1.Name}输了"); + } + else if(playscore"); + key = Console.ReadLine(); + if (key.Equals("n",StringComparison.OrdinalIgnoreCase)) + { + Console.WriteLine("系统退出!!!"); + } + } + } + } + class Competitor + { + private string name; + + public string Name { get => name; set => name = value; } + } + class Gameplayer + { + private string name; + + public string Name { get => name; set => name = value; } + } + class Game + { + private string a; + + public Game(string a) + { + this.a = a; + } + + public string A { get => a; set => a = value; } + public override string ToString() + { + return $"{a}"; + } + } + +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/.keep" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/Judgment.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/Judgment.cs" new file mode 100644 index 0000000000000000000000000000000000000000..641fd20fe281f2d2a82ddfcc2babe95bf2118e14 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/Judgment.cs" @@ -0,0 +1,159 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Judgment + { + public static void Test() + { + //接对方角色名 + string ing = "未命名"; + Boolean tr = true; + while (tr) + { + Console.WriteLine("请选择对方角色<1.刘备 2.孙权 3.曹操>"); + int key = int.Parse(Console.ReadLine()); + switch (key) + { + case 1: + ing = "刘备"; + tr = false; + break; + case 2: + ing = "孙权"; + tr = false; + break; + case 3: + ing = "曹操"; + tr = false; + break; + default: + Console.WriteLine("输入错误,请重新输入!"); + break; + } + } + Opposite oppo = new Opposite(ing); + //游戏次数 + int z = 0; + //刘备赢多少 + int g = 0; + //我赢的次数 + int t = 0; + Console.WriteLine("请输入您的姓名"); + string Name = Console.ReadLine(); + Oneself oneself = new Oneself(Name); + oneself.Test01(); + Console.WriteLine("开始游戏吗?"); + string k = Console.ReadLine(); + Boolean n = true; + while (n) + { + switch (k) + { + case "y": + z++; + Console.WriteLine(); + int e = 0; + while (true) + { + try + { + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布"); + e = int.Parse(Console.ReadLine()); + oneself.Test03(e); + break; + } + catch (Exception) + { + Console.WriteLine("输入错误,请重新输入"); + } + } + oneself.Test(); + int a = Opposite.Test01(); + oppo.Test(); + if (a == e) + { + Console.WriteLine("和局,真衰!嘿嘿,等着瞧吧!"); + } + else if ((e == 1 && a == 3) || (e == 2 && a == 1) || (e == 3 && a == 2)) + { + Console.WriteLine("恭喜,{0}赢了", oneself.name); + t++; + } + else + { + Console.WriteLine("笨蛋,{0}输了", oneself.name); + g++; + } + Console.WriteLine("是否开始下一轮比赛"); + string q = Console.ReadLine(); + switch (q) + { + case "y": + n = true; + break; + case "n": + n = false; + Console.WriteLine("==============================================="); + oneself.Test01(); + Console.WriteLine("对战次数:{0}", z); + + Console.WriteLine(); + Console.WriteLine("姓名\t得分"); + Console.WriteLine("{0} \t{1}", oneself.name, t); + Console.WriteLine("{0} \t{1}", Opposite.Name, g); + if (t == g) + { + Console.WriteLine("平局,{0},{1},两个笨蛋",oppo.name,oneself.name); + } + else if (t > g) + { + Console.WriteLine("{0}赢,{1}笨蛋", oneself.name, Opposite.Name); + } + else if (t < g) + { + Console.WriteLine("{0}赢,{1}笨蛋", Opposite.Name, oneself.name); + } + Console.WriteLine("要进行下一局比赛吗?"); + string ke = Console.ReadLine(); + switch (ke) + { + case "y": + n = true; + z = 0; + g = 0; + t = 0; + break; + case "n": + Console.WriteLine("系统退出"); + n = false; + break; + default: + break; + } + break; + default: + Console.WriteLine("输入错误,请重新输入!"); + Console.WriteLine("是否开始下一轮比赛"); + q = Console.ReadLine(); + break; + } + break; + case "n": + Console.WriteLine("系统退出"); + n = false; + break; + default: + Console.WriteLine("输入错误,请重新输入!"); + Console.WriteLine("开始游戏吗?"); + k = Console.ReadLine(); + break; + } + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/Oneself.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/Oneself.cs" new file mode 100644 index 0000000000000000000000000000000000000000..5050a81ffe507ab63327fdebf3d5ee2324341c2b --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/Oneself.cs" @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Oneself : Person + { + public string name { get; set; } + public static string chu { get; set; } + public Oneself(string name) + { + this.name = name; + } + public void Test01() + { + Console.WriteLine("{0} vs {1} 对战", Name, this.name); + } + + public void Test03(int key) + { + + switch (key) + { + case 1: + chu = "剪刀"; + break; + case 2: + chu = "石头"; + break; + case 3: + chu = "布"; + break; + default: + break; + } + } + public override void Test() + { + Console.WriteLine("{0}:出拳:{1}", name, chu); + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/Opposite.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/Opposite.cs" new file mode 100644 index 0000000000000000000000000000000000000000..9f572ac6cf8d315c2016e0a34e3cc399330406a1 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/Opposite.cs" @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Opposite : Person + { + public string name { get; set; } + public static string a { get; set; } + public Opposite(string name) + { + this.name = name; + Name = name; + } + public static int Test01() + { + Random ran = new Random(); + int key = ran.Next(3) + 1; + switch (key) + { + case 1: + a = "剪刀"; + break; + case 2: + a = "石头"; + break; + case 3: + a = "布"; + break; + default: + break; + } + return key; + } + public override void Test() + { + Console.WriteLine("{0}:出拳:{1}", name, a); + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/Person.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/Person.cs" new file mode 100644 index 0000000000000000000000000000000000000000..f87b5cfcd4634874dbf27823863f5457d9e60f13 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/Person.cs" @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + abstract class Person + { + public static string Name { get; set; } + public abstract void Test(); + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/Program(2).cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/Program(2).cs" new file mode 100644 index 0000000000000000000000000000000000000000..c21cb75e930bd88dc789498cd17842491065c704 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/Program(2).cs" @@ -0,0 +1,260 @@ +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) + { + Boolean a = true; + while (a) + { + Console.WriteLine(); + Console.WriteLine("1.录入成绩 2.银行 3.退出"); + int key = int.Parse(Console.ReadLine()); + switch (key) + { + case 1: + Test01(); + break; + case 2: + Test02(); + break; + case 3: + a = false; + break; + default: + Console.WriteLine("输入错误,请重新输入"); + break; + } + } + } + public static void Test01() + { + Console.WriteLine("请输入学生数"); + int a = int.Parse(Console.ReadLine()); + float[] arr = new float[a]; + Boolean b = false; + for (int i = 0; i < arr.Length; i++) + { + b = false; + try + { + Console.WriteLine("请输入第{0}个学生的成绩", (i + 1)); + arr[i] = float.Parse(Console.ReadLine()); + } + catch (FormatException e) + { + Console.WriteLine(e.Message); + Console.WriteLine(e.Source); + Console.WriteLine(e.StackTrace); + b = true; + } + catch (OverflowException e) + { + Console.WriteLine(e.Message); + Console.WriteLine(e.Source); + Console.WriteLine(e.StackTrace); + b = true; + } + catch (Exception e) + { + Console.WriteLine(e.Message); + Console.WriteLine(e.Source); + Console.WriteLine(e.StackTrace); + b = true; + } + finally + { + Console.WriteLine("第{0}个学生的成绩录完", (i + 1)); + Console.WriteLine(); + } + Boolean o = true; + while (o) + { + o = false; + if (b) + { + b = false; + try + { + Console.WriteLine(); + Console.WriteLine("请输入重新第{0}个学生的成绩", (i + 1)); + arr[i] = float.Parse(Console.ReadLine()); + } + catch (FormatException e) + { + Console.WriteLine(e.Message); + Console.WriteLine(e.Source); + Console.WriteLine(e.StackTrace); + b = true; + o = true; + } + catch (OverflowException e) + { + Console.WriteLine(e.Message); + Console.WriteLine(e.Source); + Console.WriteLine(e.StackTrace); + b = true; + o = true; + } + catch (Exception e) + { + Console.WriteLine(e.Message); + Console.WriteLine(e.Source); + Console.WriteLine(e.StackTrace); + b = true; + o = true; + } + } + } + + } + float sum = 0; + for (int i = 0; i < arr.Length; i++) + { + sum += arr[i]; + } + float age = sum / a; + Console.WriteLine("总学生数为{0},总分数为{1},平均分为{2}", a, sum, age); + } + public static void Test02() + { + //存放在银行账户中的余额 + double a = 100000000.00; + //用户想要从银行账户中提取的金额 + double b = 0; + Boolean f = false; + Boolean p = true; + while (p) + { + Console.WriteLine("请选择功能:1、存款,2、取款 3、退出"); + int key = int.Parse(Console.ReadLine()); + switch (key) + { + case 1: + Console.WriteLine("请输入存款的金额"); + try + { + double c = double.Parse(Console.ReadLine()); + a += c; + } + catch (FormatException e) + { + Console.WriteLine(e.Message); + Console.WriteLine(e.Source); + Console.WriteLine(e.StackTrace); + f = true; + } + Boolean o = true; + while (o) + { + o = false; + if (f) + { + f = false; + Console.WriteLine(); + Console.WriteLine("请输入重新存款的金额"); + try + { + double c = double.Parse(Console.ReadLine()); + a += c; + } + catch (FormatException e) + { + Console.WriteLine(e.Message); + Console.WriteLine(e.Source); + Console.WriteLine(e.StackTrace); + f = true; + o = true; + } + catch (Exception e) + { + Console.WriteLine(e.Message); + Console.WriteLine(e.Source); + Console.WriteLine(e.StackTrace); + f = true; + o = true; + } + } + else + { + Console.WriteLine("余额为{0}", a); + } + } + + + break; + case 2: + Console.WriteLine("请输入取款的金额"); + try + { + b = double.Parse(Console.ReadLine()); + if (b > a) + { + throw new ArgumentOutOfRangeException(); + } + } + catch (OverflowException e) + { + Console.WriteLine(e.Message); + Console.WriteLine(e.Source); + Console.WriteLine(e.StackTrace); + f = true; + } + Boolean l = true; + while (l) + { + l = false; + if (f) + { + f = false; + Console.WriteLine(); + Console.WriteLine("请重新输入取款的金额"); + try + { + b = double.Parse(Console.ReadLine()); + if (b > a) + { + throw new ArgumentOutOfRangeException(); + } + } + catch (OverflowException e) + { + Console.WriteLine(e.Message); + Console.WriteLine(e.Source); + Console.WriteLine(e.StackTrace); + f = true; + l = true; + } + catch (Exception e) + { + Console.WriteLine(e.Message); + Console.WriteLine(e.Source); + Console.WriteLine(e.StackTrace); + f = true; + l = true; + } + } + else + { + a = a - b; + Console.WriteLine("余额为{0}", a); + } + } + break; + case 3: + p = false; + break; + default: + Console.WriteLine("输入错误,请重新输入"); + break; + } + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..db67e90854b6d93ab3e379965deabd658bc9f3ff --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/Program.cs" @@ -0,0 +1,25 @@ +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.布"); + Judgment.Test(); + + Console.ReadKey(); + } + } + +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\347\237\263\345\244\264\345\211\252\345\210\200\345\270\203.jpg" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\347\237\263\345\244\264\345\211\252\345\210\200\345\270\203.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..47251d59e05031453447a269c484dcddc947911c Binary files /dev/null and "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\347\237\263\345\244\264\345\211\252\345\210\200\345\270\203.jpg" differ diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\251\267\350\212\263/.keep" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\251\267\350\212\263/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\251\267\350\212\263/14/Game.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\251\267\350\212\263/14/Game.cs" new file mode 100644 index 0000000000000000000000000000000000000000..5f7f0848ce82469254e1ec9203bf0ef18c5e4fc5 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\251\267\350\212\263/14/Game.cs" @@ -0,0 +1,106 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Game + { + internal bool Gaming(Hero hero, User user) + { + int sum = 0, hNum = 0, uNum = 0; + while (true) + { + string heroAction = hero.Action(); + string userAction = user.Action(); + Console.WriteLine($"{hero.Name}:出拳:{heroAction}"); + Console.WriteLine($"{user.Name}:出拳:{userAction}"); + sum++; + IsWin(heroAction, userAction, user.Name, ref hNum, ref uNum); + Console.WriteLine("是否开始下一轮?(1.继续/0.停止)"); + string chioce = Console.ReadLine(); + if (chioce=="0") + { + return EndGame(hero.Name,user.Name,sum,hNum,uNum); + + + } + else if (chioce=="1") + { + continue; + } + + } + + } + + private bool EndGame(string name1, string name2, int sum, int hNum, int uNum) + { + Console.WriteLine("======================================="); + Console.WriteLine($"{name1} VS {name2}"); + + Console.WriteLine($"对战次数: {sum}"); + + Console.WriteLine("姓名\t得分"); + Console.WriteLine($"{name1}\t{hNum}"); + Console.WriteLine($"{name2}\t{uNum}"); + if (hNum > uNum) + { + Console.WriteLine($"{name1}赢了,{name2}输了"); + } + else if (hNum < uNum) + { + Console.WriteLine($"{name2}赢了,{name1}输了"); + } + else { + Console.WriteLine("平局"); + } + + Console.WriteLine("要开始下一局吗?(y/n)"); + string chioce = Console.ReadLine(); + if (chioce == "y") + { + + return true; + } + else if (chioce == "n") + { + return false; + + } + return true; + } + + private void IsWin(string A, string B, string name, ref int hNum, ref int uNum) + { + string temp; + if (A == "布" && B == "石头" || A == "剪刀" && B == "布" || A == "石头" && B == "剪刀") + { + temp = "赢"; + } + else if (A == B) + { + temp = "平局"; + } + else { + temp = "输"; + } + + if (temp == "赢") + { + hNum++; + Console.WriteLine($"笨蛋,{name}输了"); + } + else if (temp == "输") + { + uNum++; + Console.WriteLine($"恭喜,{name}赢了"); + } + else { + Console.WriteLine("平局,再来"); + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\251\267\350\212\263/14/Hero.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\251\267\350\212\263/14/Hero.cs" new file mode 100644 index 0000000000000000000000000000000000000000..9c0a93095fd47c82c9d5511aac32c6ee16148e98 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\251\267\350\212\263/14/Hero.cs" @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Hero : Person + { + public Hero() + { + } + + public Hero(string name) : base(name) + { + } + public override string Action() + { + Random rd = new Random(); + int chioce = rd.Next(1, 4); + switch (chioce) + { + case 1: + return "剪刀"; + case 2: + return "石头"; + case 3: + return "布"; + } + return base.Action(); + } + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\251\267\350\212\263/14/Person.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\251\267\350\212\263/14/Person.cs" new file mode 100644 index 0000000000000000000000000000000000000000..a164d472e4d323476298952fa7c0486bc4679834 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\251\267\350\212\263/14/Person.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Person + { + public string Name { get; set; } + + public Person() + { + } + + public Person(string name) + { + Name = name; + } + + public virtual string Action() { + return null; + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\251\267\350\212\263/14/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\251\267\350\212\263/14/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..54773b3b4f1cdbfeb5f510c37c038a06ccb0f889 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\251\267\350\212\263/14/Program.cs" @@ -0,0 +1,60 @@ +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("-------欢 迎 进 入 游 戏 世 界-------"); + while (true) + { + Console.WriteLine("*******************************"); + Console.WriteLine("**********猜拳,开始***********"); + Console.WriteLine("*******************************"); + Console.WriteLine("出拳规则:1.剪刀 2.石头 3.布"); + + Console.WriteLine("请选择对方角色<1.刘备 2.孙权 3.曹操>"); + Console.Write("请选择:"); + + Hero hero = new Hero(); + string chioce = Console.ReadLine(); + switch (chioce) + { + case "1": + hero = new Hero("刘备"); + break; + case "2": + hero = new Hero("孙权"); + break; + case "3": + hero = new Hero("曹操"); + break; + } + Console.WriteLine("请输入您的姓名"); + string userName = Console.ReadLine(); + User user = new User(userName); + Console.WriteLine($"{hero.Name} VS {user.Name} 对战"); + + Console.WriteLine("开始游戏吗?(y/n)"); + string begin = Console.ReadLine(); + if (begin == "n") + { + return; + } + + Game g = new Game(); + bool v = g.Gaming(hero, user); + if (v == false) + { + return; + } + + } + } + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\251\267\350\212\263/14/User.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\251\267\350\212\263/14/User.cs" new file mode 100644 index 0000000000000000000000000000000000000000..12611fe5ac373194917e36ecdccd7a866c9c7cf3 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\251\267\350\212\263/14/User.cs" @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class User : Person + { + public User() + { + } + + public User(string name) : base(name) + { + } + public override string Action() + { + + Console.WriteLine("请出拳:1.剪刀 2.石头 3.布(输入相应数字)"); + string chioce = Console.ReadLine(); + switch (chioce) + { + case "1": + return "剪刀"; + case "2": + return "石头"; + case "3": + return "布"; + } + return base.Action(); + } + + } +} diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\274\272/Game.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\274\272/Game.cs" new file mode 100644 index 0000000000000000000000000000000000000000..717631fe9817bbff700c552ee76c2b1a8f7e478c --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\274\272/Game.cs" @@ -0,0 +1,106 @@ +?using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Game + { + internal bool Gaming(Hero hero, User user) + { + int sum = 0, hNum = 0, uNum = 0; + while (true) + { + string heroAction = hero.Action(); + string userAction = user.Action(); + Console.WriteLine($"{hero.Name}ȭ{heroAction}"); + Console.WriteLine($"{user.Name}ȭ{userAction}"); + sum++; + IsWin(heroAction, userAction, user.Name, ref hNum, ref uNum); + Console.WriteLine("Ƿʼһ֣1./0.ֹͣ"); + string chioce = Console.ReadLine(); + if (chioce=="0") + { + return EndGame(hero.Name,user.Name,sum,hNum,uNum); + + + } + else if (chioce=="1") + { + continue; + } + + } + + } + + private bool EndGame(string name1, string name2, int sum, int hNum, int uNum) + { + Console.WriteLine("======================================="); + Console.WriteLine($"{name1} VS {name2}"); + + Console.WriteLine($"ս: {sum}"); + + Console.WriteLine("\t÷"); + Console.WriteLine($"{name1}\t{hNum}"); + Console.WriteLine($"{name2}\t{uNum}"); + if (hNum > uNum) + { + Console.WriteLine($"{name1}Ӯˣ{name2}"); + } + else if (hNum < uNum) + { + Console.WriteLine($"{name2}Ӯˣ{name1}"); + } + else { + Console.WriteLine("ƽ"); + } + + Console.WriteLine("Ҫʼһ𣿣y/n"); + string chioce = Console.ReadLine(); + if (chioce == "y") + { + + return true; + } + else if (chioce == "n") + { + return false; + + } + return true; + } + + private void IsWin(string A, string B, string name, ref int hNum, ref int uNum) + { + string temp; + if (A == "" && B == "ʯͷ" || A == "" && B == "" || A == "ʯͷ" && B == "") + { + temp = "Ӯ"; + } + else if (A == B) + { + temp = "ƽ"; + } + else { + temp = ""; + } + + if (temp == "Ӯ") + { + hNum++; + Console.WriteLine($"{name}"); + } + else if (temp == "") + { + uNum++; + Console.WriteLine($"ϲ{name}Ӯ"); + } + else { + Console.WriteLine("ƽ֣"); + } + } + } +} \ No newline at end of file diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\274\272/Hero.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\274\272/Hero.cs" new file mode 100644 index 0000000000000000000000000000000000000000..57124db1883944c452b5aee8514ad389f9e79350 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\274\272/Hero.cs" @@ -0,0 +1,35 @@ +?using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Hero : Person + { + public Hero() + { + } + + public Hero(string name) : base(name) + { + } + public override string Action() + { + Random rd = new Random(); + int chioce = rd.Next(1, 4); + switch (chioce) + { + case 1: + return ""; + case 2: + return "ʯͷ"; + case 3: + return ""; + } + return base.Action(); + } + + } +} \ No newline at end of file diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\274\272/Person.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\274\272/Person.cs" new file mode 100644 index 0000000000000000000000000000000000000000..3d6b7ba42f20d11c844f1c4c5cccac9509b2a826 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\274\272/Person.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Person + { + public string Name { get; set; } + + public Person() + { + } + + public Person(string name) + { + Name = name; + } + + public virtual string Action() { + return null; + } + } +} \ No newline at end of file diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\274\272/Program.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\274\272/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..5db2a25e6c59a0d2cc2251859f855bdb1ba988cd --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\274\272/Program.cs" @@ -0,0 +1,60 @@ +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("------- ӭ Ϸ -------"); + while (true) + { + Console.WriteLine("*******************************"); + Console.WriteLine("**********ȭʼ***********"); + Console.WriteLine("*******************************"); + Console.WriteLine("ȭ1. 2.ʯͷ 3."); + + Console.WriteLine("ѡԷɫ<1. 2.Ȩ 3.ܲ>"); + Console.Write("ѡ"); + + Hero hero = new Hero(); + string chioce = Console.ReadLine(); + switch (chioce) + { + case "1": + hero = new Hero(""); + break; + case "2": + hero = new Hero("Ȩ"); + break; + case "3": + hero = new Hero("ܲ"); + break; + } + Console.WriteLine(""); + string userName = Console.ReadLine(); + User user = new User(userName); + Console.WriteLine($"{hero.Name} VS {user.Name} ս"); + + Console.WriteLine("ʼϷ𣿣y/n"); + string begin = Console.ReadLine(); + if (begin == "n") + { + return; + } + + Game g = new Game(); + bool v = g.Gaming(hero, user); + if (v == false) + { + return; + } + + } + } + } +} \ No newline at end of file diff --git "a/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\274\272/User.cs" "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\274\272/User.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b9e2f75ab0ef71c60a7ebb3a42fe359734080978 --- /dev/null +++ "b/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\351\273\204\345\274\272/User.cs" @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class User : Person + { + public User() + { + } + + public User(string name) : base(name) + { + } + public override string Action() + { + + Console.WriteLine("ȭ1. 2.ʯͷ 3.Ӧ֣"); + string chioce = Console.ReadLine(); + switch (chioce) + { + case "1": + return ""; + case "2": + return "ʯͷ"; + case "3": + return ""; + } + return base.Action(); + } + + } +} \ No newline at end of file diff --git "a/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/.keep" "b/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/.keep" "b/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/WebForm1.aspx" "b/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/WebForm1.aspx" new file mode 100644 index 0000000000000000000000000000000000000000..69f5d022525eaef930ec86f487fa9b0d8caab9e5 --- /dev/null +++ "b/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/WebForm1.aspx" @@ -0,0 +1,48 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication2.WebForm1" %> + + + + + + + + + + +
+
+

注册页面

+ 用户名: +
+ 密 码: +
+ 性 别: + + + +
+ 爱 好: + 唱歌 + 跳舞 + rep + 篮球 + +
+ 籍 贯:省 +
+
+ 其它信息: +
+ 头像: +
+ +
+ +
+ +
+
+ + diff --git "a/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/WebForm1.aspx.cs" "b/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/WebForm1.aspx.cs" new file mode 100644 index 0000000000000000000000000000000000000000..4fcb0645fd485d481190a5436d9c6781e1f36364 --- /dev/null +++ "b/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/WebForm1.aspx.cs" @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace WebApplication2 +{ + public partial class WebForm1 : System.Web.UI.Page + { + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + DropDownList1.Items.Add("福建"); + DropDownList1.Items.Add("广东"); + DropDownList1.Items.Add("新疆"); + DropDownList1.Items.Add("广西"); + DropDownList2.Items.Add("泉州"); + DropDownList2.Items.Add("福州"); + DropDownList2.Items.Add("厦门"); + DropDownList2.Items.Add("龙岩"); + } + } + + protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) + { + string province = DropDownList1.SelectedValue; + DropDownList2.Items.Clear(); + + if (province == "福建") + { + DropDownList2.Items.Add("泉州"); + DropDownList2.Items.Add("福州"); + DropDownList2.Items.Add("厦门"); + DropDownList2.Items.Add("龙岩"); + } + else if (province == "广东") + { + DropDownList2.Items.Add("深圳"); + DropDownList2.Items.Add("广州"); + DropDownList2.Items.Add("珠海"); + DropDownList2.Items.Add("汕头"); + } + else if (province == "新疆") + { + DropDownList2.Items.Add("乌鲁木齐"); + DropDownList2.Items.Add("吐鲁番"); + DropDownList2.Items.Add("阿克苏"); + DropDownList2.Items.Add("喀什"); + } + else + { + DropDownList2.Items.Add("南宁"); + DropDownList2.Items.Add("桂林"); + DropDownList2.Items.Add("贺州"); + DropDownList2.Items.Add("柳州"); + } + } + + protected void Button1_Click(object sender, EventArgs e) + { + string s = "性别是:"; + string t = "爱好是:"; + foreach (ListItem item in RadioButtonList1.Items) + { + if (item.Selected) + { + s = $"{item.Text}"; + } + else + { + s += "人妖"; + break; + } + } + for (int i = 0; i < CheckBoxList1.Items.Count; i++) + { + if (CheckBoxList1.Items[i].Selected) + { + t += CheckBoxList1.Items[i].Text + " "; + } + else + { + t = "没有爱好"; + } + } + if (FileUpload1.HasFile) + { + string fileName = FileUpload1.FileName; + if (fileName.EndsWith(".jpg") || fileName.EndsWith(".png") || fileName.EndsWith(".jpeg")) + { + string url = Server.MapPath("/img/" + fileName); + FileUpload1.SaveAs(url); + Image1.ImageUrl = "/img/" + fileName; + Image1.Visible = true; + } + } + Label1.Text = $"用户名:{TextBox1.Text},{s},{t},籍贯:{DropDownList1.Text}省{DropDownList2.Text}市,其它信息:{TextBox3.Text},头像:"; + } + + } +} \ No newline at end of file diff --git "a/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\345\247\223\345\220\215/WebForm2.aspx" "b/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\345\247\223\345\220\215/WebForm2.aspx" new file mode 100644 index 0000000000000000000000000000000000000000..2360c2fe3d3e985547275f471d0c19c787aa3bce --- /dev/null +++ "b/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\345\247\223\345\220\215/WebForm2.aspx" @@ -0,0 +1,30 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication1.WebForm2" %> + + + + + + + + + +
+
+ +
+ +
+ + + + +
+ +
+ +
+ +
+
+ + diff --git "a/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\345\247\223\345\220\215/WebForm2.aspx.cs" "b/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\345\247\223\345\220\215/WebForm2.aspx.cs" new file mode 100644 index 0000000000000000000000000000000000000000..78ad34fb20254288eb7989cd0f4cda751d5f0099 --- /dev/null +++ "b/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\345\247\223\345\220\215/WebForm2.aspx.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace WebApplication1 +{ + public partial class WebForm2 : System.Web.UI.Page + { + protected void Page_Load(object sender, EventArgs e) + { + + } + + protected void Button1_Click(object sender, EventArgs e) + { + Label5.Text = $"姓名:{ TextBox1.Text},年龄:{ TextBox2.Text},性别:{ DropDownList1.SelectedValue}, 爱好:{ TextBox3.Text}"; + + } + } +} \ No newline at end of file diff --git "a/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\346\226\260\351\227\273/WebForm1.aspx" "b/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\346\226\260\351\227\273/WebForm1.aspx" new file mode 100644 index 0000000000000000000000000000000000000000..53803617c2095d904e3e88f4e917531b1b9814c6 --- /dev/null +++ "b/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\346\226\260\351\227\273/WebForm1.aspx" @@ -0,0 +1,52 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %> + + + + + + + + + + +
+
+

在线新闻发布系统

+ + + 新华社 + 黎明社 + 人民日报 + 新周刊 + +
+ + + +
+ + +
+

+ + +

+
+ +
+
+ + diff --git "a/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\346\226\260\351\227\273/WebForm1.aspx.cs" "b/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\346\226\260\351\227\273/WebForm1.aspx.cs" new file mode 100644 index 0000000000000000000000000000000000000000..06a001e3ad3ea2594b757a5d66f7379af7b55dab --- /dev/null +++ "b/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\346\226\260\351\227\273/WebForm1.aspx.cs" @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace WebApplication1 +{ + public partial class WebForm1 : System.Web.UI.Page + { + protected void Page_Load(object sender, EventArgs e) + { + this.Label3.Text = "发布时间:" + DateTime.Now.ToString("d"); + } + + protected void Button1_Click(object sender, EventArgs e) + { + string t = TextArea1.Value; + if (string.IsNullOrEmpty(t)) + { + this.Label4.Text = "请输入新闻内容"; + } + else + { + this.Label4.Text = $"此新闻来自 {DropDownList1.Text} 谢谢您提交的新闻!"; + } + + } + + protected void Button2_Click(object sender, EventArgs e) + { + TextArea1.Value = null; + } + } +} \ No newline at end of file diff --git "a/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\351\241\276\345\256\242/WebForm3.aspx" "b/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\351\241\276\345\256\242/WebForm3.aspx" new file mode 100644 index 0000000000000000000000000000000000000000..321d501a1cf06822f4c803dcf90105e94224650f --- /dev/null +++ "b/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\351\241\276\345\256\242/WebForm3.aspx" @@ -0,0 +1,46 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="WebApplication1.WebForm3" %> + + + + + + + + + + +
+
+

顾客信息登记

+ +
+ +
+ +
+

+ +

+ +
+ +
+ +
+
+ + diff --git "a/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\351\241\276\345\256\242/WebForm3.aspx.cs" "b/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\351\241\276\345\256\242/WebForm3.aspx.cs" new file mode 100644 index 0000000000000000000000000000000000000000..45bcb60d02bbc90f10f1e59187ed6723b8cf21a6 --- /dev/null +++ "b/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\351\241\276\345\256\242/WebForm3.aspx.cs" @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace WebApplication1 +{ + public partial class WebForm3 : System.Web.UI.Page + { + protected void Page_Load(object sender, EventArgs e) + { + + } + + protected void Button1_Click(object sender, EventArgs e) + { + this.Label4.Text = "您好:当前时间是:"+DateTime.Now; + this.Label5.Text = "请确认您的信息"; + Label6.Text = $"姓名:{TextBox1.Text}
年龄:{TextBox2.Text}
爱好:{TextArea1.Value}"; + } + } +} \ No newline at end of file diff --git "a/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/.keep" "b/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/.keep" "b/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\345\247\223\345\220\215/WebForm2.aspx" "b/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\345\247\223\345\220\215/WebForm2.aspx" new file mode 100644 index 0000000000000000000000000000000000000000..2360c2fe3d3e985547275f471d0c19c787aa3bce --- /dev/null +++ "b/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\345\247\223\345\220\215/WebForm2.aspx" @@ -0,0 +1,30 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication1.WebForm2" %> + + + + + + + + + +
+
+ +
+ +
+ + + + +
+ +
+ +
+ +
+
+ + diff --git "a/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\345\247\223\345\220\215/WebForm2.aspx.cs" "b/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\345\247\223\345\220\215/WebForm2.aspx.cs" new file mode 100644 index 0000000000000000000000000000000000000000..78ad34fb20254288eb7989cd0f4cda751d5f0099 --- /dev/null +++ "b/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\345\247\223\345\220\215/WebForm2.aspx.cs" @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace WebApplication1 +{ + public partial class WebForm2 : System.Web.UI.Page + { + protected void Page_Load(object sender, EventArgs e) + { + + } + + protected void Button1_Click(object sender, EventArgs e) + { + Label5.Text = $"姓名:{ TextBox1.Text},年龄:{ TextBox2.Text},性别:{ DropDownList1.SelectedValue}, 爱好:{ TextBox3.Text}"; + + } + } +} \ No newline at end of file diff --git "a/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\346\226\260\351\227\273/WebForm1.aspx" "b/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\346\226\260\351\227\273/WebForm1.aspx" new file mode 100644 index 0000000000000000000000000000000000000000..53803617c2095d904e3e88f4e917531b1b9814c6 --- /dev/null +++ "b/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\346\226\260\351\227\273/WebForm1.aspx" @@ -0,0 +1,52 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %> + + + + + + + + + + +
+
+

在线新闻发布系统

+ + + 新华社 + 黎明社 + 人民日报 + 新周刊 + +
+ + + +
+ + +
+

+ + +

+
+ +
+
+ + diff --git "a/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\346\226\260\351\227\273/WebForm1.aspx.cs" "b/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\346\226\260\351\227\273/WebForm1.aspx.cs" new file mode 100644 index 0000000000000000000000000000000000000000..06a001e3ad3ea2594b757a5d66f7379af7b55dab --- /dev/null +++ "b/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\346\226\260\351\227\273/WebForm1.aspx.cs" @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace WebApplication1 +{ + public partial class WebForm1 : System.Web.UI.Page + { + protected void Page_Load(object sender, EventArgs e) + { + this.Label3.Text = "发布时间:" + DateTime.Now.ToString("d"); + } + + protected void Button1_Click(object sender, EventArgs e) + { + string t = TextArea1.Value; + if (string.IsNullOrEmpty(t)) + { + this.Label4.Text = "请输入新闻内容"; + } + else + { + this.Label4.Text = $"此新闻来自 {DropDownList1.Text} 谢谢您提交的新闻!"; + } + + } + + protected void Button2_Click(object sender, EventArgs e) + { + TextArea1.Value = null; + } + } +} \ No newline at end of file diff --git "a/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\351\241\276\345\256\242/WebForm3.aspx" "b/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\351\241\276\345\256\242/WebForm3.aspx" new file mode 100644 index 0000000000000000000000000000000000000000..321d501a1cf06822f4c803dcf90105e94224650f --- /dev/null +++ "b/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\351\241\276\345\256\242/WebForm3.aspx" @@ -0,0 +1,46 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="WebApplication1.WebForm3" %> + + + + + + + + + + +
+
+

顾客信息登记

+ +
+ +
+ +
+

+ +

+ +
+ +
+ +
+
+ + diff --git "a/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\351\241\276\345\256\242/WebForm3.aspx.cs" "b/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\351\241\276\345\256\242/WebForm3.aspx.cs" new file mode 100644 index 0000000000000000000000000000000000000000..45bcb60d02bbc90f10f1e59187ed6723b8cf21a6 --- /dev/null +++ "b/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\351\237\251\345\233\275\346\226\207/\351\237\251\345\233\275\346\226\207/\351\241\276\345\256\242/WebForm3.aspx.cs" @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace WebApplication1 +{ + public partial class WebForm3 : System.Web.UI.Page + { + protected void Page_Load(object sender, EventArgs e) + { + + } + + protected void Button1_Click(object sender, EventArgs e) + { + this.Label4.Text = "您好:当前时间是:"+DateTime.Now; + this.Label5.Text = "请确认您的信息"; + Label6.Text = $"姓名:{TextBox1.Text}
年龄:{TextBox2.Text}
爱好:{TextArea1.Value}"; + } + } +} \ No newline at end of file