lesson12练习更改
This commit is contained in:
@@ -90,7 +90,7 @@
|
|||||||
|
|
||||||
|
|
||||||
ChineseTeacher ct = new ChineseTeacher();
|
ChineseTeacher ct = new ChineseTeacher();
|
||||||
ct.name = "唐老师";
|
ct.name = "HK";
|
||||||
ct.number = 2;
|
ct.number = 2;
|
||||||
ct.subject = "语文";
|
ct.subject = "语文";
|
||||||
ct.SpeakName();
|
ct.SpeakName();
|
||||||
|
|||||||
@@ -11,10 +11,9 @@
|
|||||||
}
|
}
|
||||||
class Warrior : Human
|
class Warrior : Human
|
||||||
{
|
{
|
||||||
public int atk;
|
public void Attack(Warrior OtherWarrior)
|
||||||
public void Attack()
|
|
||||||
{
|
{
|
||||||
Console.WriteLine("攻击");
|
Console.WriteLine("{0}攻击{1}",name,OtherWarrior.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
internal class Program
|
internal class Program
|
||||||
@@ -24,11 +23,10 @@
|
|||||||
Console.WriteLine("Hello, World!");
|
Console.WriteLine("Hello, World!");
|
||||||
Warrior w = new Warrior();
|
Warrior w = new Warrior();
|
||||||
w.name = "HK";
|
w.name = "HK";
|
||||||
w.age = 18;
|
|
||||||
w.Speak();
|
w.Speak();
|
||||||
w.atk = 5;
|
Warrior w2 = new Warrior();
|
||||||
w.Attack();
|
w2.name = "KH";
|
||||||
|
w2.Attack(w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user