forked from XINCGer/Unity3DTraining
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPowerPortAdaptercs.cs
More file actions
43 lines (38 loc) · 993 Bytes
/
Copy pathPowerPortAdaptercs.cs
File metadata and controls
43 lines (38 loc) · 993 Bytes
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
38
39
40
41
42
43
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AdapterPattern
{
/// <summary>
/// 适配器接口
/// </summary>
public interface PowerPortAdapter
{
void PowerSupply();
}
/// <summary>
/// 110V电源适配器类
/// </summary>
class Adapter110V : PowerPort110V, PowerPortAdapter
{
NoteBook noteBook = new NoteBook();
public void PowerSupply()
{
base.PowerSupply();
Console.WriteLine("适配器将电源转换成了笔记本需要的!");
noteBook.Work();
}
}
class Adapter220V: PowerPort220V, PowerPortAdapter
{
NoteBook noteBook = new NoteBook();
public void PowerSupply()
{
base.PowerSupply();
Console.WriteLine("适配器将电源转换成了笔记本需要的!");
noteBook.Work();
}
}
}