题目描述
编写代码实现:定义了三个类Bird、Mapie、Eagle。其中Bird为抽象类,定义了一个抽象方法Eat()。Mapie类和Eagle类为Bird的派生类。Mapie类中重写了Eat()方法,重载了一个Eat(int time)方法。Eagle类中也重写了Eat()方法。
输入
输入time参数的值
输出
各个方法的名称
样例输入
10
样例输出
Mapie eat!
Mapie eat 10!
Eagle eat!
Eagle eat!
提示
注意格式!!!
using System; using System.Collections.Generic; using System.Text; namespace 类的继承 { public abstract class Bird { public abstract void Eat(); } public class Mapie : Bird { public int t; public Mapie(int a) { this.t = a; } public override void Eat() { Console.WriteLine("Mapie eat!"); } public void Eat(int a) { Console.WriteLine("Mapie eat {0}!", a); } } public class Eagle : Bird { public int t; public Eagle(int a) { this.t = a; } public override void Eat() { Console.WriteLine("Eagle eat!"); } public void Eat(int a) { Console.WriteLine("Eagle eat!"); } } class RectangleTester { static void Main(string[] args) { int time; time = Convert.ToInt32(Console.ReadLine()); Mapie mapie = new Mapie(time); mapie.Eat(); mapie.Eat(time); Eagle eagle = new Eagle(time); eagle.Eat(); eagle.Eat(time); Console.ReadKey(); } } }