private static void PrintLabyrinth(string[,] maze)
        {
            for (int i = 0; i < maze.GetLength(0); i++)
            {
                for (int j = 0; j < maze.GetLength(1); j++)
                {
                    string current = maze[i, j];

                    if (current.Equals("x", StringComparison.OrdinalIgnoreCase))
                    {
                        Helper.Write("x ", ConsoleColor.Red);
                    }
                    else
                    {
                        int parseResult;
                        if (!current.Equals("0") &&
                            int.TryParse(current, out parseResult))
                        {
                            Helper.Write($"{current} ", ConsoleColor.Green);
                        }
                        else
                        {
                            Console.Write("{0} ", current);
                        }
                    }
                }

                Console.WriteLine();
            }
        }
Beispiel #2
0
 private static void PrintList <T>(GenericList <T> list) where T : IComparable <T>
 {
     ConsoleMio
     .Write("List size: ", color: Info)
     .WriteLine(list.Count, color: Result)
     .WriteLine(list, color: Result)
     .WriteLine();
 }
        private static void CreateSquare(double side)
        {
            ConsoleMio
            .Write("Creating a square with side of: ", Info)
            .WriteLine(side, Result);

            var square = new Square(side);

            PrintResult(square);
        }
        static void Main()
        {
            ConsoleMio.PrintHeading("Homework: Defining Classes Part 2 - Generic Matrix");

            var version = typeof(TestMatrices).GetCustomAttribute <SpecialVersionAttribute>(false);

            ConsoleMio
            .Write("Version Information: ", color: Info)
            .WriteLine(version, color: Result)
            .WriteLine();

            Matrix <double> realMatrix = GenerateMatrix(3, 3);

            PrintMatrix(realMatrix);
        }
        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)
        {
            Mio.Setup();

            Mio.PrintHeading("Task 10 Shortest Sequence Of Operations From N to M");

            Mio.Write("Enter number N = ", Black);
            int n = int.Parse(Mio.ReadLine(Red));

            Mio.Write("Enter number M = ", Black);
            int m = int.Parse(Mio.ReadLine(Red));

            // Using the stack from Task 12
            Stack <int> steps = new Stack <int>();

            steps.StackUp(m);

            int current = m;

            while (current > n)
            {
                if (current % 2 == 0 && current / 2 >= n)
                {
                    current /= 2;
                    steps.StackUp(current);
                }
                else if (current - 2 >= n)
                {
                    current -= 2;
                    steps.StackUp(current);
                }
                else if (current - 1 >= n)
                {
                    current -= 1;
                    steps.StackUp(current);
                }
            }

            Mio
            .Write("Result: ", DarkGreen)
            .WriteLine(string.Join(" → ", steps), DarkBlue);
        }
        private static void Main()
        {
            Console.Setup();

            Console.PrintHeading("Task 1 Iteration Simulation ");

            Console.Write("Enter n: ", DarkCyan);
            n          = int.Parse(Console.ReadLine(Gray));
            collection = new int[n];

            var iterator = new RecursionIterator(n);

            iterator.Iterate(IterationAction);
        }
        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();
        }