public void MustEncloseOperandInParentheses_WhenOperandHasSamePriority_ReturnsFalse() { var operand = new Positive(new Constant("1")); var expression = new Negative(operand); Assert.IsFalse(expression.MustEncloseOperandInParentheses); }
public void MustEncloseOperandInParentheses_WhenOperandHasLowerPriority_ReturnsTrue() { var operand = new Add(new Constant("1"), new Constant("2")); var expression = new Negative(operand); Assert.IsTrue(expression.MustEncloseOperandInParentheses); }
private void ConvertCabinFever(CabinFeverSaveDataProxy proxy) { if (proxy == null) { return; } if (proxy.m_Active) { Negative.Add(new CabinFever(negative) { AfflictionType = AfflictionType.CabinFever, Location = 0, ElapsedHours = proxy.m_ElapsedHours, }); } else if (proxy.m_RiskActive) { Negative.Add(new CabinFever(negative) { AfflictionType = AfflictionType.CabinFeverRisk, Location = 0, ElapsedHours = proxy.m_ElapsedHours, }); } }
public void Destroy() { Negative?.Destroy(); Negative = null; Positive?.Destroy(); Positive = null; }
public Node UnaryExpression() { if (CurrentToken == TokenCategory.NOT) { var result = new Not() { AnchorToken = Expect(TokenCategory.NOT) }; result.Add(UnaryExpression()); return(result); } else if (CurrentToken == TokenCategory.MINUS) { var result = new Negative() { AnchorToken = Expect(TokenCategory.MINUS) }; result.Add(UnaryExpression()); return(result); } else if (firstOfSimpleExpression.Contains(CurrentToken)) { return(SimpleExpression()); } else { throw new SyntaxError(firstOfUnaryExpression, tokenStream.Current); } }
public override int GetHashCode() { int hash = 1; if (ResourceName.Length != 0) { hash ^= ResourceName.GetHashCode(); } if (HasKeywordPlanCampaign) { hash ^= KeywordPlanCampaign.GetHashCode(); } if (HasId) { hash ^= Id.GetHashCode(); } if (HasText) { hash ^= Text.GetHashCode(); } if (MatchType != global::Google.Ads.GoogleAds.V10.Enums.KeywordMatchTypeEnum.Types.KeywordMatchType.Unspecified) { hash ^= MatchType.GetHashCode(); } if (HasNegative) { hash ^= Negative.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public void CalculateTest(double first, double expected) { var calculator = new Negative(); var actualResult = calculator.CalculateTwo(first); Assert.AreEqual((int)expected, (int)actualResult); }
private void ConvertFrostbite(FrostbiteSaveDataProxy proxy) { if (proxy == null) { return; } foreach (int bodyArea in proxy.m_LocationsWithActiveFrostbite) { Negative.Add(new Frostbite(negative) { AfflictionType = AfflictionType.Frostbite, Location = bodyArea, Damage = proxy.m_LocationsCurrentFrostbiteDamage[bodyArea], }); } foreach (int bodyArea in proxy.m_LocationsWithFrostbiteRisk) { Negative.Add(new Frostbite(negative) { AfflictionType = AfflictionType.FrostbiteRisk, Location = bodyArea, Damage = proxy.m_LocationsCurrentFrostbiteDamage[bodyArea], }); } }
public void CalculationTest(double value, double answer) { var calculator = new Negative(); double actual = calculator.calculate(value); Assert.AreEqual(answer, actual, 0.001); }
private void ConvertHypothermia(HypothermiaSaveDataProxy proxy) { if (proxy == null) { return; } if (proxy.m_Active) { Negative.Add(new Hypothermia(negative) { AfflictionType = AfflictionType.Hypothermia, Location = 6, ElapsedHours = proxy.m_ElapsedHours, ElapsedWarmHours = proxy.m_ElapsedHours, Cause = proxy.m_CauseLocID, }); } else if (proxy.m_ElapsedHours > 0) { Negative.Add(new Hypothermia(negative) { AfflictionType = AfflictionType.HypothermiaRisk, Location = 6, ElapsedHours = proxy.m_ElapsedHours, ElapsedWarmHours = proxy.m_ElapsedHours, Cause = proxy.m_CauseLocID, }); } }
public void MustEncloseOperandInParentheses_WhenOperandHasHigherPriority_ReturnsFalse() { var operand = new ArrayVariable("A", new[] { new Constant("1") }); var expression = new Negative(operand); Assert.IsFalse(expression.MustEncloseOperandInParentheses); }
public void SerializeTo(GlobalSaveGameFormat global) { var afflictionDict = new Dictionary <AfflictionType, List <Affliction> >(); foreach (var affliction in Negative.Concat(Positive)) { if (!afflictionDict.ContainsKey(affliction.AfflictionType)) { afflictionDict.Add(affliction.AfflictionType, new List <Affliction>()); } afflictionDict[affliction.AfflictionType].Add(affliction); } global.Hypothermia = ConvertBackHypothermia(global.Hypothermia, afflictionDict); global.FrostBite = ConvertBackFrostBite(global.FrostBite, afflictionDict); global.FoodPoisoning = ConvertBackFoodPoisoning(global.FoodPoisoning, afflictionDict); global.Dysentery = ConvertBackDysentery(global.Dysentery, afflictionDict); global.SprainedAnkle = ConvertBackSprainedAnkle(global.SprainedAnkle, afflictionDict); global.SprainedWrist = ConvertBackSprainedWrist(global.SprainedWrist, afflictionDict); global.Burns = ConvertBackBurns(global.Burns, afflictionDict); global.BurnsElectric = ConvertBackBurnsElectric(global.BurnsElectric, afflictionDict); global.BloodLoss = ConvertBackBloodLoss(global.BloodLoss, afflictionDict); global.Infection = ConvertBackInfection(global.Infection, afflictionDict); global.InfectionRisk = ConvertBackInfectionRisk(global.InfectionRisk, afflictionDict); global.CabinFever = ConvertBackCabinFever(global.CabinFever, afflictionDict); global.IntestinalParasites = ConvertBackIntestinalParasites(global.IntestinalParasites, afflictionDict); global.BrokenRibs = ConvertBackBrokenRib(global.BrokenRibs, afflictionDict); global.WellFed = ConvertBackWellFed(global.WellFed, afflictionDict); }
private void btnNegative_Click(object sender, EventArgs e) { Negative negative = new Negative(); negative.setImage(new Bitmap(pictureBox1.Image)); negative.process(); pictureBox1.Image = negative.getImage(); }
public void NegativeFloatTest() { Negative op = new Negative(); Assert.AreEqual(_zeroFloat, op.Execute(_zeroFloat)); Assert.AreEqual(_minusOneFloat, op.Execute(_oneFloat)); }
private void btnNegative_Click(object sender, EventArgs e) { Negative negative = new Negative(); initSourceMap(); negative.setImage(_imageTemp); actions(negative, "Negative"); }
public override bool Evaluate(Client client) { // Test a client using the primitive operation bool res = Test(client); // Select a branch to follow return(res ? Positive.Evaluate(client) : Negative.Evaluate(client)); }
public void Negative_WithStringA_ThrowsRuntimeBinderException() { var variables = MakeVariables(); var operand = new Constant("A"); var expression = new Negative(operand); var actual = expression.GetExpression(variables) .Calculate(); }
public void UnaryNegativeTest() { Negative op = new Negative(); Assert.AreEqual(zeroInt, new UnaryStatement(op, zeroIntn).Evaluate(varTable)); Assert.AreEqual(minusOneInt, new UnaryStatement(op, oneIntn).Evaluate(varTable)); Assert.AreEqual(zeroFloat, new UnaryStatement(op, zeroFloatn).Evaluate(varTable)); Assert.AreEqual(minusOneFloat, new UnaryStatement(op, oneFloatn).Evaluate(varTable)); }
void MakeItNegative() { Negative.AddInteractionPunch(0.2f); if (!Interacted && !ModuleSolved && Interactable) { Audio.PlaySoundAtTransform(SFX[0].name, transform); Interacted = true; TrueNumber.text += "-"; YourAnswer += "-"; } }
private void B_Negative_Click(object sender, EventArgs e) { Bitmap image = new Bitmap(imgPreview); Bitmap negative = Negative.build(image); //previewPB.Image = negative; //imgPreview = previewPB.Image; imgPreview = negative; RGBChannelChanged(); B_RefHis.Visible = true; }
/// <summary>新建时调用</summary> protected override void OnNew() { Debug = Config.GetConfig <Boolean>("XCode.Debug", true); ShowSQL = Config.GetConfig <Boolean>("XCode.ShowSQL", Debug); SQLPath = Config.GetConfig <String>("XCode.SQLPath"); ConnMaps = Config.GetConfig <String>("XCode.ConnMaps"); TraceSQLTime = Config.GetConfig <Int32>("XCode.TraceSQLTime"); Cache.Init(); Negative.Init(); }
private Complex VoltageDrop() { if (!Positive.IsConnected() || !Negative.IsConnected()) { return(new Complex()); } var V = Positive.Node.Voltage - Negative.Node.Voltage; return(V - Voltage); }
public void Negative_WithDouble2_ReturnsDoubleMinus2() { var variables = MakeVariables(); var operand = new Constant(2.0); var expression = new Negative(operand); var actual = expression.GetExpression(variables) .Calculate(); Assert.AreEqual(-2.0, actual); }
public void Negative_WithString2_ReturnsIntegerMinus2() { var variables = MakeVariables(); var operand = new Constant("2"); var expression = new Negative(operand); var actual = expression.GetExpression(variables) .Calculate(); Assert.AreEqual(-2, actual); }
public override ReturnType Evaluate(Client client) { bool result = Test(client); if (result) { return(Positive.Evaluate(client)); } else { return(Negative.Evaluate(client)); } }
private Complex OhmsLaw() { if (!Positive.IsConnected() || !Negative.IsConnected()) { return(new Complex()); } var V = Positive.Node.Voltage - Negative.Node.Voltage; var I = Positive.Current; var R = Resistance; return(V - R * I); }
public async override Task <bool> Evaluate(Zahtjev z) { var l = await Test(z); listaUtakmica = new List <Utakmica>(l); if (l.Count > 0) { return(await Positive.Evaluate(z)); } else { return(await Negative.Evaluate(z)); } }
public override ParkingRateCode Evaluate(Patron patron) { var result = Test(patron); Console.WriteLine(" - {0}? {1}", Title, result ? "yes" : "no"); if (result == true) { return(Positive.Evaluate(patron)); } else { return(Negative.Evaluate(patron)); } }
public override void Evaluate(Client client) { // Test a client using the primitive operation bool res = Test(client); Console.WriteLine(" - {0}? {1}", Title, res ? "yes" : "no"); // Select a branch to follow if (res) { Positive.Evaluate(client); } else { Negative.Evaluate(client); } }
private void ConvertBurnsElectric(BurnsElectricSaveDataProxy proxy) { if (proxy == null || !proxy.m_Active) { return; } Negative.Add(new BurnsElectric(negative) { AfflictionType = AfflictionType.BurnsElectric, Location = 3, BandageApplied = proxy.m_BandageApplied, DurationHours = proxy.m_DurationHours, ElapsedHours = proxy.m_ElapsedHours, PainKillersTaken = proxy.m_PainKillersTaken, }); }
public static Element Evaluate(string s, ref int i) { int start = i; Stack<Element> element = new Stack<Element>(); Stack<Operator> op = new Stack<Operator>(); op.Push(new OpenBracket()); for (; i < s.Length;) { char c = s[i]; if (c == ' ') { i++; continue; } if (StrNumber.IndexOf(c) != -1) { element.Push(getDouble(s, ref i)); continue; } if (StrOperator.IndexOf(c) != -1) { if(c == '-' && (i == 0 || (StrOperator + '(').IndexOf(s[i-1]) != -1)) { i++; Negative n = new Negative(); n.Inputs.Add(Evaluate(s, ref i)); element.Push(n); continue; } if (c == '+' && (i == 0 || (StrOperator + '(').IndexOf(s[i - 1]) != -1)) { i++; continue; } Operator temp = getOperator(s, ref i); while (temp.Level <= op.Peek().Level && !(temp is OpenBracket)) { Operator o = op.Pop(); o.MakeInput(element); element.Push(o); } op.Push(temp); continue; } if (c == '(') { i++; element.Push(Evaluate(s, ref i)); continue; } if (StrEnd.IndexOf(c) != -1) { while (!(op.Peek() is OpenBracket)) { Operator o = op.Pop(); o.MakeInput(element); element.Push(o); } op.Pop(); break; } element.Push(getSpec(s, ref i)); } if (element.Count != 1) throw new Exception("Error when calculate \"" + s.Substring(start, i - start) + "\""); return element.Pop(); }
public static Int32 Parse(List<Token> src, Int32 begin, out Expr expr) { //expr = null; Int32 current; Int32 saved; if (Parser.IsKeyword(src[begin], KeywordVal.SIZEOF)) { // 1. sizeof current = begin + 1; // 1.1. try to match type_name saved = current; TypeName type_name; current = ParseTypeName(src, current, out type_name); if (current != -1) { // 1.1. -- successful match expr = new SizeofType(type_name); return current; } // 1.2. type_name match failed, try unary_expression current = saved; current = _unary_expression.Parse(src, current, out expr); if (current == -1) { expr = null; return -1; } // 1.2. -- successful match expr = new SizeofExpr(expr); return current; } // sizeof // 2. postfix_expression current = _postfix_expression.Parse(src, begin, out expr); if (current != -1) { // successful match return current; } // now only operators are left if (src[begin].type != TokenType.OPERATOR) { return -1; } current = begin; OperatorVal val = ((TokenOperator)src[begin]).val; switch (val) { case OperatorVal.INC: // '++' current++; current = _unary_expression.Parse(src, current, out expr); if (current == -1) { expr = null; return -1; } expr = new PreIncrement(expr); return current; case OperatorVal.DEC: // '--' current++; current = _unary_expression.Parse(src, current, out expr); if (current == -1) { expr = null; return -1; } expr = new PreDecrement(expr); return current; case OperatorVal.BITAND: // '&' (reference) current++; current = _cast_expression.Parse(src, current, out expr); if (current == -1) { expr = null; return -1; } expr = new Reference(expr); return current; case OperatorVal.MULT: // '*' (dereference) current++; current = _cast_expression.Parse(src, current, out expr); if (current == -1) { expr = null; return -1; } expr = new Dereference(expr); return current; case OperatorVal.ADD: // '+' (positive) current++; current = _cast_expression.Parse(src, current, out expr); if (current == -1) { expr = null; return -1; } expr = new Positive(expr); return current; case OperatorVal.SUB: // '-' (negative) current++; current = _cast_expression.Parse(src, current, out expr); if (current == -1) { expr = null; return -1; } expr = new Negative(expr); return current; case OperatorVal.TILDE: // '~' (bitwise not) current++; current = _cast_expression.Parse(src, current, out expr); if (current == -1) { expr = null; return -1; } expr = new BitwiseNot(expr); return current; case OperatorVal.NOT: // '!' (logical not) current++; current = _cast_expression.Parse(src, current, out expr); if (current == -1) { expr = null; return -1; } expr = new LogicalNot(expr); return current; default: // no match return -1; } // case (val) }