static void Main(string[] args) { Shape s1 = new Circle() { Radius = 2.0, Color = Color.White }; Shape s2 = new Rectangle() { Width = 3.5, Height = 4.2, Color = Color.Black }; IShape s3 = new CircleAbstract() { Radius = 2.0, Color = Color.White }; IShape s4 = new RectangleAbstract() { Width = 3.5, Height = 4.2, Color = Color.Black }; Console.WriteLine(s1); Console.WriteLine(s2); Console.WriteLine(s3); Console.WriteLine(s4); }
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; } } }