Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public interface IPartShop { }
- class Roof : IPartShop { }
- class Floor : IPartShop { }
- class Wall : IPartShop { }
- public abstract class PartShopFactory
- {
- public abstract IPartShop BuildPartShop();
- }
- public class RoofFactory : PartShopFactory
- {
- public override IPartShop BuildPartShop()
- {
- return new Roof();
- }
- }
- public class FloorFactory : PartShopFactory
- {
- public override IPartShop BuildPartShop()
- {
- return new Floor();
- }
- }
- public class WallFactory : PartShopFactory
- {
- public override IPartShop BuildPartShop()
- {
- return new Wall();
- }
- }
- static void Main(string[] args)
- {
- PartShopFactory pathShopFactory = new RoofFactory();
- IPartShop roof = pathShopFactory.BuildPartShop();
- Console.ReadKey();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement