static void MakeShapeHollow(Shape s)
 {
     if (s.Area() > s.Perimeter())
     {
         s.MakeHollow();
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Сравнение элементов.
        /// </summary>
        /// <param name="obj">правый параметр сравнения</param>
        /// <returns> -1 - если левый параметр меньше правого
        ///            0 - параметры равны
        ///            1 - если левый параметр больше правого
        /// </returns>
        public int CompareTo(object obj)
        {
            Shape p = (Shape)obj;

            if (this.Area() < p.Area())
            {
                return(-1);
            }
            else if (this.Area() == p.Area())
            {
                return(0);
            }
            else
            {
                return(1);
            }
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Shape undefShape = new Shape();

            Console.WriteLine(undefShape.NameOfShape());
            Console.WriteLine(undefShape.AmmountOfSides());
            Console.WriteLine(undefShape.Area());
            Console.WriteLine(undefShape.Circumference());
            Console.WriteLine(undefShape.AStringIwantToKeep());

            Console.WriteLine("----------");

            //undefShape.NumberOfSides = 3;   This shouldn't work. And it doesn't. So it works as expected.
            Line line = new Line();

            Console.WriteLine(line.NameOfShape());
            Console.WriteLine(line.AmmountOfSides());
            Console.WriteLine(line.Area());
            Console.WriteLine(line.Circumference());
            Console.WriteLine(line.AStringIwantToKeep());

            Console.WriteLine("----------");

            Square firstSquare = new Square();

            firstSquare.A = 5;
            firstSquare.B = 10;
            Console.WriteLine(firstSquare.NameOfShape());
            Console.WriteLine(firstSquare.AmmountOfSides());
            Console.WriteLine(firstSquare.Area());
            Console.WriteLine(firstSquare.Circumference());
            Console.WriteLine(firstSquare.AStringIwantToKeep());
            firstSquare.A = 15;
            Console.WriteLine(firstSquare.Area());
            Console.WriteLine(firstSquare.Circumference());

            Console.WriteLine("----------");

            Square secondSquare = new Square(7, 2);

            Console.WriteLine(secondSquare.NameOfShape());
            Console.WriteLine(secondSquare.AmmountOfSides());
            Console.WriteLine(secondSquare.Area());
            Console.WriteLine(secondSquare.Circumference());
            Console.WriteLine(secondSquare.AStringIwantToKeep());
            secondSquare.A = 15;
            Console.WriteLine(secondSquare.Area());
            Console.WriteLine(secondSquare.Circumference());


            Console.ReadLine();
        }
Exemplo n.º 4
0
 private static void Calculate(Shape shape)
 {
     shape.Area();
     shape.Perimeter();
     Console.WriteLine();
 }