Advertisement
Guest User

Untitled

a guest
May 27th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. class User{
  2.  
  3. }
  4.  
  5. class Iuser extends User{
  6. private $name;
  7. function __construct($name){
  8. $this->name = $name;
  9. }
  10. function getName(){
  11. return strtoupper($this->name);
  12. }
  13. }
  14.  
  15. class Wuser extends User{
  16. private $name;
  17. function __construct($name){
  18. $this->name = $name;
  19. }
  20. function getName(){
  21. return strtolower($this->name);
  22. }
  23. }
  24.  
  25. class Name{
  26. public $u;
  27. function __construct(User $u){
  28. $this->u = $u;
  29. }
  30.  
  31. function getName(){
  32. $name = $this->u->getName();
  33. return "Hi My Name is ".$name;
  34. }
  35. }
  36.  
  37. $name = "Deval Patel";
  38. $iu = new Iuser($name);
  39. $wu = new Wuser($name);
  40. $user = new Name($wu);
  41. echo $user->getName();
  42.  
  43. interface User{
  44. public function getName();
  45. }
  46.  
  47. class Iuser implements User{
  48. private $name;
  49. function __construct($name){
  50. $this->name = $name;
  51. }
  52. function getName(){
  53. return strtoupper($this->name);
  54. }
  55. }
  56.  
  57. class Wuser implements User{
  58. private $name;
  59. function __construct($name){
  60. $this->name = $name;
  61. }
  62. function getName(){
  63. return strtolower($this->name);
  64. }
  65. }
  66.  
  67. class Name{
  68. public $u;
  69. function __construct(User $u){
  70. $this->u = $u;
  71. }
  72.  
  73. function getName(){
  74. $name = $this->u->getName();
  75. return "Hi My Name is ".$name;
  76. }
  77. }
  78.  
  79. $name = "Deval Patel";
  80. $iu = new Iuser($name);
  81. $wu = new Wuser($name);
  82. $user = new Name($iu);
  83. echo $user->getName();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement