示例#1
0
        // Methode waarmee makkelijker gelogd kan worden. Dit zorgt ervoor dat er minder code per event-handler geschreven hoeft te worden.
        // De verschillende vormen zijn:
        // 1: creaties
        // 2: zoeken
        // 3: sorteren
        public string Logger(string method, double duration, AD.Players player, string output, int action)
        {
            StringBuilder build = new StringBuilder();
            string        time  = duration.ToString();

            if (action == 1)
            {
                build.AppendFormat("{2}{0} in: {1} nanoseconds. {2}", method, time, Environment.NewLine);
            }
            else if (action == 2)
            {
                if (!(output.Contains("=") || !(duration > 0)))
                {
                    build.AppendFormat("{2}{0} found in: {1}. {2}Found at: {3} nanoseconds. {2}", method, time, Environment.NewLine, output);
                }
                else
                {
                    build.AppendFormat("Something went wrong, try another input" + Environment.NewLine);
                }
            }
            else if (action == 3)
            {
                build.AppendFormat("{2}{0} in: {1} nanoseconds.{2}", method, duration, Environment.NewLine);
            }

            string result = build.ToString();

            return(result);
        }
示例#2
0
        // Laat volgende node zien.
        private void ShowNext_Click(object sender, EventArgs e)
        {
            PlayerIterator.NextLink();
            Node <AD.Players> node = PlayerIterator.GetCurrent();

            AD.Players player = node.data;
            IteratorShow.Text = GetPlayerStats(player);
        }
示例#3
0
        public static string GetPlayerStats(AD.Players player)
        {
            string stats = null;

            stats += "ID";
            stats += player.GetId().ToString();
            stats += "Name: ";
            stats += player.GetName();
            stats += ", Highscore: ";
            stats += player.GetScore().ToString();
            stats += Environment.NewLine;

            return(stats);
        }
示例#4
0
        private void ArrayMin()
        {
            QPCounter.Start();
            AD.Players player = AD.Search.Min <AD.Players> .Search(_RandomArray);

            QPCounter.Stop();
            double duration = QPCounter.Duration(size);
            string playerId = player.GetId().ToString();

            if (ArrayCreated == false)
            {
                playerId = "Create an Array First!";
            }
            ResultBox.Text += Logger("Min in array", duration, player, playerId, 2);
        }
示例#5
0
        // Methoden van de verschillende zoekmethoden.
        public string FormBinarySearch(int key)
        {
            string answer = "";

            PlayerBinaryNode = BinarySearchTree <AD.Players> .Find(key);

            AD.Players player = PlayerBinaryNode.Data;
            if (answer != null)
            {
                answer = player.GetId().ToString();
            }
            else
            {
                answer = "Key could not be found";
            }
            return(answer);
        }
示例#6
0
        public AD.Players MinBinSearch()
        {
            AD.Players player = BinarySearchTree <AD.Players> .FindMin();

            return(player);
        }