From 8957a9d567f94b67b88c0f16400b53a29428632a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=9C=E6=B5=B7=E5=BD=AA?= <3305448617@qq.com> Date: Sun, 23 May 2021 22:03:36 +0800 Subject: [PATCH] 123 --- .../CookRobot.cs" | 38 +++++++++++++ .../DeliveryRobot.cs" | 22 +++++++ .../IronNpc.cs" | 27 +++++++++ .../NPC.cs" | 41 +++++++++++++ .../Program.cs" | 34 +++++++++++ .../Program1.cs" | 57 +++++++++++++++++++ .../Robot.cs" | 24 ++++++++ .../ShopNpc.cs" | 26 +++++++++ .../WorkNpc.cs" | 27 +++++++++ 9 files changed, 296 insertions(+) create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/CookRobot.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/DeliveryRobot.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/IronNpc.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/NPC.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/Program.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/Program1.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/Robot.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/ShopNpc.cs" create mode 100644 "\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/WorkNpc.cs" diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/CookRobot.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/CookRobot.cs" new file mode 100644 index 0000000..b551ea4 --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/CookRobot.cs" @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp7 +{ + public enum cai : int + { + 铁锅炖大鹅, + 火烧, + } + class CookRobot : Robot + { + public int a; + public CookRobot(string name, cai Cai) : base(name) + { + a = (int)Cai; + } + public override void Working() + { + Console.WriteLine("炒菜机器人现在启动"); + if (a == 0) + { + Console.WriteLine("请稍等"); + Console.WriteLine("......"); + Console.WriteLine("你的川菜好了"); + } + else if (a == 1) + { + Console.WriteLine("请稍等"); + Console.WriteLine("......"); + Console.WriteLine("你的粤菜好了"); + } + } + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/DeliveryRobot.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/DeliveryRobot.cs" new file mode 100644 index 0000000..9606d76 --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/DeliveryRobot.cs" @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp7 +{ + class DeliveryRobot : Robot + { + public int hours { get; set; } + public DeliveryRobot(string name, int hours) : base(name) + { + this.hours = hours; + } + public override void Working() + { + Console.WriteLine("传菜机器人现在启动"); + Console.WriteLine("连续工作时间为:{0}。", this.hours); + } + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/IronNpc.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/IronNpc.cs" new file mode 100644 index 0000000..5e55a06 --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/IronNpc.cs" @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp7 +{ + class IronNpc:NPC + { + private string ironinfo; + public string Ironinfo + { + get { return ironinfo; } + set { ironinfo = value; } + } + public IronNpc(string name, npcType type, string ironinfo) : base(name, type) + { + this.Ironinfo = ironinfo; + } + + public override void Speak() + { + Console.WriteLine("我是{0},{1}:{2}", this.Name, this.Type, this.ironinfo); + } + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/NPC.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/NPC.cs" new file mode 100644 index 0000000..29a10d2 --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/NPC.cs" @@ -0,0 +1,41 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp7 +{ + public enum npcType + { + WorkNpc,//任务 + ShopNpc,//商贩 + IronNpc,//铁匠 + } + abstract class NPC + { + private string name; + private npcType type; + public string Name + { + get { return this.name; } + set { this.name = value; } + } + public npcType Type + { + get { return this.type; } + set { this.type = value; } + } + public NPC(string name, npcType type) + { + this.Name = name; + this.Type = type; + } + public NPC() + { + } + public abstract void Speak(); + + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/Program.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/Program.cs" new file mode 100644 index 0000000..4e7dfdf --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/Program.cs" @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp7 +{ + class Program + { + static void Main(string[] args) + { + WorkNpc npc1 = new WorkNpc("小白兔", npcType.WorkNpc, "去野外帮我挖2根萝卜。"); + npc1.Speak(); + WorkNpc npc2 = new WorkNpc("灰太狼", npcType.WorkNpc, "懒羊羊"); + npc2.Speak(); + WorkNpc work2 = new WorkNpc("小三", npcType.IronNpc, "帮我去采集"); + npc2.Speak(); + ShopNpc shop = new ShopNpc("小王", npcType.ShopNpc, "我这里武器,你要吗?"); + shop.Speak(); + ShopNpc shop1 = new ShopNpc("小王", npcType.ShopNpc, "我这里卖材料,你要吗?"); + shop1.Speak(); + ShopNpc shop2 = new ShopNpc("小王", npcType.ShopNpc, "我这里卖食物,你要吗?"); + shop2.Speak(); + IronNpc ir = new IronNpc("小三", npcType.IronNpc, "我这里修补,你要打吗?"); + ir.Speak(); + IronNpc ir1 = new IronNpc("小三", npcType.IronNpc, "我这里强化,你要打吗?"); + ir1.Speak(); + IronNpc ir2 = new IronNpc("小三", npcType.IronNpc, "我这里打造,你要打吗?"); + ir2.Speak(); + } + + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/Program1.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/Program1.cs" new file mode 100644 index 0000000..ee843fd --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/Program1.cs" @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp7 +{ + class Program1 + { + static void Main(string[] args) + { + string key; + Console.WriteLine("请输入炒菜或者传菜"); + key = Console.ReadLine(); + Robot a = Tsat(key); + a.Working(); + + } + public static Robot Tsat(string key) + { + Robot a; + int s; + switch (key) + { + case "炒菜": + Console.WriteLine("请问你要炒什么菜系的菜:1.铁锅炖大鹅 2.火烧"); + s = int.Parse(Console.ReadLine()); + if (s == 1) + { + a = new CookRobot("炒菜机器人", cai.铁锅炖大鹅); + } + else if (s == 2) + { + a = new CookRobot("炒菜机器人", cai.火烧); + } + else + { + Console.WriteLine("选择出错,默认选择粤菜"); + a = new CookRobot("炒菜机器人", cai.火烧); + } + break; + case "传菜": + Console.WriteLine("请输入传菜机器人的时长:"); + int jiu = int.Parse(Console.ReadLine()); + a = new DeliveryRobot("传菜机器人", jiu); + break; + default: + Console.WriteLine("输入错误自动选择炒菜机器人"); + a = new CookRobot("", cai.火烧); + break; + } + return a; + } + } + } + diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/Robot.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/Robot.cs" new file mode 100644 index 0000000..476121e --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/Robot.cs" @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp7 +{ + abstract class Robot + { + public string name; + + public Robot() { } + + public Robot(string Name) + { + this.name = Name; + } + + + public abstract void Working(); + + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/ShopNpc.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/ShopNpc.cs" new file mode 100644 index 0000000..771b8ea --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/ShopNpc.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp7 +{ + class ShopNpc:NPC + { + private string shopinfo; + public string Shopinfo + { + get { return shopinfo; } + set { shopinfo = value; } + } + public ShopNpc(string name, npcType type, string shopinfo) : base(name, type) + { + this.Shopinfo = shopinfo; + } + public override void Speak() + { + Console.WriteLine("我是{0},{1}:{2}", this.Name, this.Type, this.shopinfo); + } + } +} diff --git "a/\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/WorkNpc.cs" "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/WorkNpc.cs" new file mode 100644 index 0000000..d88b652 --- /dev/null +++ "b/\347\254\2542\346\254\241\344\275\234\344\270\232/\346\235\234\346\265\267\345\275\252/WorkNpc.cs" @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp7 +{ + class WorkNpc:NPC + { + private string workInfo; + public string WorkInfo + { + get { return WorkInfo; } + set { WorkInfo = value; } + } + public WorkNpc(string name, npcType type, string workInfo) : base(name, type) { + this.WorkInfo = workInfo; + } + public override void Speak() + { + Console.WriteLine("你能帮帮我吗?,我是{0},{1},任务:{2}", this.Name, this.Type, this.workInfo); + } + + + } +} -- Gitee