Guest User

Untitled

a guest
Jan 23rd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. namespace FactoryMethod
  2. {
  3. public interface IPhone
  4. {
  5. decimal Price { get; }
  6. }
  7.  
  8. public class Nokia : IPhone
  9. {
  10. public decimal Price
  11. {
  12. get { return 200; }
  13. }
  14. }
  15.  
  16. public class Motorola : IPhone
  17. {
  18. public decimal Price
  19. {
  20. get { return 100; }
  21. }
  22. }
  23.  
  24. public class PhoneFactory
  25. {
  26. public IPhone GetPhone(string type)
  27. {
  28. switch (type)
  29. {
  30. case "Nokia":
  31. return new Nokia();
  32. case "Motorola":
  33. return new Motorola();
  34. default:
  35. return null;
  36. }
  37. }
  38. }
  39. }
Add Comment
Please, Sign In to add comment