Exemple #1
0
        private bool ValidateInput()
        {
            if (_pruferCode.GetText().Equals("Empty"))
            {
                return(true);
            }
            var values         = _pruferCode.GetText().Split(" ");
            int elementsAmount = values.Length;

            if (elementsAmount == 0 || elementsAmount > 25)
            {
                return(false);
            }

            foreach (string value in values)
            {
                if (!Int32.TryParse(value, out int number))
                {
                    return(false);
                }
                if (number < 1 || number > elementsAmount + 2)
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #2
0
        private bool ValidateInput()
        {
            if (!Int32.TryParse(_edgesAmount.GetText(), out int edges))
            {
                return(false);
            }

            return(edges >= 1 && edges <= _vertices);
        }
Exemple #3
0
 private void OnCheckButtonClick(IItem sender, MouseArgs args)
 {
     if (ValidateInput())
     {
         var eventArgs = new GotCorrectCheckPathEventArgs
         {
             FirstVertex  = Int32.Parse(_firstVertex.GetText()),
             SecondVertex = Int32.Parse(_secondVertex.GetText())
         };
         _output.SetText(string.Empty);
         OnGotCorrectInput(eventArgs);
     }
     else
     {
         _output.SetText("Incorrect Input");
         _output.SetHeight(50);
     }
 }
Exemple #4
0
        private bool ValidateInput()
        {
            if (!(Int32.TryParse(_verticesAmount.GetText(), out int vertices) &&
                  Double.TryParse(_density.GetText(), out double density) &&
                  Int32.TryParse(_minWeight.GetText(), out int minWeight) &&
                  Int32.TryParse(_maxWeight.GetText(), out int maxWeight)))
            {
                return(false);
            }

            return(vertices >= 2 &&
                   vertices <= _maxVertices &&
                   density >= 0 &&
                   density <= 1 &&
                   minWeight >= -100 &&
                   minWeight <= 100 &&
                   maxWeight >= -100 &&
                   maxWeight <= 100 &&
                   minWeight <= maxWeight);
        }
Exemple #5
0
 private void OnButtonClick(bool dijkstra, bool bellmanFord, bool floyd)
 {
     if (ValidateInput())
     {
         var eventArgs = new GotCorrectFindPathEventArgs
         {
             FirstVertex  = Int32.Parse(_firstVertex.GetText()),
             SecondVertex = Int32.Parse(_secondVertex.GetText()),
             Dijkstra     = dijkstra,
             BellmanFord  = bellmanFord,
             Floyd        = floyd
         };
         _output.SetText(string.Empty);
         OnGotCorrectInput(eventArgs);
     }
     else
     {
         _output.SetText("Incorrect Input");
         _output.SetHeight(50);
     }
 }