Exemple #1
0
        public static void Main(string[] args)
        {
            //Circle_hollow C1 = new Circle_hollow(0, 0, 4);
            //Circle_solid C2 = new Circle_solid(1, 1, 4);

            //Console.WriteLine(C2.Get_circumference());
            //Console.WriteLine(C1.Get_circumference());
            //Console.WriteLine(C2.Get_area());

            //Triangle T = new Triangle(1, 1, -2, 4, -2, -2);
            //Console.WriteLine(T.Area());

            Paint         paint = new Paint();
            Circle_hollow circle_hollow;// = new Circle_hollow();
            Circle_solid  circle_solid;
            Ring          ring;
            Line          line;
            Triangle      triangle;
            Rectangle     rectangle;

            int x = 1, y, tmp1, tmp2, tmp3, tmp4;

            string r = "1";

            Int32.Parse(r);



            int test = 0;

            while (true)
            {
                Console.WriteLine("1. Add the figure");
                Console.WriteLine("2. Show all figures");
                Console.WriteLine("3. Clear all");
                Console.WriteLine("4. Exit");
                Console.Write("input: ");
                switch (Console.ReadLine())
                {
                case "1":
                    Console.WriteLine();
                    Console.WriteLine("Enter the number of figure");
                    Console.WriteLine("1. Hollow Circle");
                    Console.WriteLine("2. Solid Circle");
                    Console.WriteLine("3. Ring");
                    Console.WriteLine("4. Line");
                    Console.WriteLine("5. Triangle");
                    Console.WriteLine("6. Rectangle");
                    Console.Write("input: ");
                    switch (Console.ReadLine())
                    {
                    case "1":         // добавление фигур
                        Console.WriteLine();
                        Console.WriteLine("Hollow Circle:");
                        Console.Write("x = ");
                        x = Int32.Parse(Console.ReadLine());
                        Console.Write("y = ");
                        y = Int32.Parse(Console.ReadLine());
                        Console.Write("rad = ");
                        tmp1 = Int32.Parse(Console.ReadLine());

                        circle_hollow = new Circle_hollow(x, y, tmp1);
                        paint.Add_Circle_hollow(circle_hollow);
                        Console.WriteLine("Hollow Circle is created");
                        Console.WriteLine();
                        break;

                    case "2":
                        Console.WriteLine();
                        Console.WriteLine("Solid Circle:");
                        Console.Write("x = ");
                        x = Int32.Parse(Console.ReadLine());
                        Console.Write("y = ");
                        y = Int32.Parse(Console.ReadLine());
                        Console.Write("rad = ");
                        tmp1 = Int32.Parse(Console.ReadLine());

                        circle_solid = new Circle_solid(x, y, tmp1);
                        paint.Add_Circle_solid(circle_solid);
                        Console.WriteLine("Solid Circle is created");
                        Console.WriteLine();
                        break;

                    case "3":
                        Console.WriteLine();
                        Console.WriteLine("Ring:");
                        Console.Write("x = ");
                        x = Int32.Parse(Console.ReadLine());
                        Console.Write("y = ");
                        y = Int32.Parse(Console.ReadLine());
                        Console.Write("outer rad = ");
                        tmp1 = Int32.Parse(Console.ReadLine());
                        Console.Write("inner rad = ");
                        tmp2 = Int32.Parse(Console.ReadLine());

                        ring = new Ring(x, y, tmp1, tmp2);
                        paint.Add_Ring(ring);
                        Console.WriteLine("Ring is created");
                        Console.WriteLine();
                        break;

                    case "4":
                        Console.WriteLine();
                        Console.WriteLine("Line:");
                        Console.Write("x1 = ");
                        x = Int32.Parse(Console.ReadLine());
                        Console.Write("y1 = ");
                        y = Int32.Parse(Console.ReadLine());
                        Console.Write("x2 = ");
                        tmp1 = Int32.Parse(Console.ReadLine());
                        Console.Write("y2 = ");
                        tmp2 = Int32.Parse(Console.ReadLine());

                        line = new Line(x, y, tmp1, tmp2);
                        paint.Add_Line(line);
                        Console.WriteLine("Line is created");
                        Console.WriteLine();
                        break;

                    case "5":
                        Console.WriteLine();
                        Console.WriteLine("Triangle:");
                        Console.Write("x1 = ");
                        x = Int32.Parse(Console.ReadLine());
                        Console.Write("y1 = ");
                        y = Int32.Parse(Console.ReadLine());
                        Console.Write("x2 = ");
                        tmp1 = Int32.Parse(Console.ReadLine());
                        Console.Write("y2 = ");
                        tmp2 = Int32.Parse(Console.ReadLine());
                        Console.Write("x3 = ");
                        tmp3 = Int32.Parse(Console.ReadLine());
                        Console.Write("y3 = ");
                        tmp4 = Int32.Parse(Console.ReadLine());

                        triangle = new Triangle(x, y, tmp1, tmp2, tmp3, tmp4);
                        paint.Add_Triangle(triangle);
                        Console.WriteLine("Triangle is created");
                        Console.WriteLine();
                        break;

                    case "6":
                        Console.WriteLine();
                        Console.WriteLine("Rectangle:");
                        Console.Write("x1 = ");
                        x = Int32.Parse(Console.ReadLine());
                        Console.Write("y1 = ");
                        y = Int32.Parse(Console.ReadLine());
                        Console.Write("x2 = ");

                        tmp1 = Int32.Parse(Console.ReadLine());
                        Console.Write("y2 = ");
                        tmp2 = Int32.Parse(Console.ReadLine());

                        rectangle = new Rectangle(x, y, tmp1, tmp2);
                        paint.Add_Rectangle(rectangle);
                        Console.WriteLine("Rectangle is created");
                        Console.WriteLine();
                        break;
                    }
                    continue;

                case "2":     // вывод всех фигур
                    Console.WriteLine();
                    if (paint.Get_Circle_hollow_list().Count > 0)
                    {
                        for (int i = 0; i < paint.Get_Circle_hollow_list().Count; i++)
                        {
                            Console.WriteLine($"Hollow Circle {i + 1}");
                            Console.WriteLine($"Coordinates of center: ({paint.Get_Circle_hollow(i).Get_x()}; " +
                                              $"{paint.Get_Circle_hollow(i).Get_y()})");
                            Console.WriteLine($"Radius = {paint.Get_Circle_hollow(i).Get_rad()}");
                            Console.WriteLine($"Circumference = {paint.Get_Circle_hollow(i).Get_circumference()}");
                            Console.WriteLine();
                        }
                    }
                    if (paint.Get_Circle_solid_list().Count > 0)
                    {
                        for (int i = 0; i < paint.Get_Circle_solid_list().Count; i++)
                        {
                            Console.WriteLine($"Solid Circle {i + 1}");
                            Console.WriteLine($"Coordinates of center: ({paint.Get_Circle_solid(i).Get_x()}; " +
                                              $"{paint.Get_Circle_solid(i).Get_y()})");
                            Console.WriteLine($"Radius = {paint.Get_Circle_solid(i).Get_rad()}");
                            Console.WriteLine($"Circumference = {paint.Get_Circle_solid(i).Get_circumference()}");
                            Console.WriteLine($"Area = {paint.Get_Circle_solid(i).Get_area()}");
                            Console.WriteLine();
                        }
                    }
                    if (paint.Get_Ring_list().Count > 0)
                    {
                        for (int i = 0; i < paint.Get_Ring_list().Count; i++)
                        {
                            Console.WriteLine($"Ring {i + 1}");
                            Console.WriteLine($"Coordinates of center: ({paint.Get_Ring(i).Get_x()}; " +
                                              $"{paint.Get_Ring(i).Get_y()})");
                            Console.WriteLine($"Outer radius = {paint.Get_Ring(i).Get_rad()}");
                            Console.WriteLine($"Inner radius = {paint.Get_Ring(i).Get_rad_inside()}");
                            Console.WriteLine($"Sum circumference = {paint.Get_Ring(i).Get_Sum_of_circumferences()}");
                            Console.WriteLine($"Area = {paint.Get_Ring(i).Get_area()}");
                            Console.WriteLine();
                        }
                    }
                    if (paint.Get_Line_list().Count > 0)
                    {
                        for (int i = 0; i < paint.Get_Line_list().Count; i++)
                        {
                            Console.WriteLine($"Line {i + 1}");
                            Console.WriteLine($"Coordinates of 1st point: ({paint.Get_Line(i).Get_x1()}; " +
                                              $"{paint.Get_Line(i).Get_y1()})");
                            Console.WriteLine($"Coordinates of 2nd point: ({paint.Get_Line(i).Get_x2()}; " +
                                              $"{paint.Get_Line(i).Get_y2()})");
                            Console.WriteLine($"Line length = {paint.Get_Line(i).Get_a()}");
                            Console.WriteLine();
                        }
                    }
                    if (paint.Get_Triangle_list().Count > 0)
                    {
                        for (int i = 0; i < paint.Get_Triangle_list().Count; i++)
                        {
                            Console.WriteLine($"Triangle {i + 1}");
                            Console.WriteLine($"Coordinates of 1st point: ({paint.Get_Triangle(i).Get_x1()}; " +
                                              $"{paint.Get_Triangle(i).Get_y1()})");
                            Console.WriteLine($"Coordinates of 2nd point: ({paint.Get_Triangle(i).Get_x2()}; " +
                                              $"{paint.Get_Triangle(i).Get_y2()})");
                            Console.WriteLine($"Coordinates of 3rd point: ({paint.Get_Triangle(i).Get_x3()}; " +
                                              $"{paint.Get_Triangle(i).Get_y3()})");
                            Console.WriteLine($"Perimeter = {paint.Get_Triangle(i).Perimeter()}");
                            Console.WriteLine($"Area = {paint.Get_Triangle(i).Area()}");
                            Console.WriteLine();
                        }
                    }
                    if (paint.Get_Rectangle_list().Count > 0)
                    {
                        for (int i = 0; i < paint.Get_Rectangle_list().Count; i++)
                        {
                            Console.WriteLine($"Rectangle {i + 1}");
                            Console.WriteLine($"Coordinates of 1st point: ({paint.Get_Rectangle(i).Get_x1()}; " +
                                              $"{paint.Get_Rectangle(i).Get_y1()})");
                            Console.WriteLine($"Coordinates of 2nd point: ({paint.Get_Rectangle(i).Get_x2()}; " +
                                              $"{paint.Get_Rectangle(i).Get_y2()})");
                            Console.WriteLine($"Coordinates of 3rd point: ({paint.Get_Rectangle(i).Get_x3()}; " +
                                              $"{paint.Get_Rectangle(i).Get_y3()})");
                            Console.WriteLine($"Coordinates of 4th point: ({paint.Get_Rectangle(i).Get_x4()}; " +
                                              $"{paint.Get_Rectangle(i).Get_y4()})");
                            if (paint.Get_Rectangle(i).Is_square())
                            {
                                Console.WriteLine($"a = {paint.Get_Rectangle(i).Get_a()}");
                            }
                            else
                            {
                                Console.WriteLine($"a = {paint.Get_Rectangle(i).Get_a()}");
                                Console.WriteLine($"b = {paint.Get_Rectangle(i).Get_b()}");
                            }
                            Console.WriteLine($"Perimeter = {paint.Get_Rectangle(i).Perimeter()}");
                            Console.WriteLine($"Area = {paint.Get_Rectangle(i).Area()}");
                            Console.WriteLine();
                        }
                    }
                    continue;

                case "3":     // очистка холста
                    paint.Clear_all();
                    Console.WriteLine();
                    continue;

                case "4":     // Выход;
                    Console.WriteLine("END");
                    break;

                default:
                    continue;
                }
                break;
            }
        }
Exemple #2
0
 public void Add_Circle_hollow(Circle_hollow circle)
 {
     circle_hollow_list.Add(circle);
 }