// If we did not implement the abstract Draw() method, Circle would also be
// considered abstract, and would have to be marked abstract!
class Circle : Shape
{
public Circle() {}
public Circle(string name) : base(name) {}
public override void Draw()
{
Console.WriteLine("Drawing {0} the Circle", shapeName);
}
}
The short answer is that we can now make the assumption that anything deriving from
Shape does indeed have a unique version of the Draw() method. To illustrate the full story of
polymorphism, consider the following code:
static void Main(string[] args)
{
Console.WriteLine("***** Fun with Polymorphism *****\n");
Do'stlaringiz bilan baham: |