static void Main(string[] args)
        {
            //1. Zadatak

            double[] numbers = new double[] { 7, 4, 6, 14, 9, 1, 3, 2, 0, 12, 5 };

            NumberSequence sequentialSortSequence = new NumberSequence(numbers);

            sequentialSortSequence.SetSortStrategy(new SequentialSort());

            NumberSequence bubbleSortSequence = new NumberSequence(numbers);

            bubbleSortSequence.SetSortStrategy(new BubbleSort());

            NumberSequence combSortSequence = new NumberSequence(numbers);

            combSortSequence.SetSortStrategy(new CombSort());

            sequentialSortSequence.Sort();
            bubbleSortSequence.Sort();
            combSortSequence.Sort();

            Console.WriteLine(sequentialSortSequence.ToString());
            Console.WriteLine(bubbleSortSequence.ToString());
            Console.WriteLine(combSortSequence.ToString());



            //2. Zadatak
            NumberSequence numberSequence = new NumberSequence(numbers);

            numberSequence.SetSearchStrategy(new SeqSearch());

            Console.WriteLine(numberSequence.Search(7));
            Console.WriteLine(numberSequence.Search(14));



            //3. i 4. Zadatak
            SystemDataProvider dataProvider = new SystemDataProvider();

            dataProvider.Attach(new FileLogger("data.txt"));
            dataProvider.Attach(new ConsoleLogger());

            while (true)
            {
                dataProvider.GetCPULoad();
                dataProvider.GetAvailableRAM();
                System.Threading.Thread.Sleep(1000);
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            NumberSequence sequence       = new NumberSequence(new double[] { 8, 2, 1, 7, 6, 5, 4, 3, 10, 9 });
            NumberSequence sequencebubble = sequence;
            NumberSequence sequencecomb   = sequence;

            sequence.SetSortStrategy(new SequentialSort());
            sequencebubble.SetSortStrategy(new BubbleSort());
            sequencecomb.SetSortStrategy(new CombSort());
            sequence.Sort();
            Console.WriteLine("Sequential sort:");
            Console.WriteLine(sequence.ToString());
            sequencebubble.Sort();
            Console.WriteLine("Bubble sort:");
            Console.WriteLine(sequencebubble.ToString());
            sequencecomb.Sort();
            Console.WriteLine("Comb sort:");
            Console.WriteLine(sequencecomb.ToString());

            sequence.SetSearchStrategy(new LinearSearch());
            int index = sequence.Search(11);

            if (index != -1)
            {
                Console.WriteLine("Index of given number in the array: " + index);
            }
            else
            {
                Console.WriteLine("There is not given number in the array!");
            }
            int index1 = sequence.Search(10);

            if (index1 != -1)
            {
                Console.WriteLine("Index of given number in the array: " + index1);
            }
            else
            {
                Console.WriteLine("There is not given number in the array!");
            }
        }