private static void Main(string[] args)
        {
            Helper.Setup();

            while ((maze = TestMazeFactory.GetNext()) != null)
            {
                Helper.PrintHeading("Minimal Distances In The Labytinth Of Doom");

                Helper.WriteLine("Labyrinth Before: ", ConsoleColor.DarkCyan);
                PrintLabyrinth(maze);
                Console.WriteLine();

                unexploredPositions = new Queue <MatrixPosition>();
                DoNextLabyrinth();

                Helper.WriteLine("Labyrinth After: ", ConsoleColor.DarkGreen);
                PrintLabyrinth(maze);
                Console.WriteLine();

                Helper.WriteLine("Press a key to test the next labyrinth...", ConsoleColor.DarkRed);
                Console.ReadKey(true);
                Console.Clear();
            }

            Helper.WriteLine(
                "Completed!!!",
                ConsoleColor.DarkGreen);
        }
Beispiel #2
0
        private static void Main(string[] args)
        {
            ConsoleMio.PrintHeading("OOP Principles - Part 1 - Students And Workers");

            var students = StudentsGenerator.Generate(10)
                           .OrderBy(s => s.Grade);

            ConsoleMio.WriteLine("Students by grade: \n", Info);
            PrintPeople(students);

            var workers = WorkerGenerator.Generate(10, 11)
                          .OrderByDescending(w => w.MoneyPerHour());

            ConsoleMio.WriteLine("Workerks by income: \n", Info);
            PrintPeople(workers);

            var people = new List <Human>(students);

            people.AddRange(workers);

            people = people
                     .OrderBy(p => p.FirstName)
                     .ThenBy(p => p.LastName)
                     .ToList();

            ConsoleMio.WriteLine("People by name: \n", Info);
            PrintPeople(people);
        }
        private static void Main()
        {
            ConsoleMio.PrintHeading("Homework: Defining Classes Part 2 - Euclidean Space");

            var startPoint = new Point3D(12, 2, 1);

            ConsoleMio
            .Write("Creating a start point: ", color: Info)
            .WriteLine(startPoint, color: Result)
            .WriteLine();

            var destinationPoint = new Point3D(3003232, 512312374, 1);

            ConsoleMio
            .Write("Creating a destination point: ", color: Info)
            .WriteLine(destinationPoint, color: Result)
            .WriteLine();

            var distance = EuclideanSpaceMethods.DistanceBetweenPoints(startPoint, destinationPoint);

            ConsoleMio
            .Write("Distance between points: ", color: Info)
            .WriteLine(distance, color: Result)
            .WriteLine();


            var sampleRout = new Path(startPoint, destinationPoint);

            PathStorage.SavePath(sampleRout);
            var loadedRout = PathStorage.LoadPath();

            ConsoleMio
            .WriteLine("Creating a sample route", color: Info)
            .WriteLine("Saving route to disk...", color: Info)
            .WriteLine("Loading the route from disk...", color: Info)
            .WriteLine("Printing the points in the stored route: ", Info)
            .WriteLine();

            foreach (var point in loadedRout.PointsInPath)
            {
                ConsoleMio.FormatLine("\t{0}", color: Result, args: point);
            }

            ConsoleMio.WriteLine();
        }
        private static void Main(string[] args)
        {
            ConsoleMio.Setup();

            while ((maze = TestMazeFactory.GetNext()) != null)
            {
                ConsoleMio.PrintHeading("Task 14 Minimal Distances In The Labyrinth Of Doom");

                ConsoleMio.WriteLine("Labyrinth Before: ", DarkCyan);
                PrintLabyrinth(maze);
                ConsoleMio.WriteLine();

                unexploredPositions = new LinkedQueue <MatrixPosition>();
                DoNextLabyrinth();

                ConsoleMio.WriteLine("Labyrinth After: ", DarkGreen);
                PrintLabyrinth(maze);
                ConsoleMio.WriteLine();

                ConsoleMio.WriteLine("Press a key to test the next labyrinth...", DarkRed);
                Console.ReadKey(true);
                Console.Clear();
            }

            ConsoleMio.WriteLine(
                "Completed!!! Thank you very much for looking all the tasks!",
                DarkGreen);
        }
        private static void Prompt()
        {
            const string triangle = "Create a Triangle";
            const string rect     = "Create a Rectangle";
            const string square   = "Create a Square";
            const string quit     = "Quit";

            var menu = ConsoleMio.CreatePromptMenu <string>(
                "What would you like to do?",
                new[] { triangle, rect, square, quit });

            var choice = menu.Show(Black, Warning);

            ConsoleMio.WriteLine();

            double[] args;
            switch (choice)
            {
            case triangle:
                args = ReadInput("Enter hypotenuse and side lengths: ", 2);
                CreateTriangle(args[0], args[1]);
                break;

            case rect:
                args = ReadInput("Enter A and B sides: ", 2);
                CreateRectangle(args[0], args[1]);
                break;

            case square:
                args = ReadInput("Enter the square side: ", 1);
                CreateSquare(args[0]);
                break;

            case quit:
                ConsoleMio.WriteLine("Byem bye...", DarkRed);
                Thread.Sleep(1000);
                Environment.Exit(0);
                break;

            default:
                throw new ApplicationException("Invalid menu choice");
            }
        }
 private static void IterationAction(int i)
 {
     if (RecursionIterator.IteratorsInstances.Count < n)
     {
         var nestedIterator = new RecursionIterator(n);
         nestedIterator.Iterate(IterationAction);
     }
     else
     {
         Console.WriteLine(string.Join(
                               "", RecursionIterator.IteratorsInstances.Select(r => r.CurrentPosition)), DarkMagenta);
     }
 }
        private static void Main()
        {
            ConsoleMio.PrintHeading("OOP Principles - Part 1 - Animals");

            var animals = GenerateAnimals();

            PrintAnimals(animals);

            var averageAges = GetAverageAges(animals);

            ConsoleMio.PromptToContinue(Info);
            ConsoleMio.WriteLine("Average Ages:", Info)
            .WriteLine(Dash, Info);

            foreach (var key in averageAges.Keys)
            {
                ConsoleMio.Write(key, Result)
                .Write(" average age: ", Info)
                .FormatLine("{0:F}", Result, averageAges[key]);
            }

            ConsoleMio.WriteLine(Dash, Info)
            .WriteLine();
        }
        private static void Loop()
        {
            while (true)
            {
                string[] actions =
                {
                    "Register a customer",
                    "Review existing customers",
                    "Quit"
                };

                var menu = ConsoleMio.CreatePromptMenu(
                    "What would you like to do?", actions);

                var choice = menu.Show(Black, Warning);

                if (choice == actions[0])
                {
                    commandInterface.RegisterCustomer();
                }
                else if (choice == actions[1])
                {
                    commandInterface.ReviewCustomers();
                }
                else if (choice == actions[2])
                {
                    OnQuit();
                }
                else
                {
                    throw new NotImplementedException("This action isn't implemented yet");
                }

                ConsoleMio.WriteLine();
            }
        }
Beispiel #9
0
        private static void TestReadInput()
        {
            var input = ConsoleMio.ReadInput(
                "Reading test input:",
                new[] { " " },
                double.Parse,
                2,
                Red,
                Blue,
                DarkCyan);

            foreach (var number in input)
            {
                ConsoleMio.WriteLine(number, Blue);
            }
        }
        private static void Main()
        {
            ConsoleMio.PrintHeading("Extension Methods Tests");

            ConsoleMio.WriteLine("What would you like to test: ", Info);
            var menu = ConsoleMio.CreateMenu(new[]
            {
                nameof(Enumerable_Tests),
                nameof(Student_Tests),
                nameof(StringBuilder_Test),
                nameof(StartStopTimer),
                nameof(Quit)
            });

            while (true)
            {
                Execute(menu, typeof(StartTests));
            }
        }