本文整理汇总了C#中SimpleCalculator.Parse.getOperator方法的典型用法代码示例。如果您正苦于以下问题:C# Parse.getOperator方法的具体用法?C# Parse.getOperator怎么用?C# Parse.getOperator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleCalculator.Parse
的用法示例。
在下文中一共展示了Parse.getOperator方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
Console.WriteLine("What is your name?");
string userName = Console.ReadLine();
Parse p = new Parse();
Evaluate e = new Evaluate();
bool run = true;
while (run)
{
Console.WriteLine(userName + " Define your mathematical operation");
string input = Console.ReadLine();
if (input.ToUpper() == "LASTQ")
{
Console.WriteLine(e.lastExpression());
run = false;
break;
}
string oper = p.getOperator(input);
int num1 = p.getNumberOne(input);
int num2 = p.getNumberTwo(input);
int answer = e.ExecuteMethod(num1, num2, oper);
Console.WriteLine("The answer to your operation is: " + answer);
}
Console.WriteLine("Press any key to exit");
Console.ReadLine();
}
示例2: EvaluateTestEnsureICanSubtract
public void EvaluateTestEnsureICanSubtract()
{
Evaluate e = new Evaluate();
Parse p = new Parse();
string input = "2 - 2";
int num1 = p.getNumberOne(input);
int num2 = p.getNumberTwo(input);
string oper = p.getOperator(input);
int expected = 0;
Assert.AreEqual(expected, e.ExecuteMethod(num1, num2, oper));
}
示例3: CommandEnsureICanGetReturnFromLastQCommand
public void CommandEnsureICanGetReturnFromLastQCommand()
{
Parse p = new Parse();
Evaluate e = new Evaluate();
string input = "2 + 2";
int num1 = p.getNumberOne(input);
int num2 = p.getNumberTwo(input);
string oper = p.getOperator(input);
int answer = e.ExecuteMethod(num1, num2, oper);
string expected = "2 + 2";
string actual = e.lastExpression();
Assert.AreEqual(expected, actual);
}
示例4: ParseEnsureICanGetAdditionOperator
public void ParseEnsureICanGetAdditionOperator()
{
Parse p = new Parse();
string input = "2 + 2";
Assert.AreEqual("+", p.getOperator(input));
}
示例5: ParseEnsureICanCaptureBadInputNegativeSpaceNumber
public void ParseEnsureICanCaptureBadInputNegativeSpaceNumber()
{
Parse p = new Parse();
string input = "2+- 3";
p.getOperator(input);
}
示例6: ParseEnsureICanCaptureBadInputDoubleOperator
public void ParseEnsureICanCaptureBadInputDoubleOperator()
{
Parse p = new Parse();
string input = "2 ++ 2";
p.getOperator(input);
}