Skip to content

Instantly share code, notes, and snippets.

@htdangkhoa
Last active April 21, 2022 07:32
Show Gist options
  • Save htdangkhoa/e1c6a9d054892807751779831481bb39 to your computer and use it in GitHub Desktop.
Save htdangkhoa/e1c6a9d054892807751779831481bb39 to your computer and use it in GitHub Desktop.
import { AbstractFactory } from 'AbstractFactory';
import { ConcreteProductA1, ConcreteProductA2 } from 'ProductA';
import { ConcreteProductB1, ConcreteProductB2 } from 'ProductB';
export class ConcreteFactory1 implements AbstractFactory {
public createProductA(): AbstractProductA {
return new ConcreteProductA1();
}
public createProductB(): AbstractProductB {
return new ConcreteProductB1();
}
}
export class ConcreteFactory2 implements AbstractFactory {
public createProductA(): AbstractProductA {
return new ConcreteProductA2();
}
public createProductB(): AbstractProductB {
return new ConcreteProductB2();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment