コード例 #1
0
ファイル: GetNumberVariable.cs プロジェクト: TheAIBot/Bioly
 public override string ToXml()
 {
     return
         ($"<block type=\"{XML_TYPE_NAME}\" id=\"{BlockID}\">" +
          $"<field name=\"{VARIABLE_FIELD_NAME}\">{InputNumbers.First()}</field>" +
          "</block>");
 }
コード例 #2
0
ファイル: GetNumberVariable.cs プロジェクト: TheAIBot/Bioly
 public override float Run <T>(Dictionary <string, float> variables, CommandExecutor <T> executor, Dictionary <string, BoardFluid> dropPositions)
 {
     if (!variables.ContainsKey(InputNumbers.First()))
     {
     }
     return(variables[InputNumbers.First()]);
 }
コード例 #3
0
ファイル: Player.cs プロジェクト: JokubasRa/YatzyG
        public bool ParseInputReroll(string line)
        {
            if (line == null)
            {
                throw new NullReferenceException();
            }
            if (line.Trim().Equals("0"))
            {
                DiceToReroll.Clear();
                EndOfThrowing = true;
                return(true);
            }

            List <int> InputNumbers;

            try
            {
                InputNumbers = line.Split().Select(int.Parse).ToList();
            }
            catch (Exception)
            {
                Console.WriteLine("Invalid Input: Could not recognise numbers. Try again.");
                return(false);
            }

            if ((InputNumbers.Count() > NUM_OF_DICE || InputNumbers.Count() < 1) || InputNumbers.Any(x => x > NUM_OF_DICE || x < 1))
            {
                Console.WriteLine("Invalid input: Too many entered numbers or they are out of range. Try again.");
                return(false);
            }

            DiceToReroll = PlayerDice.Where(x => InputNumbers.Contains(x.IndexOfDice)).ToList();
            return(true);
        }
コード例 #4
0
 public override Task <CalculationResponse> MultiplyNumbers(InputNumbers request, ServerCallContext context)
 {
     return(Task.FromResult(new CalculationResponse
     {
         Response = "Numbers multiplied successfully.",
         Result = request.FirstNumber * request.SecondNumber
     }));;;
 }
コード例 #5
0
ファイル: GetNumberVariable.cs プロジェクト: TheAIBot/Bioly
 public override string ToString()
 {
     return("Variable: " + InputNumbers.First());
 }
コード例 #6
0
ファイル: GetNumberVariable.cs プロジェクト: TheAIBot/Bioly
 public override Block TrueCopy(DFG <Block> dfg)
 {
     return(new GetNumberVariable(InputNumbers.First(), OutputVariable, BlockID, CanBeScheduled));
 }
コード例 #7
0
        private void BtnOperators_On_Click(object sender, RoutedEventArgs e)
        {
            Button button = e.Source as Button;

            if (button != null && (OperatorAllowed || (OnlyEqualSignAllowed && button.Content.ToString() == "=")))
            {
                //Checking to see if Calculator has been reseted
                string inputText;
                if (IsCalcInResetState)
                {
                    CalcInput.Text   = "0";
                    CalcDisplay.Text = "";
                }

                if (CalcInput.Text.Contains("√"))
                {
                    inputText = BasicHelper.ConvertNumberToRoot(CalcInput.Text).ToString();
                }
                else if (CalcInput.Text.Contains("!"))
                {
                    inputText = BasicHelper.DetermineFactorial(CalcInput.Text).ToString();
                }
                else
                {
                    inputText = CalcInput.Text;
                }

                var inputTextConvertedToDouble = Convert.ToDouble(inputText);

                CalcDisplay.Text += inputText + " ";

                InputNumbers.Add(inputTextConvertedToDouble);
                if (button.Content.ToString() != "=")
                {
                    CalcDisplay.Text += " " + button.Content + " ";
                }

                if (InputNumbers.Count() > 1)
                {
                    Result = BasicHelper.DetermineOperatorAndCalculate(Operator, Result, inputTextConvertedToDouble);

                    if (Result == null)
                    {
                        if (Operator == "/")
                        {
                            CalcInput.Text = $"∞";
                        }
                        else
                        {
                            CalcInput.Text = "Syntax Error!";
                        }
                    }
                    else
                    {
                        CalcInput.Text = $"{Result}";
                    }

                    ResultShowingInCalcInput = true;
                }
                else if (InputNumbers.Count() > 0 && InputNumbers.Count() < 2)
                {
                    Result += InputNumbers[0];
                    ResultShowingInCalcInput = true;
                }

                if (button.Content.ToString() != "=")
                {
                    Operator           = button.Content.ToString();
                    IsCalcInResetState = false;
                    if (Operator == "^" || Operator == "^-")
                    {
                        OperatorAllowed      = false;
                        OnlyEqualSignAllowed = false;
                    }
                }
                else
                {
                    InputNumbers             = new List <double>();
                    Result                   = 0;
                    Operator                 = "";
                    ResultShowingInCalcInput = true;
                    IsCalcInResetState       = true;
                }
            }
        }