コード例 #1
0
ファイル: TestShapes.cs プロジェクト: Vyara/Telerik-Academy
        //method for printing shape 
        public static void PrintShape(Shape shape)
        {
            if (shape is Square)
            {
                Console.WriteLine("Square with side {0}.", shape.Width);
            }

            else
            {
                Console.WriteLine("{0} with width {1} and height {2}.", shape.GetType().Name, shape.Width, shape.Height);
            }

        }
コード例 #2
0
 public void RemoveShape(Shape shape)
 {
     if (Points.Count > 0)
     {
         foreach (var point in shape.Points)
         {
             Points.Remove(point);
         }
     }
     if (!thisShapesList.Contains(shape))
     {
         throw new ShapeException($"{shape.GetType().Name} is not part of the composite shape.");
     }
     thisShapesList.Remove(shape);
     shape.CompositeShape = false;
 }