Exemplo n.º 1
0
        static void Main()
        {
            Triangle triangle = new Triangle(10, 8, 60);

            Console.WriteLine("Triangle, area = {0}, perimeter = {1}", triangle.ComputeArea(),
                              triangle.ComputePerimeter());

            Circle circle = new Circle(10);

            Console.WriteLine("Circle, area = {0}, perimeter = {1}", circle.ComputeArea(),
                              circle.ComputePerimeter());

            Rectangle rectangle = new Rectangle(10, 20);

            Console.WriteLine("Rectangle, area = {0}, perimeter = {1}", rectangle.ComputeArea(),
                              rectangle.ComputePerimeter());

            Square square = new Square(10);

            Console.WriteLine("Square, area = {0}, perimeter = {1}", square.ComputeArea(),
                              square.ComputePerimeter());

            Rhombus rhombus = new Rhombus(10, 60);

            Console.WriteLine("Rhombus, area = {0}, perimeter = {1}", rhombus.ComputeArea(),
                              rhombus.ComputePerimeter());
        }
Exemplo n.º 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     string[] diagonals = InputDiagonals.Text.Split(' ');
     if (diagonals.Length != 2)
     {
         OutputRhomb.Text = "Incorrect input";
     }
     try
     {
         rhombus = new Rhombus(Convert.ToInt32(diagonals[0]), Convert.ToInt32(diagonals[1]));
     }
     catch (Exception exception)
     {
         OutputRhomb.Text = exception.Message;
         rhombus          = null;
     }
     if (rhombus != null)
     {
         OutputRhomb.Text = "Perimeter: " + rhombus.GetPerimetеr() + "\nArea: " +
                            rhombus.GetArea();
     }
 }