public override string ToXml() { return ($"<block type=\"{XML_TYPE_NAME}\" id=\"{BlockID}\">" + $"<field name=\"{VARIABLE_FIELD_NAME}\">{InputNumbers.First()}</field>" + "</block>"); }
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()]); }
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); }
public override Task <CalculationResponse> MultiplyNumbers(InputNumbers request, ServerCallContext context) { return(Task.FromResult(new CalculationResponse { Response = "Numbers multiplied successfully.", Result = request.FirstNumber * request.SecondNumber }));;; }
public override string ToString() { return("Variable: " + InputNumbers.First()); }
public override Block TrueCopy(DFG <Block> dfg) { return(new GetNumberVariable(InputNumbers.First(), OutputVariable, BlockID, CanBeScheduled)); }
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; } } }