Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.39 KB | None | 0 0
  1. public class Device
  2. {
  3.     public static Device Create(Type t, Color c) =>
  4.     (t,c) switch
  5.     {
  6.         (typeof(Iphone), Color.Gold) => new GoldIphone()
  7.         (typeof(Ipad), Color.Silver) => new SilverIpad()
  8.          ......
  9.     }
  10.      
  11. }
  12.  
  13. public class Iphone : Device
  14. {}
  15. public class GoldenIphone : Iphone
  16. {}
  17. public class Ipad : Device
  18. {}
  19. public class SilverIpad : Ipad
  20. {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement