mirror of
https://github.com/iandinwoodie/cpp-design-patterns-for-humans.git
synced 2025-12-17 12:34:38 +03:00
Corrected the slash-direction for comments.
This commit is contained in:
16
README.md
16
README.md
@@ -151,13 +151,13 @@ class DoorFactory
|
|||||||
Here is how this can be used:
|
Here is how this can be used:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
\\ Make a door with dimensions 100x200.
|
// Make a door with dimensions 100x200.
|
||||||
Door door = DoorFactory::makeDoor(100, 200);
|
Door door = DoorFactory::makeDoor(100, 200);
|
||||||
|
|
||||||
std::cout << "Width: " << door.getWidth() << std::endl;
|
std::cout << "Width: " << door.getWidth() << std::endl;
|
||||||
std::cout << "Height: " << door.getHeight() << std::endl;
|
std::cout << "Height: " << door.getHeight() << std::endl;
|
||||||
|
|
||||||
\\ We can use the factory again to make a door with dimensions 50x100.
|
// We can use the factory again to make a door with dimensions 50x100.
|
||||||
Door door2 = DoorFactory::makeDoor(50, 100);
|
Door door2 = DoorFactory::makeDoor(50, 100);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -264,10 +264,10 @@ Here is how this can be used:
|
|||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
DevelopmentManager developmentManager = DevelopmentManager();
|
DevelopmentManager developmentManager = DevelopmentManager();
|
||||||
developmentManager.takeInterview(); // Output: Asking about design patterns!
|
developmentManager.takeInterview(); \\ Output: Asking about design patterns!
|
||||||
|
|
||||||
MarketingManager marketingManager = MarketingManager();
|
MarketingManager marketingManager = MarketingManager();
|
||||||
marketingManager.takeInterview(); // Output: Asking about community building!
|
marketingManager.takeInterview(); \\ Output: Asking about community building!
|
||||||
```
|
```
|
||||||
|
|
||||||
#### When To Use
|
#### When To Use
|
||||||
@@ -409,15 +409,15 @@ DoorFactory woodenFactory = WoodenDoorFactory();
|
|||||||
Door door = woodenFactory.makeDoor();
|
Door door = woodenFactory.makeDoor();
|
||||||
DoorFittingExpert expert = woodenFactory.makeFittingExpert();
|
DoorFittingExpert expert = woodenFactory.makeFittingExpert();
|
||||||
|
|
||||||
door.getDescription(); // Output: I am a wooden door.
|
door.getDescription(); \\ Output: I am a wooden door.
|
||||||
expert.getDescription(); // Output: I can only fit wooden doors.
|
expert.getDescription(); \\ Output: I can only fit wooden doors.
|
||||||
|
|
||||||
DoorFactory ironFactory = IronDoorFactory();
|
DoorFactory ironFactory = IronDoorFactory();
|
||||||
Door door = ironFactory.makeDoor();
|
Door door = ironFactory.makeDoor();
|
||||||
DoorFittingExpert expert = woodenFactory.makeFittingExpert();
|
DoorFittingExpert expert = woodenFactory.makeFittingExpert();
|
||||||
|
|
||||||
door.getDescription(); // Output: I am an iron door.
|
door.getDescription(); \\ Output: I am an iron door.
|
||||||
expert.getDescription(); // Output: I can only fit iron doors.
|
expert.getDescription(); \\ Output: I can only fit iron doors.
|
||||||
```
|
```
|
||||||
|
|
||||||
As you can see the wooden door factory has encapsulated the carpenter and the
|
As you can see the wooden door factory has encapsulated the carpenter and the
|
||||||
|
|||||||
Reference in New Issue
Block a user