Last active
April 21, 2022 07:32
-
-
Save htdangkhoa/4602482121553989c269dd64ef015194 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import { AbstractFactory } from './AbstractFactory'; | |
import { ConcreteFactory1, ConcreteFactory2 } from './ConcreteFactory' | |
function clientCode(factory: AbstractFactory) { | |
const productA = factory.createProductA(); | |
const productB = factory.createProductB(); | |
console.log(productA.usefulFunctionA()); | |
console.log(productB.usefulFunctionB()); | |
} | |
console.log("Client: Testing client code with ConcreteFactory1"); | |
clientCode(new ConcreteFactory1()); | |
console.log("----------------"); | |
console.log("Client: Testing the same client code with ConcreteFactory2"); | |
clientCode(new ConcreteFactory2()); | |
/* | |
Output: | |
Client: Testing client code with ConcreteFactory1 | |
The result of the product A1. | |
The result of the product B1. | |
---------------- | |
Client: Testing the same client code with ConcreteFactory2 | |
The result of the product A2. | |
The result of the product B2. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment