Пример #1
0
        private static void TestHeading()
        {
            ConsoleMio.PrintHeading("Even heading");

            ConsoleMio.PrintHeading("Odd heading");

            ConsoleMio.PrintHeading("Some really long heading text that will probably span multiple lines. Dobar si pesho. Some really long heading text that will probably span multiple lines.");
        }
        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);
        }
        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);
        }
Пример #4
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: OOP Principles - Part 2 - Shapes");

            while (true)
            {
                ConsoleMio.Setup();
                Prompt();
            }
        }
        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));
            }
        }
Пример #7
0
        private static void Main()
        {
            Console.Setup();
            Console.PrintHeading("Task 2 Generate All Combinations With Duplicates");

            int[] collection             = { 1, 2, 3, 4, 5 };
            int   combinationSetsLength  = 2;
            CombinatoricsGen <int> combo =
                new CombinatoricsesWithDuplicates <int>(combinationSetsLength, collection);

            var resultPrinter = new ResultPrinter(Console);

            resultPrinter.DispalyResults(collection, combinationSetsLength, combo);

            Console.PrintHeading("Task 3 Generate All Regular Combinations");

            combo = new CombinatoricsesRegular <int>(combinationSetsLength, collection);

            resultPrinter.DispalyResults(collection, combinationSetsLength, combo);
        }
        private static void Main()
        {
            ConsoleMio.PrintHeading("Homework: OOP Principles - Part 2 - Bank Accounts");

            bestBank = File.Exists(DataFilePath)
                ? BinaryHandler.ReadFromBinaryFile <Bank>(DataFilePath)
                : new Bank("Best Bank", 3.5m);

            commandInterface = new CommandInterface(ConsoleMio, bestBank, OnQuit);

            Loop();
        }
        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);
        }
        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);
        }
Пример #11
0
        private static void Main()
        {
            Console.Setup();

            Console.PrintHeading("Task 4 Permutations of numbers");

            ResultPrinter printer = new ResultPrinter(Console);

            int[] collection = { 1, 2, 3, 4 };

            int subsetSize = 4;

            CombinatoricsGen <int> combo = new PermutationsGenerator <int>(subsetSize, collection);

            printer.DispalyResults(collection, collection.Length, combo);
        }
        private static void Main()
        {
            Console.Setup();

            Console.PrintHeading("Task 5 Print Ordered Subsets of K from Set of N");

            string[] mainSet = { "hi", "a", "b" };

            int subsetLength = 2;

            var printer = new ResultPrinter(Console);

            CombinatoricsGen <string> combo = new PermutationsWithRepetition <string>(subsetLength, mainSet);

            printer.DispalyResults(mainSet, subsetLength, combo);
        }
Пример #13
0
        private static void Main()
        {
            ConsoleMio.PrintHeading("Homework: Defining Classes Part 2 - Generic Class");

            GenericList <int> intList = CreateIntList();

            InitNumbers(intList);
            ChangeValue(intList, 5, 2000);
            AddNumbers(intList);
            TestInsertAt(intList, 2, -123);
            TestRemoveAt(intList, 0);
            ShowMax(intList);
            ShowMin(intList);
            TestIndexOf(intList, 100);
            TestIndexOf(intList, -100);
        }
        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);
        }
Пример #16
0
        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();
        }