Skip to content

Commit 9132682

Browse files
committed
修改编码格式不正确问题。
1 parent 0e3ee75 commit 9132682

23 files changed

+97
-97
lines changed

DS01_SimpleFactory.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
//녜蹶끓틔
1+
//抽象产品
22
interface Car
33
{
44
public void drive();
55
}
66

7-
//야竟끓틔잚
7+
//具体产品类
88
class Benz implements Car{
99
public void drive() {
1010
System.out.println("Driving Benz ");
@@ -17,7 +17,7 @@ public void drive() {
1717
}
1818
}
1919

20-
//묏낍잚실
20+
//工厂类角色
2121
class Driver{
2222
public static Car driverCar(String s)throws Exception {
2323
if(s.equalsIgnoreCase("Benz"))

DS02_FactoryMethod.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
//녜蹶묏낍
1+
//抽象工厂
22
interface Driver{
33
public Car driverCar();
44
}
55

6-
//야竟묏낍잚
6+
//具体工厂类
77
class BenzDriver implements Driver{
88
public Car driverCar(){
99
return new Benz();
@@ -16,13 +16,13 @@ public Car driverCar(){
1616
}
1717
}
1818

19-
//녜蹶끓틔
19+
//抽象产品
2020
interface Car
2121
{
2222
public void drive();
2323
}
2424

25-
//야竟끓틔잚
25+
//具体产品类
2626
class Benz implements Car{
2727
public void drive() {
2828
System.out.println("Driving Benz ");

DS03_AbstractFactory.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
//녜蹶끓틔
2+
//抽象产品
33
interface ICat {
44

55
void eat();
@@ -10,7 +10,7 @@ interface IDog {
1010
void eat();
1111
}
1212

13-
//야竟끓틔
13+
//具体产品
1414
class BlackCat implements ICat {
1515

1616
public void eat() {
@@ -40,15 +40,15 @@ public void eat() {
4040
}
4141

4242

43-
// 녜蹶묏낍
43+
// 抽象工厂
4444
interface IAnimalFactory{
4545

4646
ICat createCat();
4747

4848
IDog createDog();
4949
}
5050

51-
//야竟묏낍
51+
//具体工厂
5252
class BlackAnimalFactory implements IAnimalFactory {
5353

5454
public ICat createCat() {

DS04_Builder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ public ManBuilder() {
2020
}
2121

2222
public void buildBody() {
23-
person.setBody("建造男人的身体");
23+
person.setBody("建造男人的身体");
2424
}
2525

2626
public void buildFoot() {
27-
person.setFoot("建造男人的脚");
27+
person.setFoot("建造男人的脚");
2828
}
2929

3030
public void buildHead() {
31-
person.setHead("建造*人的头");
31+
person.setHead("建造*人的头");
3232
}
3333

3434
public Person buildPerson() {

DS04_Singleton.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import java.util.HashMap;
22
class Singleton
33
{
4-
//用来存放对应关系
4+
//用来存放对应关系
55
private static HashMap sinRegistry = new HashMap();
66
static private Singleton s = new Singleton();
7-
//受保护的构造函数
7+
//受保护的构造函数
88
protected Singleton()
99
{}
1010
public static Singleton getInstance(String name)

DS07_Bright.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public String getType() {
2626
class Man extends Person {
2727

2828
public Man() {
29-
setType("ÄÐÈË");
29+
setType("男人");
3030
}
3131

3232
public void dress() {
@@ -38,7 +38,7 @@ public void dress() {
3838
class Lady extends Person {
3939

4040
public Lady() {
41-
setType("Å®ÈË");
41+
setType("女人");
4242
}
4343

4444
public void dress() {
@@ -55,14 +55,14 @@ abstract class Clothing {
5555
class Jacket extends Clothing {
5656

5757
public void personDressCloth(Person person) {
58-
System.out.println(person.getType() + "´©Âí¼×");
58+
System.out.println(person.getType() + "穿马甲");
5959
}
6060
}
6161

6262
class Trouser extends Clothing {
6363

6464
public void personDressCloth(Person person) {
65-
System.out.println(person.getType() + "´©¿ã×Ó");
65+
System.out.println(person.getType() + "穿裤子");
6666
}
6767
}
6868

DS08_Composite.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Programmer extends Employer {
3434

3535
public Programmer(String name) {
3636
setName(name);
37-
employers = null;//程序员, 表示没有下属了
37+
employers = null;//程序员, 表示没有下属了
3838
}
3939

4040
public void add(Employer employer) {
@@ -50,7 +50,7 @@ class ProcectAssistant extends Employer {
5050

5151
public ProcectAssistant(String name) {
5252
setName(name);
53-
employers = null;//项目助理, 表示没有下属了
53+
employers = null;//项目助理, 表示没有下属了
5454
}
5555

5656
public void add(Employer employer) {
@@ -85,15 +85,15 @@ public void delete(Employer employer) {
8585
public class DS08_Composite {
8686

8787
public static void main(String[] args) {
88-
Employer pm = new ProjectManager("项目经理");
89-
Employer pa = new ProcectAssistant("项目助理");
90-
Employer programmer1 = new Programmer("程序员一");
91-
Employer programmer2 = new Programmer("程序员二");
88+
Employer pm = new ProjectManager("项目经理");
89+
Employer pa = new ProcectAssistant("项目助理");
90+
Employer programmer1 = new Programmer("程序员一");
91+
Employer programmer2 = new Programmer("程序员二");
9292

93-
pm.add(pa);//为项目经理添加项目助理
94-
pm.add(programmer2);//为项目经理添加程序员
93+
pm.add(pa);//为项目经理添加项目助理
94+
pm.add(programmer2);//为项目经理添加程序员
9595

96-
//注意,这里如果不加<>里面的东西,竟然不能编译通过,这个是因为泛型编程
96+
//注意,这里如果不加<>里面的东西,竟然不能编译通过,这个是因为泛型编程
9797
List<Employer> ems = pm.getEmployers();
9898
int emsCount = ems.size();
9999
for(int i = 0; i <emsCount;++i)

DS09_Decorator.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
//Component定义一个对象接口,可以给这些对象动态地添加职责。
1+
//Component定义一个对象接口,可以给这些对象动态地添加职责。
22
interface Person {
33

44
void eat();
55
}
66

7-
//ConcreteComponent 定义一个对象,可以给这个对象添加一些职责。
7+
//ConcreteComponent 定义一个对象,可以给这个对象添加一些职责。
88
class Man implements Person {
99

1010
public void eat() {
11-
System.out.println("男人在吃");
11+
System.out.println("男人在吃");
1212
}
1313
}
1414

15-
//Decorator 维持一个执行Component对象的指针,并定义一个与Componect 接口一致的接口。
15+
//Decorator 维持一个执行Component对象的指针,并定义一个与Componect 接口一致的接口。
1616
abstract class Decorator implements Person {
1717

1818
protected Person person;
@@ -26,17 +26,17 @@ public void eat() {
2626
}
2727
}
2828

29-
//ConcreteDectrator 想组建添加职责
29+
//ConcreteDectrator 想组建添加职责
3030
class ManDecoratorA extends Decorator {
3131

3232
public void eat() {
3333
super.eat();
3434
reEat();
35-
System.out.println("ManDecoratorA类");
35+
System.out.println("ManDecoratorA类");
3636
}
3737

3838
public void reEat() {
39-
System.out.println("再吃一顿饭");
39+
System.out.println("再吃一顿饭");
4040
}
4141
}
4242

@@ -45,7 +45,7 @@ class ManDecoratorB extends Decorator {
4545
public void eat() {
4646
super.eat();
4747
System.out.println("===============");
48-
System.out.println("ManDecoratorB类");
48+
System.out.println("ManDecoratorB类");
4949
}
5050
}
5151

DS10_Facade.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@ interface ServiceC{
1515
class ServiceAImpl implements ServiceA {
1616

1717
public void methodA() {
18-
System.out.println("这是服务A");
18+
System.out.println("这是服务A");
1919
}
2020
}
2121

2222
class ServiceBImpl implements ServiceB {
2323

2424
public void methodB() {
25-
System.out.println("这是服务B");
25+
System.out.println("这是服务B");
2626
}
2727
}
2828

2929
class ServiceCImpl implements ServiceC {
3030

3131
public void methodC() {
32-
System.out.println("这是服务C");
32+
System.out.println("这是服务C");
3333
}
3434
}
3535

DS11_Flyweight.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import java.util.*;
22

3-
//Õâ¸öÀý×Ó²»Ì«ºÃ
3+
//这个例子不太好
44

55
//Flyweight
66
interface Flyweight {
@@ -13,7 +13,7 @@ class FlyweightImpl implements Flyweight {
1313

1414
public void action(int arg) {
1515
// TODO Auto-generated method stub
16-
System.out.println("²ÎÊýÖµ:" + arg);
16+
System.out.println("参数值:" + arg);
1717
}
1818
}
1919

DS12_Proxy.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ class ProxyObject implements Object {
44
Object obj;
55

66
public ProxyObject() {
7-
System.out.println("这是代理类");
7+
System.out.println("这是代理类");
88
obj = new ObjectImpl();
99
}
1010

1111
public void action() {
12-
System.out.println("代理开始");
12+
System.out.println("代理开始");
1313
obj.action();
14-
System.out.println("代理结束");
14+
System.out.println("代理结束");
1515
}
1616
}
1717

@@ -27,7 +27,7 @@ class ObjectImpl implements Object {
2727
public void action() {
2828
System.out.println("========");
2929
System.out.println("========");
30-
System.out.println("这是被代理的类");
30+
System.out.println("这是被代理的类");
3131
System.out.println("========");
3232
System.out.println("========");
3333
}

DS13_CHAIN.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//这个例子不是很好。
1+
//这个例子不是很好。
22
//Hand*er
33

44
interface RequestHandle {
@@ -12,10 +12,10 @@ class HRRequestHandle implements RequestHandle {
1212

1313
public void handleRequest(Request request) {
1414
if (request instanceof DimissionRequest) {
15-
System.out.println("要离职, 人事审批!");
15+
System.out.println("要离职, 人事审批!");
1616
}
1717

18-
System.out.println("请求完成");
18+
System.out.println("请求完成");
1919
}
2020
}
2121

@@ -30,7 +30,7 @@ public PMRequestHandle(RequestHandle rh) {
3030

3131
public void handleRequest(Request request) {
3232
if (request instanceof AddMoneyRequest) {
33-
System.out.println("要加薪, 项目经理审批!");
33+
System.out.println("要加薪, 项目经理审批!");
3434
} else {
3535
rh.handleRequest(request);
3636
}
@@ -47,7 +47,7 @@ public TLRequestHandle(RequestHandle rh) {
4747

4848
public void handleRequest(Request request) {
4949
if (request instanceof LeaveRequest) {
50-
System.out.println("要请假, 项目组长审批!");
50+
System.out.println("要请假, 项目组长审批!");
5151
} else {
5252
rh.handleRequest(request);
5353
}
@@ -61,17 +61,17 @@ public static void main(String[] args) {
6161
RequestHandle pm = new PMRequestHandle(hr);
6262
RequestHandle tl = new TLRequestHandle(pm);
6363

64-
//team leader处理离职请求
64+
//team leader处理离职请求
6565
Request request = new DimissionRequest();
6666
tl.handleRequest(request);
6767

6868
System.out.println("===========");
69-
//team leader处理加薪请求
69+
//team leader处理加薪请求
7070
request = new AddMoneyRequest();
7171
tl.handleRequest(request);
7272

7373
System.out.println("========");
74-
//项目经理上理辞职请求
74+
//项目经理上理辞职请求
7575
request = new DimissionRequest();
7676
pm.handleRequest(request);
7777
}

0 commit comments

Comments
 (0)