Пример #1
0
        static void Main(string[] args)
        {
            string selectionString = null;

            while (selectionString != "Q")
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Enter task number (1-5) to choose task or enter Q to quit");
                selectionString = Console.ReadLine();
                switch (selectionString)
                {
                case "1":
                    Task1.Start();
                    break;

                case "2":
                    Task2.Start();
                    break;

                case "3":
                    Task3.Start();
                    break;

                case "4":
                    Task4.Start();
                    break;

                case "5":
                    Task5.Start();
                    break;

                case "Q":
                    Console.WriteLine("Quitting the program");
                    break;

                default:
                    Console.WriteLine("Wrong command");
                    break;
                }
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            int    choseLection;                              // For chosing Lection
            int    choseTasks;                                // For chosing Tasks
            int    page;                                      // for 4 Lection
            double x1, y1, x2, y2, radius, real, imagine;     // Input data
            double circuit, areaofthecircle, perimeter, area; // Output data

            Console.WriteLine(" ~ Chose Lection \n 2 - Second Lection \n 3 - Third Lection \n 4 - Fourth Lection");
            choseLection = Int32.Parse(Console.ReadLine());
            switch (choseLection)
            {
            case 2:
                Console.Clear();
                Console.WriteLine(" ~ Chose Task \n From 1 to 5");
                choseTasks = Int32.Parse(Console.ReadLine());
                switch (choseTasks)
                {
                case 1:
                    Console.Clear();
                    Console.WriteLine(" ~ Enter Coordinates for Rectangle");
                    Console.Write("x1: ");
                    x1 = Double.Parse(Console.ReadLine());
                    Console.Write("y1: ");
                    y1 = Double.Parse(Console.ReadLine());
                    Console.Write("x2: ");
                    x2 = Double.Parse(Console.ReadLine());
                    Console.Write("y2: ");
                    y2 = Double.Parse(Console.ReadLine());
                    Lection2Library.Rectangle recTask1 = new Lection2Library.Rectangle(x1, y1, x2, y2);
                    perimeter = recTask1.GetPerimeter();
                    Console.WriteLine($"Rectangle Perimeter = {perimeter}");
                    area = recTask1.GetArea();
                    Console.WriteLine($"Rectangle Area = {area}");
                    break;

                case 2:
                    Console.Clear();
                    Console.WriteLine(" ~ Enter Coordinates for Rectangle");
                    Console.Write("x1: ");
                    x1 = Double.Parse(Console.ReadLine());
                    Console.Write("y1: ");
                    y1 = Double.Parse(Console.ReadLine());
                    Console.Write("x2: ");
                    x2 = Double.Parse(Console.ReadLine());
                    Console.Write("y2: ");
                    y2 = Double.Parse(Console.ReadLine());
                    RectangleAutoProperties recTask2 = new RectangleAutoProperties(x1, y1, x2, y2);
                    Console.WriteLine($"Rectangle Perimeter = {recTask2.GetPerimeter}");
                    Console.WriteLine($"Rectangle Area = {recTask2.GetArea}");
                    break;

                case 3:
                    Console.Clear();
                    Console.WriteLine(" ~ Enter radius");
                    Console.Write("Radius: ");
                    radius = Double.Parse(Console.ReadLine());
                    Circle circleTask3 = new Circle();
                    circuit = circleTask3.Circuit(radius);
                    Console.WriteLine($"Circle Perimeter = {circuit}");
                    areaofthecircle = circleTask3.AreaOfTheCircle(radius);
                    Console.WriteLine($"Circle Area = {areaofthecircle}");
                    break;

                case 4:
                    Console.Clear();
                    Console.WriteLine(" ~ Enter Coordinates for static Rectangle");
                    Console.Write("x1: ");
                    x1 = Double.Parse(Console.ReadLine());
                    Console.Write("y1: ");
                    y1 = Double.Parse(Console.ReadLine());
                    Console.Write("x2: ");
                    x2 = Double.Parse(Console.ReadLine());
                    Console.Write("y2: ");
                    y2        = Double.Parse(Console.ReadLine());
                    perimeter = StaticRectangle.GetPerimeter(x1, y1, x2, y2);
                    Console.WriteLine($"Rectangle Perimeter = {perimeter}");
                    area = StaticRectangle.GetArea(x1, y1, x2, y2);
                    Console.WriteLine($"Rectangle Area = {area}");
                    Console.WriteLine(" ~ Enter radius for static Circle");
                    Console.Write("Radius: ");
                    radius  = Double.Parse(Console.ReadLine());
                    circuit = StaticCircle.Circuit(radius);
                    Console.WriteLine($"Circle Perimeter = {circuit}");
                    areaofthecircle = StaticCircle.AreaOfTheCircle(radius);
                    Console.WriteLine($"Circle Area = {areaofthecircle}");
                    break;

                case 5:
                    Console.Clear();
                    Console.WriteLine(" ~ Enter real number 1");
                    Console.Write("reZ: ");
                    real = Double.Parse(Console.ReadLine());
                    Console.WriteLine(" ~ Enter imagine number 1");
                    Console.Write("imZ: ");
                    imagine = Double.Parse(Console.ReadLine());
                    ComplexNumber num1 = new ComplexNumber(real, imagine);
                    Console.WriteLine(" ~ Enter real number 2");
                    Console.Write("reZ: ");
                    real = Double.Parse(Console.ReadLine());
                    Console.WriteLine(" ~ Enter imagine number 2");
                    Console.Write("imZ: ");
                    imagine = Double.Parse(Console.ReadLine());
                    ComplexNumber num2 = new ComplexNumber(real, imagine);
                    ComplexNumber num3, num4;
                    num3 = num1 * num2;
                    Console.WriteLine(num3.GetComplexNumber());
                    num4 = num1 / num2;
                    Console.WriteLine(num4.GetComplexNumber());
                    break;
                }
                break;

            case 3:
                Console.Clear();
                Console.WriteLine(" ~ Chose Task \n From 1 to 4");
                choseTasks = Int32.Parse(Console.ReadLine());
                switch (choseTasks)
                {
                case 1:
                    Console.Clear();
                    Console.WriteLine(" ~ Task #1");
                    Lection3Task1.Square square = new Lection3Task1.Square();
                    square.Draw();
                    Lection3Task1.Rectangle rect = new Lection3Task1.Rectangle();
                    rect.Draw();
                    break;

                case 2:
                    Console.Clear();
                    Console.WriteLine(" ~ Task #2");
                    Lection3Task2.Square squareTask2 = new Lection3Task2.Square(2, 5);
                    squareTask2.Draw();
                    Lection3Task2.Rectangle rectTask2 = new Lection3Task2.Rectangle(1, 6);
                    rectTask2.Draw();
                    break;

                case 3:
                    Console.Clear();
                    Console.WriteLine(" ~ Task #3");
                    Lection3Task3.Figure figure = new Lection3Task3.Figure(2, 5);
                    figure.Draw();
                    Lection3Task3.Square squareTask3 = new Lection3Task3.Square(2, 5);
                    squareTask3.Draw();
                    Lection3Task3.Rectangle rectTask3 = new Lection3Task3.Rectangle(1, 6);
                    rectTask3.Draw();
                    break;

                case 4:
                    Console.Clear();
                    Console.WriteLine(" ~ Task #4");
                    void DrawAll(params IDrawable[] array)
                    {
                        for (int i = 0; i < array.Length; i++)
                        {
                            array[i].Draw();
                        }
                    }

                    DrawAll(new Lection3Task4.Figure(1, 2), new Lection3Task4.Rectangle(2, 3), new Lection3Task4.Square(5, 5));
                    break;
                }
                break;

            case 4:
                Console.Clear();
                Console.WriteLine(" ~ Chose Task \n From 1 to 3");
                choseTasks = Int32.Parse(Console.ReadLine());
                switch (choseTasks)
                {
                case 1:
                    Console.Clear();
                    Console.WriteLine(" ~ Task #1");
                    Task1 task1 = new Task1();
                    task1.Show();
                    break;

                case 2:
                    Console.Clear();
                    Console.WriteLine(" ~ Task #2");
                    Task2 task2 = new Task2();
                    task2.Show();
                    break;

                case 3:
                    Console.Clear();
                    Console.WriteLine(" ~ Task #3");
                    Task3 task3 = new Task3();
                    task3.Show();
                    Console.Write("Input Page: ");
                    page = Int32.Parse(Console.ReadLine());
                    task3.DisplayPage(page);
                    break;
                }
                break;
            }
        }