Пример #1
0
 private static void DrawCircle()
 {
     IShape circle = new Circle();
     circle.Draw();
     Console.WriteLine("Object of type circle stored in a variable of type IShape\n");
     Console.WriteLine("*********************************\n");
 }
Пример #2
0
 private static void AssignDifferentTypesToSameInstanceVariable()
 {
     Console.WriteLine("Instance variable holds a type of circle, and then a type of rectangle. The draw methods change\n");
     IShape shape = new Circle();
     Console.WriteLine("The object variable is of type IShape,\nand is holding an instance of a Circle.\n");
     shape.Draw();
     Console.WriteLine("The object variable is of type IShape,\nbut is now holding an instance of a Rectangle.\n");
     shape = new Rectangle();
     shape.Draw();
 }