Advertisement
stupid_pro

Untitled

Nov 12th, 2021
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. using System;
  2. class First
  3. {
  4. public static void Main(string[] args)
  5. {
  6. Human oleg = new Human();
  7. Animal dog = new Animal();
  8. Phone iphoneX = new Phone();
  9. Computer macbookWindows = new Computer();
  10. }
  11. }
  12. class Human
  13. {
  14. string sex = null;
  15. public Human()
  16. {
  17. Console.WriteLine("Олег родился");
  18. intro();
  19. }
  20. void intro()
  21. {
  22. Console.WriteLine("Привет! Я - человек. Выбери мне имя, пол, возраст и научите ездить");
  23. }
  24. public void maleOrfemale()
  25. {
  26. Console.WriteLine("1 - male, 2 - female");
  27. }
  28. public string chooseSex (int decision)
  29. {
  30. if (decision == 1) this.sex = "Male"; //this присваивает значение глобальной переменной класса
  31. if (decision == 2) this.sex = "Female";
  32. return sex;
  33. }
  34. public void writeSex()
  35. {
  36. Console.WriteLine(sex + "from object");
  37. }
  38. }
  39. class Animal
  40. {
  41. public Animal()
  42. {
  43. Console.WriteLine("СОБАКА " + 12 + "лет!");
  44. }
  45. }
  46. class Phone
  47. {
  48. public Phone()
  49. {
  50. Console.WriteLine("Apple Iphone");
  51. }
  52. }
  53. class Text
  54. {
  55.  
  56. }
  57. class Computer
  58. {
  59. public Computer()
  60. {
  61. Console.WriteLine("Minecraft запустись");
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement