Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Pr1
  4. {
  5.  
  6. class Avto
  7. {
  8. public string numb;
  9. public string model;
  10. public string color;
  11. public string fullName;
  12.  
  13. public void PrintInfo(string numb, string model, string color, string fullName)
  14. {
  15. Console.WriteLine("Auto Numb: {0} \nCar Model: {1} \nCar Color: {2}, \nOwner Full Name: {3} \n", numb, model, color, fullName);
  16.  
  17. }
  18.  
  19. }
  20.  
  21. class Book
  22. {
  23. private string autor = "[NULL]";
  24. private string name = "[NULL]";
  25. private string pubH = "[NULL]";
  26. private int pagesN = -1;
  27. private int pubY = -1;
  28. private static double price = 30;
  29.  
  30. public void Print()
  31. {
  32. Console.WriteLine("Autor: {0} \nBook Name: {1} \nPublishing House: {2} \nPages Numb: {3} \nPublishing Year: {4} \n", this.autor, this.name, this.pubH, this.pagesN, this.pubY);
  33. }
  34.  
  35. public void Default()
  36. {
  37. this.autor = "L.N. Tolstoy";
  38. this.name = "War and Peace";
  39. this.pubH = "Ecsmo";
  40. this.pagesN = 1225;
  41. this.pubY = 1867;
  42. }
  43.  
  44. public void SetPrice(double price)
  45. {
  46. Book.price = price;
  47. }
  48.  
  49. public double RentPrice(int s)
  50. {
  51. double cust = price * s;
  52. return cust;
  53. }
  54.  
  55. }
  56.  
  57. class Person
  58. {
  59. public string name;
  60. public int age;
  61.  
  62. public Person(string n)
  63. {
  64. Random rand = new Random();
  65. name = n;
  66. age = rand.Next(1, 100);
  67. }
  68.  
  69. public void Say()
  70. {
  71. Random rand = new Random();
  72. int rand_talk = rand.Next(2, 3);
  73. if (rand_talk == 1)
  74. Console.WriteLine("Привет, меня зовут {0}", name);
  75. else
  76. Console.WriteLine("Мне {0} лет, а тебе?", age);
  77. }
  78.  
  79. }
  80.  
  81. class MainClass
  82. {
  83. public static void Main(string[] args)
  84. {
  85. // Задание 1
  86. Avto myCar1 = new Avto();
  87. Avto myCar2 = new Avto();
  88.  
  89. myCar1.numb = "RCU 891";
  90. myCar1.model = "Volkswagen “polo“";
  91. myCar1.color = "Blue";
  92. myCar1.fullName = "Jane Olivier Andrey";
  93.  
  94. myCar2.numb = "ABA D12";
  95. myCar2.model = "Kia “Cerato“";
  96. myCar2.color = "Black";
  97. myCar2.fullName = "Jane Olivier Andrey";
  98.  
  99. myCar1.PrintInfo(myCar1.numb, myCar1.model, myCar1.color, myCar1.fullName);
  100. myCar2.PrintInfo(myCar2.numb, myCar2.model, myCar2.color, myCar2.fullName);
  101.  
  102. // Задание 2
  103. Book myBook = new Book();
  104. myBook.Default();
  105. myBook.Print();
  106.  
  107. myBook.SetPrice(20);
  108. Console.WriteLine("Rent Cost: {0} \n", myBook.RentPrice(3));
  109.  
  110. // Задание 3
  111. Person ti = new Person("Pasha");
  112. ti.Say();
  113. }
  114. }
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement