bugfix: change character code : utf-8

master
FengJungle 2021-10-28 21:58:09 +08:00
parent 49bc9c8130
commit 4d8d1ca606
4 changed files with 34 additions and 34 deletions

View File

@ -6,7 +6,7 @@
#include <mutex> #include <mutex>
using namespace std; using namespace std;
//实现类接口 // 实现类接口Implementor
class Game class Game
{ {
public: public:
@ -16,47 +16,47 @@ public:
private: private:
}; };
//具体实现类GameA // 具体实现类GameA
class GameA:public Game class GameA:public Game
{ {
public: public:
GameA(){} GameA(){}
void play(){ void play(){
printf("Jungle玩游戏A\n"); printf("Jungle<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϷA\n");
} }
}; };
//具体实现类GameB // 具体实现类GameB
class GameB :public Game class GameB :public Game
{ {
public: public:
GameB(){} GameB(){}
void play(){ void play(){
printf("Jungle玩游戏B\n"); printf("Jungle<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϷB\n");
} }
}; };
//抽象类Phone //抽象类Phone
class Phone class Phone
{ {
public: public:
Phone(){ Phone(){
} }
virtual ~Phone(){} virtual ~Phone(){}
//安装游戏 // Setup game
virtual void setupGame(Game *igame) = 0; virtual void setupGame(Game *igame) = 0;
virtual void play() = 0; virtual void play() = 0;
private: private:
Game *game; Game *game;
}; };
//扩充抽象类PhoneA // 扩充抽象类PhoneA
class PhoneA:public Phone class PhoneA:public Phone
{ {
public: public:
PhoneA(){ PhoneA(){
} }
//安装游戏 // Setup game
void setupGame(Game *igame){ void setupGame(Game *igame){
this->game = igame; this->game = igame;
} }
@ -67,13 +67,13 @@ private:
Game *game; Game *game;
}; };
//扩充抽象类PhoneB // 扩充抽象类PhoneB
class PhoneB :public Phone class PhoneB :public Phone
{ {
public: public:
PhoneB(){ PhoneB(){
} }
//安装游戏 // Setup game
void setupGame(Game *igame){ void setupGame(Game *igame){
this->game = igame; this->game = igame;
} }

View File

@ -6,14 +6,14 @@ int main()
Game *game; Game *game;
Phone *phone; Phone *phone;
//Jungle买了PhoneA品牌的手机想玩游戏A // Jungle买了PhoneA品牌的手机想玩游戏A
phone = new PhoneA(); phone = new PhoneA();
game = new GameA(); game = new GameA();
phone->setupGame(game); phone->setupGame(game);
phone->play(); phone->play();
printf("++++++++++++++++++++++++++++++++++\n"); printf("++++++++++++++++++++++++++++++++++\n");
//Jungle想在这个手机上玩游戏B // Jungle想在这个手机上玩游戏B
delete game; delete game;
game = new GameB(); game = new GameB();
phone->setupGame(game); phone->setupGame(game);

View File

@ -6,7 +6,7 @@
#include <vector> #include <vector>
using namespace std; using namespace std;
//抽象构件 // 抽象构件
class Component class Component
{ {
public: public:
@ -15,13 +15,13 @@ public:
this->name = iName; this->name = iName;
} }
virtual ~Component(){} virtual ~Component(){}
//增加一个部门或办公室 // 增加一个部门或办公室
virtual void add(Component*) = 0; virtual void add(Component*) = 0;
//撤销一个部门或办公室 // 撤销一个部门或办公室
virtual void remove(Component*) = 0; virtual void remove(Component*) = 0;
// //
virtual Component* getChild(int) = 0; virtual Component* getChild(int) = 0;
//各部门操作 // 各部门操作
virtual void operation() = 0; virtual void operation() = 0;
string getName(){ string getName(){
return name; return name;
@ -30,7 +30,7 @@ private:
string name; string name;
}; };
//叶子构件:办公室 // 叶子构件:办公室
class Office :public Component class Office :public Component
{ {
public: public:
@ -52,7 +52,7 @@ private:
string name; string name;
}; };
//叶子构件:行政办公室 // 叶子构件:行政办公室
class AdminOffice :public Office class AdminOffice :public Office
{ {
public: public:
@ -66,7 +66,7 @@ private:
string name; string name;
}; };
//叶子构件:教务办公室 // 叶子构件:教务办公室
class DeanOffice :public Office class DeanOffice :public Office
{ {
public: public:
@ -80,7 +80,7 @@ private:
string name; string name;
}; };
//容器构件SubComponent // 容器构件SubComponent
class SubComponent :public Component class SubComponent :public Component
{ {
public: public:
@ -110,7 +110,7 @@ public:
private: private:
string name; string name;
//构件列表 // 构件列表
vector<Component*>componentList; vector<Component*>componentList;
}; };

View File

@ -6,23 +6,23 @@ int main()
Component *head, *sichuanBranch, *cdBranch, *myBranch, *office1, *office2, *office3, Component *head, *sichuanBranch, *cdBranch, *myBranch, *office1, *office2, *office3,
*office4, *office5, *office6, *office7, *office8; *office4, *office5, *office6, *office7, *office8;
head = new SubComponent("总部"); head = new SubComponent("总部");
sichuanBranch = new SubComponent("四川分部"); sichuanBranch = new SubComponent("四川分部");
office1 = new AdminOffice("行政办公室"); office1 = new AdminOffice("行政办公室");
office2 = new DeanOffice("教务办公室"); office2 = new DeanOffice("教务办公室");
cdBranch = new SubComponent("成都分部"); cdBranch = new SubComponent("成都分部");
myBranch = new SubComponent("绵阳分部"); myBranch = new SubComponent("绵阳分部");
office3 = new AdminOffice("行政办公室"); office3 = new AdminOffice("行政办公室");
office4 = new DeanOffice("教务办公室"); office4 = new DeanOffice("教务办公室");
office5 = new AdminOffice("行政办公室"); office5 = new AdminOffice("行政办公室");
office6 = new DeanOffice("教务办公室"); office6 = new DeanOffice("教务办公室");
office7 = new AdminOffice("行政办公室"); office7 = new AdminOffice("行政办公室");
office8 = new DeanOffice("教务办公室"); office8 = new DeanOffice("教务办公室");
cdBranch->add(office5); cdBranch->add(office5);
cdBranch->add(office6); cdBranch->add(office6);