static void Main(string[] args) { var select = -1; do { Console.Clear(); Console.WriteLine("Task 02. OOP Basics."); Console.WriteLine("Select the number of a task to check."); Console.WriteLine("1. Round."); Console.WriteLine("2. Triangle."); Console.WriteLine("3. User."); Console.WriteLine("4. My String."); Console.WriteLine("5. Employee."); Console.WriteLine("6. Ring."); Console.WriteLine("7. Vector Graphics Editor."); Console.WriteLine("8. Game."); Console.WriteLine("0. Exit."); if (int.TryParse(Console.ReadLine(), out select)) { switch (select) { case 1: Console.Clear(); Console.WriteLine("Task 2.1. Round."); RoundDemo.Demo(); Console.WriteLine("Press enter to continue."); Console.ReadLine(); break; case 2: Console.Clear(); Console.WriteLine("Task 2.2. Triangle."); TriangleDemo.Demo(); Console.WriteLine("Press enter to continue."); Console.ReadLine(); break; case 3: Console.Clear(); Console.WriteLine("Task 2.3. User."); UserDemo.Demo(); Console.WriteLine("Press enter to continue."); Console.ReadLine(); break; case 4: Console.Clear(); Console.WriteLine("Task 2.4. My String."); MyStringDemo.Demo(); Console.WriteLine("Press enter to continue."); Console.ReadLine(); break; case 5: Console.Clear(); Console.WriteLine("Task 2.5. Employee."); EmployeeDemo.Demo(); Console.WriteLine("Press enter to continue."); Console.ReadLine(); break; case 6: Console.Clear(); Console.WriteLine("Task 2.6. Ring."); RingDemo.Demo(); Console.WriteLine("Press enter to continue."); Console.ReadLine(); break; case 7: Console.Clear(); Console.WriteLine("Task 2.7. Vector Graphics Editor."); Polymorphism.Vector_Graphics_Editor.Editor.Demo(); Console.WriteLine("Press enter to continue."); Console.ReadLine(); break; case 8: Console.Clear(); Console.WriteLine("Task 2.8. Game."); Polymorphism.Game.GameDemo.Demo(); Console.WriteLine("Press enter to continue."); Console.ReadLine(); break; case 0: Console.WriteLine("Good luck!"); Console.WriteLine("Press enter to exit."); break; default: Console.WriteLine("Wrong number. Try again."); Console.WriteLine("Press enter to continue."); Console.ReadLine(); break; } } else { select = -1; Console.WriteLine("Invalid input. Try again."); Console.WriteLine("Press enter to continue."); Console.ReadLine(); } }while (select != 0); Console.ReadLine(); }
static int Main(string[] args) { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Green; Console.Title = "Playgound Pro C# .Net Core API"; string[] theArgs = Environment.GetCommandLineArgs(); foreach (string arg in theArgs) { Console.WriteLine("Arg: {0}", arg); } ShowEnvironmentDetails(); ShowNumberFormat(); ShowDefaultDeclarations(); TryFromStringWithTryParse(); Playground playground = new Playground(); playground.LinqQueryOverInts(); playground.JaggedMultiDimensionalArrays(); playground.CalculateAverage(out double average, 4.0, 3.0, 5.0); Console.WriteLine(@"Average {0}", average); Playground.Days currDay = Playground.Days.Monday; playground.GreetOnDay(currDay); Rectangle <int> newRect = new Rectangle <int>(@"Original Rectangle Info", 1, 2); Console.WriteLine(@"Original Rect Message"); newRect.Message(); Rectangle <int> copyRect = newRect; copyRect.rectInfo.InfoString = @"Modified Rectangle Info"; Console.WriteLine(@"Copy Rect Message"); copyRect.Message(); Console.WriteLine(@"Original Rect Message post modification"); newRect.Message(); Console.WriteLine(@"Tuple members"); Tuples tuples = new Tuples(); tuples.PlayWithTuples(); Console.WriteLine(@"Split Members"); Tuples splitNames = new Tuples(); var(first, _, last) = splitNames.SplitNames("Vaibhav Ramesh Panchal"); Console.WriteLine($"{first} {last}"); Point <double> deconstructedTuple = new Point <double>(30.0f, 40.0f); var(xPos, yPos, color) = deconstructedTuple.Deconstruct(); Console.WriteLine($"xPos : {xPos}, yPos : {yPos}, color : {color}"); // Exception DemoInteface try { HarleyDavidson harleyDavidson = new HarleyDavidson("harley", 1, "HR1001"); for (int i = 0; i < 5000; i++) { harleyDavidson.SpeedUpBy(i); } } catch (Exception e) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("===Speed Exception==="); Console.WriteLine(e.Message); Console.WriteLine(e.TargetSite); Console.WriteLine(e.StackTrace); Console.WriteLine("===Speed Exception==="); Console.ForegroundColor = ConsoleColor.White; } // Interface //ShapesDemo.DemoInteface(); ShapesDemo.DemoExplicitInterface(); //EnumDemo.Demo(); //EnumDemo.DemoCustomerEnumerator(); EnumDemo.DemoYield(); EmployeeDemo.DemoSortedSet(); Calculator <int> .CalculatorDemo(); CarDemo carDemo = new CarDemo(); carDemo.DemoEvents(); NumberDemo.LamdaDemo(); PersonCollection.PersonCollectionDemo(); RectangleFloat.CastDemo(); Console.ReadKey(); return(0); }