Skip to content

Commit e816228

Browse files
author
jason_yao
committed
update
1 parent 79e971b commit e816228

797 files changed

Lines changed: 38665 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Operation
6+
{
7+
/// <summary>
8+
/// 運算類別
9+
/// </summary>
10+
public class Operation
11+
{
12+
private double _numberA = 0;
13+
private double _numberB = 0;
14+
15+
/// <summary>
16+
/// 數字A
17+
/// </summary>
18+
public double NumberA
19+
{
20+
get
21+
{
22+
return _numberA;
23+
}
24+
set
25+
{
26+
_numberA = value;
27+
}
28+
}
29+
30+
/// <summary>
31+
/// 數字B
32+
/// </summary>
33+
public double NumberB
34+
{
35+
get
36+
{
37+
return _numberB;
38+
}
39+
set
40+
{
41+
_numberB = value;
42+
}
43+
}
44+
45+
/// <summary>
46+
/// 得到運算結果
47+
/// </summary>
48+
/// <returns></returns>
49+
public virtual double getResult()
50+
{
51+
double result = 0;
52+
return result;
53+
}
54+
55+
56+
}
57+
58+
/// <summary>
59+
/// 加法類
60+
/// </summary>
61+
class OperationAdd : Operation
62+
{
63+
public override double getResult()
64+
{
65+
double result = 0;
66+
result = NumberA + NumberB;
67+
return result;
68+
}
69+
}
70+
71+
/// <summary>
72+
/// 減法類別
73+
/// </summary>
74+
class OperationSub : Operation
75+
{
76+
public override double getResult()
77+
{
78+
double result = 0;
79+
result = NumberA - NumberB;
80+
return result;
81+
}
82+
}
83+
84+
/// <summary>
85+
/// 乘法類別
86+
/// </summary>
87+
class OperationMul : Operation
88+
{
89+
public override double getResult()
90+
{
91+
double result = 0;
92+
result = NumberA * NumberB;
93+
return result;
94+
}
95+
}
96+
97+
/// <summary>
98+
/// 除法類別
99+
/// </summary>
100+
class OperationDiv : Operation
101+
{
102+
public override double getResult()
103+
{
104+
double result = 0;
105+
if (NumberB==0)
106+
throw new Exception("除數不能為0。");
107+
result = NumberA / NumberB;
108+
return result;
109+
}
110+
}
111+
112+
/// <summary>
113+
/// 平方類別
114+
/// </summary>
115+
class OperationSqr : Operation
116+
{
117+
public override double getResult()
118+
{
119+
double result = 0;
120+
result = NumberB * NumberB;
121+
return result;
122+
}
123+
}
124+
125+
/// <summary>
126+
/// 平方根類別
127+
/// </summary>
128+
class OperationSqrt : Operation
129+
{
130+
public override double getResult()
131+
{
132+
double result = 0;
133+
if (NumberB < 0)
134+
throw new Exception("負數不能開平方根。");
135+
result = Math.Sqrt(NumberB);
136+
return result;
137+
}
138+
}
139+
140+
/// <summary>
141+
/// 相反數類別
142+
/// </summary>
143+
class OperationReverse : Operation
144+
{
145+
public override double getResult()
146+
{
147+
double result = 0;
148+
result = -NumberB;
149+
return result;
150+
}
151+
}
152+
153+
/// <summary>
154+
/// 運算類別工廠
155+
/// </summary>
156+
class OperationFactory
157+
{
158+
public static Operation createOperate(string operate)
159+
{
160+
Operation oper = null;
161+
switch (operate)
162+
{
163+
case "+":
164+
{
165+
oper = new OperationAdd();
166+
break;
167+
}
168+
case "-":
169+
{
170+
oper = new OperationSub();
171+
break;
172+
}
173+
case "*":
174+
{
175+
oper = new OperationMul();
176+
break;
177+
}
178+
case "/":
179+
{
180+
oper = new OperationDiv();
181+
break;
182+
}
183+
case "sqr":
184+
{
185+
oper = new OperationSqr();
186+
break;
187+
}
188+
case "sqrt":
189+
{
190+
oper = new OperationSqrt();
191+
break;
192+
}
193+
case "+/-":
194+
{
195+
oper = new OperationReverse();
196+
break;
197+
}
198+
}
199+
200+
return oper;
201+
}
202+
}
203+
204+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<PropertyGroup>
3+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5+
<ProductVersion>8.0.50727</ProductVersion>
6+
<SchemaVersion>2.0</SchemaVersion>
7+
<ProjectGuid>{026C6C06-965A-4516-A87F-28A0722DFC9C}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>Operation</RootNamespace>
11+
<AssemblyName>Operation</AssemblyName>
12+
</PropertyGroup>
13+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
14+
<DebugSymbols>true</DebugSymbols>
15+
<DebugType>full</DebugType>
16+
<Optimize>false</Optimize>
17+
<OutputPath>bin\Debug\</OutputPath>
18+
<DefineConstants>DEBUG;TRACE</DefineConstants>
19+
<ErrorReport>prompt</ErrorReport>
20+
<WarningLevel>4</WarningLevel>
21+
</PropertyGroup>
22+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
23+
<DebugType>pdbonly</DebugType>
24+
<Optimize>true</Optimize>
25+
<OutputPath>bin\Release\</OutputPath>
26+
<DefineConstants>TRACE</DefineConstants>
27+
<ErrorReport>prompt</ErrorReport>
28+
<WarningLevel>4</WarningLevel>
29+
</PropertyGroup>
30+
<ItemGroup>
31+
<Reference Include="System" />
32+
<Reference Include="System.Data" />
33+
<Reference Include="System.Xml" />
34+
</ItemGroup>
35+
<ItemGroup>
36+
<Compile Include="Operation.cs" />
37+
<Compile Include="Properties\AssemblyInfo.cs" />
38+
</ItemGroup>
39+
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
40+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
41+
Other similar extension points exist, see Microsoft.Common.targets.
42+
<Target Name="BeforeBuild">
43+
</Target>
44+
<Target Name="AfterBuild">
45+
</Target>
46+
-->
47+
</Project>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// 有關程式集的常規資訊透過下列屬性集
6+
// 控制。更改這些屬性值可修改
7+
// 與程式集關聯的資訊。
8+
[assembly: AssemblyTitle("Operation")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("Mircosoft")]
12+
[assembly: AssemblyProduct("Operation")]
13+
[assembly: AssemblyCopyright("版權所有 (C) Mircosoft 2006")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// 將 ComVisible 設定為 false 使此程式集中的類型
18+
// 對 COM 組件不可見。如果需要從 COM 訪問此程式集中的類型,
19+
// 則將該類型上的 ComVisible 屬性設定為 true。
20+
[assembly: ComVisible(false)]
21+
22+
// 如果此專案向 COM 公開,則下列 GUID 用於類型庫的 ID
23+
[assembly: Guid("211d34e0-b7ea-4e60-96ae-ea982314a0df")]
24+
25+
// 程式集的版本資訊由下面四個值組成:
26+
//
27+
// 主版本
28+
// 次版本
29+
// 內部版本號
30+
// 修訂號
31+
//
32+
// 可以指定所有這些值,也可以使用“修訂號”和“內部版本號”的預設值,
33+
// 方法是按如下所示使用“*”:
34+
[assembly: AssemblyVersion("1.0.0.0")]
35+
[assembly: AssemblyFileVersion("1.0.0.0")]

0 commit comments

Comments
 (0)