Advertisement
Guest User

kon nqmam

a guest
Sep 22nd, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 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. namespace ConsoleApplication1
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Dog dog = new Dog();
  14. Cat cat = new Cat();
  15. Trainer gosho = new Trainer(dog);
  16. gosho.Make();
  17. Trainer penio = new Trainer(cat);
  18. penio.Make();
  19. Console.ReadLine();
  20. }
  21. }
  22. }
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33. using System;
  34. using System.Collections.Generic;
  35. using System.Linq;
  36. using System.Text;
  37. using System.Threading.Tasks;
  38.  
  39. namespace ConsoleApplication1
  40. {
  41. interface ITrick
  42. {
  43. string MakeTrick();
  44. }
  45. interface INoise
  46. {
  47. string MakeNoice();
  48. }
  49. interface IAnimal:ITrick,INoise
  50. {
  51. void Perform();
  52. }
  53. }
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74. using System;
  75. using System.Collections.Generic;
  76. using System.Linq;
  77. using System.Text;
  78. using System.Threading.Tasks;
  79.  
  80. namespace ConsoleApplication1
  81. {
  82. class Dog:IAnimal
  83. {
  84. public string MakeNoice()
  85. {
  86. return "jaf!";
  87. }
  88. public string MakeTrick()
  89. {
  90. return "backflip";
  91. }
  92. public void Perform()
  93. {
  94. Console.WriteLine( MakeNoice());
  95. Console.WriteLine( MakeTrick());
  96. }
  97. }
  98. }
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119. using System;
  120. using System.Collections.Generic;
  121. using System.Linq;
  122. using System.Text;
  123. using System.Threading.Tasks;
  124.  
  125. namespace ConsoleApplication1
  126. {
  127. class Cat:IAnimal
  128. {
  129. public string MakeNoice()
  130. {
  131. return "MEW!";
  132. }
  133. public string MakeTrick()
  134. {
  135. return "nqq pa";
  136. }
  137. public void Perform()
  138. {
  139. Console.WriteLine(MakeNoice());
  140. Console.WriteLine(MakeTrick());
  141. }
  142. }
  143. }
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190. using System;
  191. using System.Collections.Generic;
  192. using System.Linq;
  193. using System.Text;
  194. using System.Threading.Tasks;
  195.  
  196. namespace ConsoleApplication1
  197. {
  198. class Trainer
  199. {
  200. private IAnimal entity;
  201. public Trainer(IAnimal animal)
  202. {
  203. entity = animal;
  204. }
  205. public void Make()
  206. {
  207. entity.Perform();
  208. }
  209.  
  210. }
  211. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement