Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp1
  4. {
  5. class num
  6. {
  7. protected int people, animal; //доступ открыт классам, производным от данного.
  8. public int plants;
  9. public void Set(int num1, int num2)
  10. {
  11. people = num1;
  12. animal = num2;
  13. }
  14. }
  15. class Animal : num //наследование класса num
  16. {
  17. public void show()
  18. {
  19. Console.WriteLine(people/animal);
  20. Console.WriteLine(people*plants);
  21. }
  22. }
  23. class Program
  24. {
  25. static void Main(string[] args)
  26. {
  27. num ob = new num();
  28. Animal or = new Animal();
  29.  
  30. or.Set(10, 5);
  31. or.plants = 1000;
  32. or.show();
  33.  
  34. Console.ReadKey();
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement