-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathProgram.cs
More file actions
37 lines (34 loc) · 1.14 KB
/
Program.cs
File metadata and controls
37 lines (34 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using SimpleFactory.Operations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SimpleFactory
{
public static class Program
{
public static void Main(string[] args)
{
try
{
Console.WriteLine("請輸入數字A");
string numberA = Console.ReadLine();
Console.WriteLine("請輸入運算符號(+ - * /)");
string operate = Console.ReadLine();
Console.WriteLine("請輸入數字B");
string numberB = Console.ReadLine();
var operation = OperationSimpleFactory.CreateOperate(operate);
operation.NumberA = Convert.ToDouble(numberA);
operation.NumberB = Convert.ToDouble(numberB);
string result = operation.GetResult().ToString();
Console.WriteLine("結果是:{0}", result);
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine("錯誤:{0}", ex.Message);
}
}
}
}