Advertisement
slawea

Untitled

Sep 30th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.81 KB | None | 0 0
  1. public interface IPartShop { }
  2.  
  3. class Roof : IPartShop { }
  4. class Floor : IPartShop { }
  5. class Wall : IPartShop { }
  6.  
  7. public abstract class PartShopFactory
  8. {
  9.     public abstract IPartShop BuildPartShop();
  10. }
  11.  
  12. public class RoofFactory : PartShopFactory
  13. {
  14.     public override IPartShop BuildPartShop()
  15.     {
  16.         return new Roof();
  17.     }
  18. }
  19.  
  20. public class FloorFactory : PartShopFactory
  21. {
  22.     public override IPartShop BuildPartShop()
  23.     {
  24.         return new Floor();
  25.     }
  26. }
  27.  
  28. public class WallFactory : PartShopFactory
  29. {
  30.     public override IPartShop BuildPartShop()
  31.     {
  32.         return new Wall();
  33.     }
  34. }
  35. static void Main(string[] args)
  36. {
  37.      PartShopFactory pathShopFactory = new RoofFactory();
  38.  
  39.      IPartShop roof = pathShopFactory.BuildPartShop();
  40.  
  41.      Console.ReadKey();
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement