Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. obj = obj@MySuperClass(SuperClassArguments);
  2.  
  3. classdef subClass < superClass
  4. properties (Access = public)
  5. arg1 = 1
  6. end
  7.  
  8. methods
  9. function obj = subClass(arg1)
  10. obj = obj@superClass(arg1);
  11. end
  12. end
  13. end
  14.  
  15. classdef superClass
  16. properties (Access = protected)
  17. arg2
  18. end
  19.  
  20. methods
  21. function obj = superClass(local_arg1)
  22. switch local_arg1
  23. case 1
  24. obj = functionA();
  25. otherwise
  26. obj = functionB();
  27. end
  28. end
  29. end
  30. end
  31. function obj = functionA(obj)
  32. obj.arg2 = 1;
  33. end
  34. function obj = functionB(obj)
  35. obj.arg2 = 2;
  36. end
  37.  
  38. >> a = subClass(1);
  39.  
  40. classdef superClass
  41. properties (Access = protected)
  42. arg2
  43. end
  44.  
  45. methods
  46. function obj = superClass(local_arg1)
  47. switch local_arg1
  48. case 1
  49. obj = functionA(obj);
  50. %Or: obj = obj.functionA();
  51. otherwise
  52. obj = functionB(obj);
  53. %Or: obj = obj.functionB();
  54. end
  55. end
  56. end
  57.  
  58. methods (Access = private)
  59. function obj = functionA(obj)
  60. obj.arg2 = 1;
  61. end
  62. function obj = functionB(obj)
  63. obj.arg2 = 2;
  64. end
  65. end
  66. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement