Exemplo n.º 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);
        }
Exemplo n.º 2
0
        private bool ValidateInput()
        {
            if (!Int32.TryParse(_edgesAmount.GetText(), out int edges))
            {
                return(false);
            }

            return(edges >= 1 && edges <= _vertices);
        }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
     }
 }