Ejemplo n.º 1
0
        static void Main()
        {
            Shape[] shapes = new Shape[3]
                { new Rectangle(4, 3), new Triangle(2, 2), new Circle(2) };

            foreach (Shape shape in shapes)
            {
                Console.WriteLine(shape);
                Console.WriteLine();
            }
        }
Ejemplo n.º 2
0
 public override Shape scale(Shape myCircle)
 {
     Radius = Radius + 1;
     return myCircle;
 }
Ejemplo n.º 3
0
 public abstract Shape scale(Shape x);
Ejemplo n.º 4
0
 public override Shape scale(Shape myRectangle)
 {
     Height = Height + 1;
     Width = Width + 1;
     return myRectangle;
 }
Ejemplo n.º 5
0
 public void CallArea(Shape sh)
 {
     int a;
      a = sh.area();
      Console.WriteLine("Area: {0}", a);
 }
Ejemplo n.º 6
0
 //public static bool Contains(this Shape s, Shape t)
 //{
 //    if (s is Rectangle && t is Rectangle) return Contains((Rectangle)s, (Rectangle)t);
 //    if (s is Rectangle && t is Circle) return Contains((Rectangle)s, (Circle)t);
 //    if (s is Circle && t is Rectangle) return Contains((Circle)s, (Rectangle)t);
 //    if (s is Circle && t is Circle) return Contains((Circle)s, (Circle)t);
 //    throw new ArgumentException();
 //}
 // ↑before
 // ↓after
 public static bool Contains(this Shape s, Shape t)
 {
     return Contains((dynamic)s, (dynamic)t);
 }