Skip to content

Commit 3a9e212

Browse files
committed
Design mode code comments are changed to English
#73
1 parent 8fe5157 commit 3a9e212

21 files changed

+78
-78
lines changed

DesignPattern/AbstractFactoryPattern/Factory.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ Factory* Factory::CreateFactory(FACTORY_TYPE factory)
99
{
1010
Factory *pFactory = nullptr;
1111
switch (factory) {
12-
case FACTORY_TYPE::BENZ_FACTORY: // 奔驰工厂
12+
case FACTORY_TYPE::BENZ_FACTORY: // Benz factory
1313
pFactory = new BenzFactory();
1414
break;
15-
case FACTORY_TYPE::BMW_FACTORY: // 宝马工厂
15+
case FACTORY_TYPE::BMW_FACTORY: // BMW factory
1616
pFactory = new BmwFactory();
1717
break;
18-
case FACTORY_TYPE::AUDI_FACTORY: // 奥迪工厂
18+
case FACTORY_TYPE::AUDI_FACTORY: // Audi factory
1919
pFactory = new AudiFactory();
2020
break;
2121
default:

DesignPattern/AbstractFactoryPattern/Factory.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77

88
#include "product.h"
99

10-
// 抽象工厂模式
10+
// Abstract factory pattern
1111
class Factory {
1212
public:
1313
enum FACTORY_TYPE {
14-
BENZ_FACTORY, // 奔驰工厂
15-
BMW_FACTORY, // 宝马工厂
16-
AUDI_FACTORY // 奥迪工厂
14+
BENZ_FACTORY, // Benz factory
15+
BMW_FACTORY, // BMW factory
16+
AUDI_FACTORY // Audi factory
1717
};
1818

19-
virtual ICar* CreateCar() = 0; // 生产汽车
20-
virtual IBike* CreateBike() = 0; // 生产自行车
21-
static Factory * CreateFactory(FACTORY_TYPE factory); // 创建工厂
19+
virtual ICar* CreateCar() = 0; // Production car
20+
virtual IBike* CreateBike() = 0; // Production bicycle
21+
static Factory * CreateFactory(FACTORY_TYPE factory); // Create factory
2222
};
2323

2424
#endif //DESIGNPATTERN_FACTORY_H

DesignPattern/AbstractFactoryPattern/FactoryMain.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ using namespace std;
1010

1111
void FactoryMain()
1212
{
13-
// ąźłŰ
13+
// Benz
1414
Factory * pFactory = Factory::CreateFactory(Factory::FACTORY_TYPE::BENZ_FACTORY);
1515
ICar * pCar = pFactory->CreateCar();
1616
IBike * pBike = pFactory->CreateBike();
@@ -22,7 +22,7 @@ void FactoryMain()
2222
SAFE_DELETE(pBike);
2323
SAFE_DELETE(pFactory);
2424

25-
// ąŚÂí
25+
// BMW
2626
pFactory = Factory::CreateFactory(Factory::FACTORY_TYPE::BMW_FACTORY);
2727
pCar = pFactory->CreateCar();
2828
pBike = pFactory->CreateBike();
@@ -33,7 +33,7 @@ void FactoryMain()
3333
SAFE_DELETE(pBike);
3434
SAFE_DELETE(pFactory);
3535

36-
// °ÂľĎ
36+
// Audi
3737
pFactory = Factory::CreateFactory(Factory::FACTORY_TYPE::AUDI_FACTORY);
3838
pCar = pFactory->CreateCar();
3939
pBike = pFactory->CreateBike();

DesignPattern/AbstractFactoryPattern/concrete_factory.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "Factory.h"
99
#include "concrete_product.h"
1010

11-
// 奔驰工厂
11+
// Benz factory
1212
class BenzFactory : public Factory
1313
{
1414
public:
@@ -22,7 +22,7 @@ class BenzFactory : public Factory
2222
}
2323
};
2424

25-
// 宝马工厂
25+
// BMW factory
2626
class BmwFactory : public Factory
2727
{
2828
public:
@@ -35,7 +35,7 @@ class BmwFactory : public Factory
3535
}
3636
};
3737

38-
// 奥迪工厂
38+
// Audi factory
3939
class AudiFactory : public Factory
4040
{
4141
public:

DesignPattern/AbstractFactoryPattern/concrete_product.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
#include "product.h"
99

10-
/********** 汽车 **********/
11-
// 奔驰
10+
/********** Car **********/
11+
// Benz
1212
class BenzCar : public ICar
1313
{
1414
public:
@@ -18,7 +18,7 @@ class BenzCar : public ICar
1818
}
1919
};
2020

21-
// 宝马
21+
// BMW
2222
class BmwCar : public ICar
2323
{
2424
public:
@@ -28,7 +28,7 @@ class BmwCar : public ICar
2828
}
2929
};
3030

31-
// 奥迪
31+
// Audi
3232
class AudiCar : public ICar
3333
{
3434
public:
@@ -38,8 +38,8 @@ class AudiCar : public ICar
3838
}
3939
};
4040

41-
/********** 自行车 **********/
42-
// 奔驰
41+
/********** Bicycle **********/
42+
// Benz
4343
class BenzBike : public IBike
4444
{
4545
public:
@@ -49,7 +49,7 @@ class BenzBike : public IBike
4949
}
5050
};
5151

52-
// 宝马
52+
// BMW
5353
class BmwBike : public IBike
5454
{
5555
public:
@@ -59,7 +59,7 @@ class BmwBike : public IBike
5959
}
6060
};
6161

62-
// 奥迪
62+
// Audi
6363
class AudiBike : public IBike
6464
{
6565
public:

DesignPattern/AbstractFactoryPattern/product.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
#include <string>
99
using std::string;
1010

11-
// 汽车接口
11+
// Car Interface
1212
class ICar
1313
{
1414
public:
1515
virtual string Name() = 0;
1616
};
1717

18-
// 自行车接口
18+
// Bike Interface
1919
class IBike
2020
{
2121
public:

DesignPattern/AdapterPattern/AdapterMain.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
void AdapterMain()
1111
{
12-
// ´´½¨ÊÊÅäÆ÷
12+
// Create a power adapter
1313
IRussiaSocket * pAdapter = new PowerAdapter();
1414

15-
// ³äµç
15+
// Recharge
1616
pAdapter->Charge();
1717

1818
SAFE_DELETE(pAdapter);

DesignPattern/AdapterPattern/adaptee.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#include <iostream>
99

10-
// 自带的充电器(两脚扁型)
10+
// Built-in charger (two-leg flat type)
1111
class OwnCharger
1212
{
1313
public:

DesignPattern/AdapterPattern/adapter.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#define SAFE_DELETE(p) { if(p){delete(p); (p)=NULL;} }
1313
#endif
1414

15-
// 电源适配器
15+
// Power Adapter
1616
class PowerAdapter : public IRussiaSocket
1717
{
1818
public:
@@ -23,11 +23,11 @@ class PowerAdapter : public IRussiaSocket
2323
}
2424
void Charge()
2525
{
26-
// 使用自带的充电器(两脚扁形)充电
26+
// Use the built-in charger (two-pin flat) to charge
2727
m_pCharger->ChargeWithFeetFlat();
2828
}
2929
private:
30-
// 持有需要被适配的接口对象(自带的充电器)
30+
// Hold the interface object that needs to be adapted (the built-in charger)
3131
OwnCharger* m_pCharger;
3232
};
3333

DesignPattern/AdapterPattern/target.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
#ifndef DESIGNPATTERN_TARGET_H
66
#define DESIGNPATTERN_TARGET_H
77

8-
// 俄罗斯提供的插座
8+
// Sockets provided by Russia
99
class IRussiaSocket
1010
{
1111
public:
12-
// 使用双脚圆形充电(暂不实现)
12+
// Use both feet to charge in a round shape (not implemented yet)
1313
virtual void Charge() = 0;
1414
};
1515

DesignPattern/BridgePattern/BridgeMain.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@
66

77
void BridgeMain()
88
{
9-
// 创建电器(电灯、电风扇)
9+
// Create electrical appliances (electric lights, electric fans)
1010
IElectricalEquipment * light = new Light();
1111
IElectricalEquipment * fan = new Fan();
1212

13-
// 创建开关(拉链式开关、两位开关)
14-
// 将拉链式开关和电灯关联起来,两位开关和风扇关联起来
13+
// Create switch (pull chain switch, two-position switch)
14+
// Associating a pull chain switch with a light and a two-position switch with a fan
1515
ISwitch * pullChain = new PullChainSwitch(light);
1616
ISwitch * twoPosition = new TwoPositionSwitch(fan);
1717

18-
// 开灯、关灯
18+
// Lights on, lights off
1919
pullChain->On();
2020
pullChain->Off();
2121

22-
// 打开风扇、关闭风扇
22+
// Turn on the fan, turn off the fan
2323
twoPosition->On();
2424
twoPosition->Off();
2525

DesignPattern/BridgePattern/abstraction.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77

88
#include "implementor.h"
99

10-
// 开关
10+
// Switch
1111
class ISwitch
1212
{
1313
public:
1414
ISwitch(IElectricalEquipment *ee){ m_pEe = ee; }
1515
virtual ~ISwitch(){}
16-
virtual void On() = 0; // 打开电器
17-
virtual void Off() = 0; // 关闭电器
16+
virtual void On() = 0; // Turn on the appliance
17+
virtual void Off() = 0; // Turn off the appliance
1818

1919
protected:
2020
IElectricalEquipment * m_pEe;

DesignPattern/BridgePattern/concrete_implementor.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,32 @@
88
#include "implementor.h"
99
#include <iostream>
1010

11-
// 电灯
11+
// Electric lights
1212
class Light : public IElectricalEquipment
1313
{
1414
public:
15-
// 开灯
15+
// Turn on the lights
1616
virtual void PowerOn() override
1717
{
1818
std::cout << "Light is on." << std::endl;
1919
}
20-
// 关灯
20+
// Turn off the lights
2121
virtual void PowerOff() override
2222
{
2323
std::cout << "Light is off." << std::endl;
2424
}
2525
};
2626

27-
// 风扇
27+
// Electric Fan
2828
class Fan : public IElectricalEquipment
2929
{
3030
public:
31-
// 打开风扇
31+
// Turn on the fan
3232
virtual void PowerOn() override
3333
{
3434
std::cout << "Fan is on." << std::endl;
3535
}
36-
//关闭风扇
36+
// Turn off the fan
3737
virtual void PowerOff() override
3838
{
3939
std::cout << "Fan is off." << std::endl;

DesignPattern/BridgePattern/implementor.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
#ifndef DESIGNPATTERN_IMPLEMENTOR_H
66
#define DESIGNPATTERN_IMPLEMENTOR_H
77

8-
// 电器
8+
// Electric equipment
99
class IElectricalEquipment
1010
{
1111
public:
1212
virtual ~IElectricalEquipment(){}
13-
virtual void PowerOn() = 0; // 打开
14-
virtual void PowerOff() = 0; // 关闭
13+
virtual void PowerOn() = 0;
14+
virtual void PowerOff() = 0;
1515
};
1616

1717
#endif //DESIGNPATTERN_IMPLEMENTOR_H

DesignPattern/BridgePattern/refined_abstraction.h

+10-10
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,43 @@
88
#include "abstraction.h"
99
#include <iostream>
1010

11-
// 拉链式开关
11+
// Zipper switch
1212
class PullChainSwitch : public ISwitch
1313
{
1414
public:
1515
PullChainSwitch(IElectricalEquipment *ee) : ISwitch(ee) {}
1616

17-
// 用拉链式开关打开电器
17+
// Turn on the equipment with a zipper switch
1818
virtual void On() override
1919
{
20-
std::cout << "Switch on the equipment with a pull chain switch." << std::endl;
20+
std::cout << "Turn on the equipment with a zipper switch." << std::endl;
2121
m_pEe->PowerOn();
2222
}
2323

24-
// 用拉链式开关关闭电器
24+
// Turn off the equipment with a zipper switch
2525
virtual void Off() override
2626
{
27-
std::cout << "Switch off the equipment with a pull chain switch." << std::endl;
27+
std::cout << "Turn off the equipment with a zipper switch." << std::endl;
2828
m_pEe->PowerOff();
2929
}
3030
};
3131

32-
// 两位开关
32+
// Two-position switch
3333
class TwoPositionSwitch : public ISwitch
3434
{
3535
public:
3636
TwoPositionSwitch(IElectricalEquipment *ee) : ISwitch(ee) {}
3737

38-
// 用两位开关打开电器
38+
// Turn on the equipment with a two-position switch
3939
virtual void On() override
4040
{
41-
std::cout << "Switch on the equipment with a two-position switch." << std::endl;
41+
std::cout << "Turn on the equipment with a two-position switch." << std::endl;
4242
m_pEe->PowerOn();
4343
}
4444

45-
// 用两位开关关闭电器
45+
// Turn off the equipment with a two-position switch
4646
virtual void Off() override {
47-
std::cout << "Switch off the equipment with a two-position switch." << std::endl;
47+
std::cout << "Turn off the equipment with a two-position switch." << std::endl;
4848
m_pEe->PowerOff();
4949
}
5050
};

0 commit comments

Comments
 (0)