本文整理汇总了C#中Calculator类的典型用法代码示例。如果您正苦于以下问题:C# Calculator类的具体用法?C# Calculator怎么用?C# Calculator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Calculator类属于命名空间,在下文中一共展示了Calculator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Add_NumbersAndHandleValidNewLine_ReturnSum
public void Add_NumbersAndHandleValidNewLine_ReturnSum()
{
var numberString = "1\n2";
var calculator = new Calculator();
int result = calculator.Add(numberString);
Assert.AreEqual(3, result);
}
开发者ID:johnnonolan,项目名称:StringCalculatorTDDKata,代码行数:7,代码来源:CalculatorTests.cs
示例2: AddNegative4andnegative10
public void AddNegative4andnegative10()
{
Calculator calc = new Calculator(); //ARRANGE
int result = calc.Add(-4, -10); //ACT
Assert.AreEqual(-14, result); //assert
}
开发者ID:TIY-LR-NET-2015-Fall,项目名称:Week-2-Day-3,代码行数:7,代码来源:calculatortests.cs
示例3: Calculator_Should_Calculate_Test2
public void Calculator_Should_Calculate_Test2()
{
var calculator = new Calculator();
var result = calculator.Calculate("(5+3)*(4-1)");
result.Should().Be(24);
}
开发者ID:gaiazov,项目名称:Calculator,代码行数:7,代码来源:CalculatorTests.cs
示例4: Calculator_GetNumber
public int Calculator_GetNumber(string roman)
{
int number = 0;
var calculator = new Calculator();
calculator.GetNumber(roman, ref number);
return number;
}
开发者ID:jesuswasrasta,项目名称:CSharpDojo,代码行数:7,代码来源:CalculatorTests.cs
示例5: Add5and8
public void Add5and8()
{
Calculator calc = new Calculator();
int result = calc.Add(5, 3);
Assert.AreEqual(8, result);
}
开发者ID:TIY-LR-NET-2015-Fall,项目名称:Week-2-Day-3,代码行数:7,代码来源:calculatortests.cs
示例6: TenMinusFiveIsFive
public void TenMinusFiveIsFive()
{
var calc = new Calculator();
var five = calc.Subtract(10, 5);
Assert.AreEqual(5, five);
}
开发者ID:JimmyJune,项目名称:blade,代码行数:7,代码来源:TestCalculator.cs
示例7: Division_by_zero_does_not_affect_calculator_state
public void Division_by_zero_does_not_affect_calculator_state()
{
var sut = new Calculator();
sut.Calculate(8, "/");
Assert.Throws<DivideByZeroException>(() => sut.Calculate(0, "="));
Assert.AreEqual(4, sut.Calculate(2, "="));
}
开发者ID:ralfw,项目名称:TDDaiymiByExample,代码行数:7,代码来源:test_Calculator.cs
示例8: PressBackspace_Should_Set_DisplayValue_To_0_If_DisplayValue_Less_Then_10
public void PressBackspace_Should_Set_DisplayValue_To_0_If_DisplayValue_Less_Then_10()
{
var calc = new Calculator();
calc.Press1();
calc.PressBackspace();
Assert.AreEqual(0, calc.DisplayValue);
}
开发者ID:silvfoxy,项目名称:teach-ann,代码行数:7,代码来源:TestCalculator.cs
示例9: Calculate
private static void Calculate(string s)
{
var calculator = new Calculator(UI);
calculator.Add(s);
CalculateNextValue(calculator);
}
开发者ID:rhanekom,项目名称:katas,代码行数:7,代码来源:Program.cs
示例10: Press1_Should_Set_Display_Value_To_DisplayValue_Multiply_10_Plus_1
public void Press1_Should_Set_Display_Value_To_DisplayValue_Multiply_10_Plus_1()
{
var calc = new Calculator();
calc.Press9();
calc.Press1();
Assert.AreEqual(91, calc.DisplayValue);
}
开发者ID:silvfoxy,项目名称:teach-ann,代码行数:7,代码来源:TestCalculator.cs
示例11: Press1_Then_PressPlus_Should_Set_PreviousValue_To_1
public void Press1_Then_PressPlus_Should_Set_PreviousValue_To_1()
{
var calc = new Calculator();
calc.Press1();
calc.PressPlus();
Assert.AreEqual(1, calc.PreviousValue);
}
开发者ID:silvfoxy,项目名称:teach-ann,代码行数:7,代码来源:TestCalculator.cs
示例12: Calculate
public string Calculate(double number, char operator)
{
Calculator calculator = new Calculator();
if(!storedNum)
{
storedNum = number;
}
if(storedOperator!='')
{
switch(storedOperator)
{
case '+':
storedNum = calculator.Add(storedNum, number);
break;
default:
//Suitable error for case not found
break;
}
storedOperator
}
else
{
storedOperator = operator;
}
}
开发者ID:George-Lee,项目名称:uniwork,代码行数:27,代码来源:Calculator.cs
示例13: Add_TwoNumbers_ReturnSum
public void Add_TwoNumbers_ReturnSum()
{
var numberString = "1,2";
var calculator = new Calculator();
int result = calculator.Add(numberString);
Assert.AreEqual(3, result);
}
开发者ID:johnnonolan,项目名称:StringCalculatorTDDKata,代码行数:7,代码来源:CalculatorTests.cs
示例14: Add_OneNumber_ReturnNumber
public void Add_OneNumber_ReturnNumber()
{
var numberString = "1";
var calculator = new Calculator();
int result = calculator.Add(numberString);
Assert.AreEqual(1, result);
}
开发者ID:johnnonolan,项目名称:StringCalculatorTDDKata,代码行数:7,代码来源:CalculatorTests.cs
示例15: ShouldAdd
public void ShouldAdd()
{
var sut = new Calculator();
var result = sut.Add(1, 2);
Assert.Equal(3, result);
}
开发者ID:usatank,项目名称:xUnitTests,代码行数:7,代码来源:CalculatorTests.cs
示例16: Start
public void Start()
{
plsh = GetComponent<playerShooting>();
rb = GetComponent<Rigidbody>();
col = GetComponent<SphereCollider>();
calculator = GameObject.FindGameObjectWithTag("scripts").GetComponent<Calculator>();
sightConstant = calculator.getSightConstant();
fieldofViewAngle = calculator.getFieldOfView();
sensitivity = calculator.getSensitivity();
rotateToTargetSpeed = calculator.getRotateSpeed();
index = calculator.addBot(this);
targets = calculator.getTargets(index);
col.radius= (float)sightConstant;
shootFlag = false;
playerInSight = false;
moveBool = new bool[calculator.getMasterBoolLength()];
bestPoint = transform.position;
bestPoints = new Vector3[moveBool.Length];
bestPointsSV = new float[moveBool.Length];
team = GetComponent<TeamMember>().teamID;
teamFinder();
if (team == 1)
{
goal = new Vector3(-37f, -30f, 28f);
}
else if(team == 2)
{
goal = new Vector3(64f, -30f, -43f);
}
}
开发者ID:matsmulder,项目名称:MinorProject,代码行数:30,代码来源:Bot.cs
示例17: OnePlusOneIsTwo
public void OnePlusOneIsTwo()
{
var calc = new Calculator();
var two = calc.Add(1, 1);
Assert.AreEqual(2, two);
}
开发者ID:JimmyJune,项目名称:blade,代码行数:7,代码来源:TestCalculator.cs
示例18: CalculatorReplLoop
public CalculatorReplLoop()
{
Calculator = new Calculator();
InputService = new ConsoleInputService();
OutputService = new ConsoleOutputService();
ParsingService = new InputParserService();
}
开发者ID:PaulWillis,项目名称:PrismExample,代码行数:7,代码来源:CalculatorReplLoop.cs
示例19: CalculateButton_Click
protected void CalculateButton_Click(object sender, EventArgs e)
{
if (ValueBox1.Text.Length > 0 && ValueBox2.Text.Length > 0)
{
double result = 0;
double value1 = Convert.ToDouble(ValueBox1.Text);
double value2 = Convert.ToDouble(ValueBox2.Text);
Calculator myCalculator = new Calculator();
switch (OperatorList.SelectedValue)
{
case "+":
result = myCalculator.Add(value1, value2);
break;
case "-":
result = myCalculator.Subtract(value1, value2);
break;
case "*":
result = myCalculator.Multiply(value1, value2);
break;
case "/":
result = myCalculator.Divide(value1, value2);
break;
}
ResultLabel.Text = result.ToString();
}
else
{
ResultLabel.Text = string.Empty;
}
}
开发者ID:kathytrinh81,项目名称:assignment10,代码行数:30,代码来源:CalculatorDemo.aspx.cs
示例20: CalculateButton_Click
protected void CalculateButton_Click(object sender, EventArgs e)
{
if (ValueBox1.Text.Length > 0 && ValueBox2.Text.Length > 0)
{
double result = 0;
double value1 = Convert.ToDouble(ValueBox1.Text);
double value2 = Convert.ToDouble(ValueBox2.Text);
Calculator myCalculator = new Calculator();
Trace.Write(string.Format("Performing the calculation with the {0} operator", OperatorList.SelectedValue));
switch (OperatorList.SelectedValue)
{
case "+":
result = myCalculator.Add(value1, value2);
break;
case "-":
result = myCalculator.Subtract(value1, value2);
break;
case "*":
result = myCalculator.Multiply(value1, value2);
break;
case "/":
result = myCalculator.Divide(value1, value2);
break;
}
ResultLabel.Text = result.ToString();
}
else
{
ResultLabel.Text = string.Empty;
Trace.Warn("Custom Category", "TextBox controls are empty; time to add Validation controls?");
}
}
开发者ID:evilempire22,项目名称:BegASPNET,代码行数:33,代码来源:CalculatorDemo.aspx.cs
注:本文中的Calculator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论