export interface Product {
method(param?: any) : void;
}
export class ConcreteProductA implements Product {
method = (param?: any) => {
return "Method of ConcreteProductA";
}
}
export class ProductFactory {
public static createProduct(type: string) : Product {
if (type === "A") {
return new ConcreteProductA();
}
return null;
}
}
Factory class
Create an object without exposing the creation logic to the client and refer to newly created objects using a common interface.
0 Comments
Add Comment
Log in to add a comment