forked from shihyu/DesignPatternExample
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jason_yao
committed
Oct 20, 2013
1 parent
6673e9b
commit cdd40d4
Showing
31 changed files
with
1,098 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
#include "BridgeMain.h" | ||
using namespace brige; | ||
|
||
namespace brige { | ||
|
||
void BridgeMain::main(std::string args[]) { | ||
Mobile* nokia = new NokiaMobile("Nokia"); | ||
MobileSoft* game = new MobileGame(); | ||
nokia->setSoft(game); | ||
nokia->run(); | ||
Mobile* moto = new MotoMible("Moto"); | ||
MobileSoft* mp3 = new MobileMp3(); | ||
moto->setSoft(mp3); | ||
moto->run(); | ||
} | ||
} | ||
int main() { | ||
Mobile* nokia = new NokiaMobile("Nokia"); | ||
MobileSoft* game = new MobileGame(); | ||
nokia->setSoft(game); | ||
nokia->run(); | ||
Mobile* moto = new MotoMible("Moto"); | ||
MobileSoft* mp3 = new MobileMp3(); | ||
moto->setSoft(mp3); | ||
moto->run(); | ||
return 0; | ||
} |
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
#include "MobileGame.h" | ||
#include <iostream> | ||
|
||
namespace brige { | ||
|
||
void MobileGame::run() { | ||
puts("run mobile game!"); | ||
std::cout << "run mobile game!" << std::endl; | ||
} | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
#include "MobileMp3.h" | ||
#include <iostream> | ||
|
||
namespace brige { | ||
|
||
void MobileMp3::run() { | ||
puts("run mobile mp3!"); | ||
std::cout << "run mobile mp3!" << std::endl; | ||
} | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
#include "MotoMible.h" | ||
#include <iostream> | ||
|
||
namespace brige { | ||
|
||
MotoMible::MotoMible(std::string brand) : Mobile(brand) { | ||
} | ||
|
||
void MotoMible::run() { | ||
puts("Moto Mobile: "); | ||
std::cout << "Moto Mobile: " << std::endl; | ||
this->getSoft()->run(); | ||
} | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
#include "NokiaMobile.h" | ||
#include <iostream> | ||
|
||
namespace brige { | ||
|
||
NokiaMobile::NokiaMobile(std::string brand) : Mobile(brand) { | ||
} | ||
|
||
void NokiaMobile::run() { | ||
puts("Nokia Mobile: "); | ||
std::cout << "Nokia Mobile: " << std::endl; | ||
this->getSoft()->run(); | ||
} | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
###################################################################### | ||
# Automatically generated by qmake (3.0) ?? 10? 19 21:58:03 2013 | ||
###################################################################### | ||
|
||
TEMPLATE = app | ||
TARGET = brige | ||
INCLUDEPATH += . | ||
CONFIG = warn_on debug | ||
INCLUDEPATH | ||
LIBS | ||
|
||
|
||
# Input | ||
HEADERS += BridgeMain.h \ | ||
Mobile.h \ | ||
MobileGame.h \ | ||
MobileMp3.h \ | ||
MobileSoft.h \ | ||
MotoMible.h \ | ||
NokiaMobile.h | ||
SOURCES += BridgeMain.cpp \ | ||
Mobile.cpp \ | ||
MobileGame.cpp \ | ||
MobileMp3.cpp \ | ||
MobileSoft.cpp \ | ||
MotoMible.cpp \ | ||
NokiaMobile.cpp |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,27 @@ | ||
#include "CompositeMain.h" | ||
#include <iostream> | ||
using namespace composite; | ||
|
||
namespace composite { | ||
|
||
void CompositeMain::main(std::string args[]) { | ||
ConcreteCompany* root = new ConcreteCompany("The Head Office Of Our Company In Beijing"); | ||
root->add(new HRDepartment("Head Office HR")); | ||
root->add(new FinanceDepartment("Head Office Finance")); | ||
ConcreteCompany* comp = new ConcreteCompany("The leaf company in shanghai"); | ||
comp->add(new HRDepartment("shanghai office HR")); | ||
comp->add(new FinanceDepartment("shanghai office finance")); | ||
root->add(comp); | ||
ConcreteCompany* comp1 = new ConcreteCompany("the office of shanghai company in nanjing"); | ||
comp1->add(new HRDepartment("nanjing office HR")); | ||
comp1->add(new FinanceDepartment("nanjing office finance")); | ||
comp->add(comp1); | ||
ConcreteCompany* comp2 = new ConcreteCompany("the office of shanghai company in hangzhou"); | ||
comp2->add(new HRDepartment("hangzhou office HR")); | ||
comp2->add(new FinanceDepartment("hangzhou office finance")); | ||
comp->add(comp2); | ||
puts("the structure of our company:"); | ||
root->display(1); | ||
puts("the duty of every department:"); | ||
root->lineOfDuty(); | ||
} | ||
} | ||
int main() { | ||
ConcreteCompany* root = new ConcreteCompany("The Head Office Of Our Company In Beijing"); | ||
root->add(new HRDepartment("Head Office HR")); | ||
root->add(new FinanceDepartment("Head Office Finance")); | ||
ConcreteCompany* comp = new ConcreteCompany("The leaf company in shanghai"); | ||
comp->add(new HRDepartment("shanghai office HR")); | ||
comp->add(new FinanceDepartment("shanghai office finance")); | ||
root->add(comp); | ||
ConcreteCompany* comp1 = new ConcreteCompany("the office of shanghai company in nanjing"); | ||
comp1->add(new HRDepartment("nanjing office HR")); | ||
comp1->add(new FinanceDepartment("nanjing office finance")); | ||
comp->add(comp1); | ||
ConcreteCompany* comp2 = new ConcreteCompany("the office of shanghai company in hangzhou"); | ||
comp2->add(new HRDepartment("hangzhou office HR")); | ||
comp2->add(new FinanceDepartment("hangzhou office finance")); | ||
comp->add(comp2); | ||
std::cout << "the structure of our company:" << std::endl; | ||
root->display(1); | ||
std::cout << "the duty of every department:" << std::endl; | ||
root->lineOfDuty(); | ||
return 0; | ||
} |
Binary file not shown.
Oops, something went wrong.