lesson12练习更改

This commit is contained in:
2025-09-09 11:11:14 +08:00
parent 40dca79e2b
commit 307b255d02
2 changed files with 6 additions and 8 deletions
@@ -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);
}
}
}