Пример #1
0
        public static void Main(string[] args)
        {
            Menu menu = new Menu();

            menu.ChooseAction();
            int choice = int.Parse(Console.ReadLine());

            switch (choice)
            {
            case 1:
                menu.ChooseLab();
                int choiceLab = int.Parse(Console.ReadLine());
                if (choiceLab == 1)
                {
                    Console.WriteLine("Enter points:");
                    Console.Write("LeftTopX: ");
                    double leftTopX = double.Parse(Console.ReadLine());
                    Console.Write("LeftTopY: ");
                    double leftTopY = double.Parse(Console.ReadLine());
                    Console.Write("RightDownX: ");
                    double rightDownX = double.Parse(Console.ReadLine());
                    Console.Write("RightDownY: ");
                    double rightDownY = double.Parse(Console.ReadLine());

                    // Lab#1Task1
                    Console.WriteLine("Task 1: ");
                    Rectangle myRectangle1 = new Rectangle(leftTopX, leftTopY, rightDownX, rightDownY);
                    Console.WriteLine(myRectangle1.square());
                    Console.WriteLine(myRectangle1.perimeter());
                    // Lab#1Task2
                    Console.WriteLine("Task 2: ");
                    Rectangle_Auto_Implemented myRectangleAuto1 = new
                                                                  Rectangle_Auto_Implemented();
                    myRectangleAuto1.leftTopX   = leftTopX;
                    myRectangleAuto1.leftTopY   = leftTopY;
                    myRectangleAuto1.rightDownX = rightDownX;
                    myRectangleAuto1.rightDownY = rightDownY;

                    Console.WriteLine(myRectangleAuto1.GetPerimeter);
                    Console.WriteLine(myRectangleAuto1.GetSquare);

                    //  Lab#1Task3
                    Console.Write("Enter radius: ");
                    double radius = double.Parse(Console.ReadLine());
                    Console.WriteLine("Task 3: ");
                    Circle myCircle1 = new Circle();
                    Console.WriteLine(myCircle1.length(radius));
                    Console.WriteLine(myCircle1.square(radius));
                    Console.WriteLine("Task 4: ");
                    //  Lab#1Task4
                    Console.WriteLine(StatRectangle.perimeter(leftTopX, leftTopY, rightDownX, rightDownY));
                    Console.WriteLine(StatRectangle.square(leftTopX, leftTopY, rightDownX, rightDownY));
                    Console.WriteLine(StatCircle.length(radius));
                    Console.WriteLine(StatCircle.square(radius));
                    //  Lab#1Task5
                    Console.WriteLine("Task 5: ");
                    Console.Write("Num1RealPart: ");
                    double real1 = double.Parse(Console.ReadLine());
                    Console.Write("Num1ImagPart: ");
                    double imag1 = double.Parse(Console.ReadLine());
                    Console.Write("Num2RealPart: ");
                    double real2 = double.Parse(Console.ReadLine());
                    Console.Write("Num2ImagPart: ");
                    double imag2 = double.Parse(Console.ReadLine());

                    ComplexNumber numfirst  = new ComplexNumber(real1, imag1);
                    ComplexNumber numsecond = new ComplexNumber(real2, imag2);
                    Console.WriteLine(numfirst * numsecond);
                    Console.WriteLine(numfirst / numsecond);
                }
                if (choiceLab == 2)
                {
                    Console.WriteLine("Task 1: ");
                    RectangleFigure rect1 = new RectangleFigure();
                    rect1.Draw();
                    SquareFigure square1 = new SquareFigure();
                    square1.Draw();
                    Console.WriteLine("Task 2: ");
                    Console.WriteLine("Look my code");
                    RectangleReadOnly rectangleRead1 = new RectangleReadOnly(2, 3);
                    SquareReadOnly    squareRead1    = new SquareReadOnly(2, 3);
                    Console.WriteLine("Task 3: ");
                    FigureVirtual figure1 = new FigureVirtual(2, 3);
                    figure1.Draw();
                    FigureVirtual newfigureone = new RectangleVirtual(2, 3);
                    newfigureone.Draw();
                    FigureVirtual newfiguresecond = new SquareVirtual(2, 3);
                    newfiguresecond.Draw();
                    Console.WriteLine("Task 4: ");
                    FigureDraw    figuretoDraw1  = new FigureDraw(2, 3);
                    RectangleDraw rectangleDraw1 = new RectangleDraw(2, 3);
                    figuretoDraw1.DrawAll(figuretoDraw1, rectangleDraw1);
                }
                if (choiceLab == 3)
                {
                    //   Lab#3Task1
                    Console.WriteLine("\t Lab 3: ");
                    Console.WriteLine("Task 1: ");
                    List <Person>       newList1 = new List <Person>();
                    CreateDisplayPerson create1  = new CreateDisplayPerson(newList1);
                    create1.CreateSomePerson();
                    create1.DisplayPerson();
                    //   Lab#3Task2
                    Console.WriteLine("Task 2: ");
                    AddRangePerson add1 = new AddRangePerson(newList1);
                    add1.AddTwoPerson();
                    add1.DisplayPhoneNumbers();
                    //   Lab#3Task3
                    Console.WriteLine("Task 3: ");
                    RandomList randomList1 = new RandomList();
                    Console.Write("Enter number of Page: ");
                    string numberPage1 = Console.ReadLine();
                    int    number1;
                    bool   success1 = Int32.TryParse(numberPage1, out number1);
                    if (success1)
                    {
                        number1 = Int32.Parse(numberPage1);
                        randomList1.DisplayPage(number1);
                    }
                    else
                    {
                        Console.WriteLine("Please enter number as digit");
                        break;
                    }
                }
                break;

            case 2:
                Console.WriteLine("\tLab 1: ");
                // Lab#1Task1
                Console.WriteLine("Task 1: ");
                Rectangle myRectangle = new Rectangle(2, 3, 3, 1);
                Console.WriteLine(myRectangle.square());
                Console.WriteLine(myRectangle.perimeter());
                // Lab#1Task2
                Console.WriteLine("Task 2: ");
                Rectangle_Auto_Implemented myRectangleAuto = new
                                                             Rectangle_Auto_Implemented();
                myRectangleAuto.leftTopX   = 2;
                myRectangleAuto.leftTopY   = 3;
                myRectangleAuto.rightDownX = 3;
                myRectangleAuto.rightDownY = 1;

                Console.WriteLine(myRectangleAuto.GetPerimeter);
                Console.WriteLine(myRectangleAuto.GetSquare);

                //  Lab#1Task3
                Console.WriteLine("Task 3: ");
                Circle myCircle = new Circle();
                Console.WriteLine(myCircle.length(2));
                Console.WriteLine(myCircle.square(3));
                //  Lab#1Task4
                Console.WriteLine("Task 4: ");
                Console.WriteLine(StatRectangle.perimeter(2, 3, 3, 1));
                Console.WriteLine(StatRectangle.square(2, 3, 3, 1));
                Console.WriteLine(StatCircle.length(2));
                Console.WriteLine(StatCircle.square(3));
                //  Lab#1Task5
                Console.WriteLine("Task 5: ");
                ComplexNumber num1 = new ComplexNumber(1, 1);
                ComplexNumber num2 = new ComplexNumber(1, 3);
                Console.WriteLine(num1 * num2);
                Console.WriteLine(num1 / num2);
                Console.WriteLine("\t Lab 2: ");
                //  Lab#2Task1
                Console.WriteLine("Task 1: ");
                RectangleFigure rect = new RectangleFigure();
                rect.Draw();
                SquareFigure square = new SquareFigure();
                square.Draw();
                //  Lab#2Task2
                Console.WriteLine("Task 2: ");
                Console.WriteLine("Look my code");
                RectangleReadOnly rectangleRead = new RectangleReadOnly(2, 3);
                SquareReadOnly    squareRead    = new SquareReadOnly(2, 3);
                //  Lab#2Task3
                Console.WriteLine("Task 3: ");
                FigureVirtual figure = new FigureVirtual(2, 3);
                figure.Draw();
                FigureVirtual newfigure1 = new RectangleVirtual(2, 3);
                newfigure1.Draw();
                FigureVirtual newfigure2 = new SquareVirtual(2, 3);
                newfigure2.Draw();
                //   Lab#2Task4
                Console.WriteLine("Task 4: ");
                FigureDraw    figuretoDraw  = new FigureDraw(2, 3);
                RectangleDraw rectangleDraw = new RectangleDraw(2, 3);
                figuretoDraw.DrawAll(figuretoDraw, rectangleDraw);
                //   Lab#3Task1
                Console.WriteLine("\t Lab 3: ");
                Console.WriteLine("Task 1: ");
                List <Person>       newList = new List <Person>();
                CreateDisplayPerson create  = new CreateDisplayPerson(newList);
                create.CreateSomePerson();
                create.DisplayPerson();
                //   Lab#3Task2
                Console.WriteLine("Task 2: ");
                AddRangePerson add = new AddRangePerson(newList);
                add.AddTwoPerson();
                add.DisplayPhoneNumbers();
                //   Lab#3Task3
                Console.WriteLine("Task 3: ");
                RandomList randomList = new RandomList();
                Console.Write("Enter number of Page: ");
                string numberPage = Console.ReadLine();
                int    number;
                bool   success = Int32.TryParse(numberPage, out number);
                if (success)
                {
                    number = Int32.Parse(numberPage);
                    randomList.DisplayPage(number);
                }
                else
                {
                    Console.WriteLine("Please enter number as digit");
                    break;
                }
                break;

            default:
                Console.WriteLine("Choose 1 or 2 variant");
                break;
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            bool alive = true;

            while (alive)
            {
                ConsoleColor color = Console.ForegroundColor;
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.WriteLine("1. Task 1 \t 2. Task 2  \t  3. Task 3 \t 4. EXIT \t \n");
                Console.WriteLine("Input your choice:");
                Console.ForegroundColor = color;

                try
                {
                    int number = Convert.ToInt32(Console.ReadLine());

                    switch (number)
                    {
                    case 1:
                        Console.WriteLine("You choosed TASK 1: \n");
                        ConsoleColor consoleColor = Console.ForegroundColor;
                        Console.ForegroundColor = ConsoleColor.DarkGreen;
                        Console.WriteLine("1. Task 1.1 \t 2. Task 1.2  \t  3. Task 1.3 \t 4. Task 1.4 \t 5. Task 1.5 \t \n");
                        Console.WriteLine("Input your choice:");
                        Console.ForegroundColor = consoleColor;
                        int n = Convert.ToInt32(Console.ReadLine());

                        switch (n)
                        {
                        case 1:
                            var tuple11          = GetValues();
                            var tuple12          = GetValues();
                            var rectangleMethods = new RectangleMethods(tuple11, tuple12);
                            rectangleMethods.Area();
                            rectangleMethods.Perimetr();
                            break;

                        case 2:
                            var tuple21             = GetValues();
                            var tuple22             = GetValues();
                            var rectangleProperties = new RectangleProperties(tuple21, tuple22);
                            Console.WriteLine($"Rectangle area is {rectangleProperties.Area}");
                            Console.WriteLine($"Rectangle perimetr is {rectangleProperties.Perimetr}");
                            break;

                        case 3:
                            Circle circle = new Circle();
                            circle.Length(GetRadius());
                            circle.Area(GetRadius());
                            break;

                        case 4:
                            var tuple31 = GetValues();
                            var tuple32 = GetValues();
                            RectangleStatic.Area(tuple31, tuple32);
                            RectangleStatic.Perimetr(tuple31, tuple32);

                            CircleStatic.Area(GetRadius());
                            CircleStatic.Length(GetRadius());
                            break;

                        case 5:
                            ComplexNumber complex  = new ComplexNumber(GetDoubleValue(), GetDoubleValue());
                            ComplexNumber complex2 = new ComplexNumber(GetDoubleValue(), GetDoubleValue());
                            Console.WriteLine($" Multiply : {complex * complex2}");
                            Console.WriteLine($" Divide : {complex / complex2}");
                            break;
                        }
                        break;

                    case 2:
                        Console.WriteLine("You choosed TASK 2: \n");
                        ConsoleColor console = Console.ForegroundColor;
                        Console.ForegroundColor = ConsoleColor.DarkGreen;
                        Console.WriteLine("1. Task 2.1 and 2.2 \t  2. Task 2.3 \t 3. Task 2.4 \t \n");
                        Console.WriteLine("Input your choice:");
                        Console.ForegroundColor = console;
                        int num = Convert.ToInt32(Console.ReadLine());

                        switch (num)
                        {
                        case 1:
                            SquareAbstract    squareAbstract    = new SquareAbstract(1, 2);
                            RectangleAbstract rectangleAbstract = new RectangleAbstract(2, 3);
                            squareAbstract.Draw();
                            rectangleAbstract.Draw();
                            break;

                        case 2:
                            SquareVirtual    squareVirtual    = new SquareVirtual(2, 3);
                            RectangleVirtual rectangleVirtual = new RectangleVirtual(5, 6);
                            FigureVirtual    figureVirtual    = new FigureVirtual(4, 3);
                            squareVirtual.Draw();
                            rectangleVirtual.Draw();
                            figureVirtual.Draw();
                            break;

                        case 3:
                            IDrawable drawable  = new Figure(4, 7);
                            Figure    figure    = new Figure(3, 45);
                            Rectangle rectangle = new Rectangle(3, 6);
                            Square    square    = new Square(45, 45);
                            DrawAll(drawable, figure, rectangle, square);
                            break;
                        }
                        break;

                    case 3:
                        Console.WriteLine("You choosed TASK 3: \n");
                        var personList = CreateList();
                        AddRangeToList(personList);

                        Console.WriteLine();

                        Console.WriteLine("Task 3.3: ");
                        var list    = Random();
                        var newList = ModifyList(list);
                        var pages   = newList.Partition();
                        pages.DisplayPage();
                        break;

                    case 4:
                        alive = false;
                        continue;
                    }
                }
                catch (Exception ex)
                {
                    color = Console.ForegroundColor;
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(ex.Message);
                    Console.ForegroundColor = color;
                }
            }
        }