diff --git a/C#核心/Lesson12_继承-继承的基本概念/Program.cs b/C#核心/Lesson12_继承-继承的基本概念/Program.cs index a9d0ec5..45711ed 100644 --- a/C#核心/Lesson12_继承-继承的基本概念/Program.cs +++ b/C#核心/Lesson12_继承-继承的基本概念/Program.cs @@ -90,7 +90,7 @@ ChineseTeacher ct = new ChineseTeacher(); - ct.name = "唐老师"; + ct.name = "HK"; ct.number = 2; ct.subject = "语文"; ct.SpeakName(); diff --git a/C#核心/Lesson12_继承-继承的基本概念练习/Program.cs b/C#核心/Lesson12_继承-继承的基本概念练习/Program.cs index d72b5f5..c6eab73 100644 --- a/C#核心/Lesson12_继承-继承的基本概念练习/Program.cs +++ b/C#核心/Lesson12_继承-继承的基本概念练习/Program.cs @@ -11,10 +11,9 @@ } class Warrior : Human { - public int atk; - public void Attack() + public void Attack(Warrior OtherWarrior) { - Console.WriteLine("攻击"); + Console.WriteLine("{0}攻击{1}",name,OtherWarrior.name); } } internal class Program @@ -24,11 +23,10 @@ Console.WriteLine("Hello, World!"); Warrior w = new Warrior(); w.name = "HK"; - w.age = 18; w.Speak(); - w.atk = 5; - w.Attack(); - + Warrior w2 = new Warrior(); + w2.name = "KH"; + w2.Attack(w); } } }