Advertisement
Guest User

Untitled

a guest
Feb 14th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. /* C# Example of Abstratcion: An application for mobile manufacturing company - Every phone must have to implement caller
  8. * and sms feature but it depends on company to company (or model to model) if they want to include other features or not
  9. * which are readily available , you just have to use it without knowing its implementation (like facebook in this example).
  10. */
  11. namespace AbstractTest
  12. {
  13. public abstract class feature
  14. {
  15. public abstract void Caller();
  16. public abstract void SMS();
  17. public void facebook()
  18. {
  19. Console.WriteLine("You are using facebook");
  20. }
  21. }
  22. public class Iphone : feature
  23. {
  24. public override void Caller()
  25. {
  26. Console.WriteLine("iPhone caller feature");
  27. }
  28. public override void SMS()
  29. {
  30. Console.WriteLine("iPhone sms feature");
  31. }
  32. public void otherFeature()
  33. {
  34. facebook();
  35. }
  36. }
  37. public class Nokia : feature
  38. {
  39. public override void Caller()
  40. {
  41. Console.WriteLine("Nokia caller feature");
  42. }
  43. public override void SMS()
  44. {
  45. Console.WriteLine("Nokia sms feature");
  46. }
  47. public void otherFeature()
  48. {
  49. }
  50. }
  51.  
  52. class Program
  53. {
  54. static void Main(string[] args)
  55. {
  56. Iphone c1 = new Iphone();
  57. c1.Caller();
  58. c1.SMS();
  59. c1.otherFeature();
  60. Nokia n1 = new Nokia();
  61. n1.Caller();
  62. n1.SMS();
  63. n1.otherFeature();
  64. Console.ReadLine();
  65. }
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement