本文整理匯總了C#中SimpleCalculator.Parse.getNumberOne方法的典型用法代碼示例。如果您正苦於以下問題:C# Parse.getNumberOne方法的具體用法?C# Parse.getNumberOne怎麽用?C# Parse.getNumberOne使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SimpleCalculator.Parse
的用法示例。
在下文中一共展示了Parse.getNumberOne方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: ParseEnsureICanGetFirstNumber
public void ParseEnsureICanGetFirstNumber()
{
Parse p = new Parse();
string input = "4 + 7";
Assert.AreEqual(4, p.getNumberOne(input));
}