Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public abstract class FactoryBase
- {
- public abstract Product FactoryMethod(int type);
- }
- public class ConcreteFactory : FactoryBase
- {
- public override Product FactoryMethod(int type)
- {
- switch (type)
- {
- case 1:
- return new ConcreteProduct1();
- case 2:
- return new ConcreteProduct2();
- default:
- throw new ArgumentException("Invalid type.", "type");
- }
- }
- }
- public abstract class ProductBase { }
- public class ConcreteProduct1 : ProductBase { }
- public class ConcreteProduct2 : ProductBase { }
Add Comment
Please, Sign In to add comment