ChameL1oN

ЯПЛаба4_2

Apr 13th, 2015
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 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. using System.IO;
  7.  
  8. namespace Charp2_1
  9. {
  10.  
  11.  
  12. public class Person
  13. {
  14. public string Name { get; set; }
  15. public string Surname { get; set; }
  16. public int Age { get; set; }
  17. public string Sex { get; set; }
  18.  
  19. public Person(string Name,string Surname,int Age,string Sex)
  20. {
  21. this.Name = Name;
  22. this.Surname = Surname;
  23. this.Age = Age;
  24. this.Sex = Sex;
  25. }
  26. public void Print()
  27. {
  28. Console.Write(this.Name + " " + this.Surname + " Возраст : " + this.Age + " Пол : " + this.Sex );
  29. }
  30. }
  31. public class Employee : Person
  32. {
  33. string Company { get; set; }
  34. string Job { get; set; }
  35. int Moneys { get; set; }
  36.  
  37. public Employee(string Name, string Surname, int Age, string Sex, string Company, string Job, int Moneys):base(Name, Surname, Age, Sex)
  38. {
  39. this.Company = Company;
  40. this.Job = Job;
  41. this.Moneys = Moneys;
  42. }
  43. public void Print()
  44. {
  45. base.Print();
  46. Console.WriteLine(" " + this.Company + " " + this.Job + " " + this.Moneys);
  47. }
  48. }
  49. class Program
  50. {
  51. static void Main()
  52. {
  53. StreamReader f = File.OpenText("input.txt");
  54. StreamWriter f2 = new StreamWriter("output.txt");
  55. int n = 2;
  56. Employee[] a = new Employee[n];
  57. for (int i = 0; i < n; i++)
  58. {
  59. string s = f.ReadLine();
  60. string[] w = new string[7];
  61. w[0] = s.Split(' ')[0];
  62. w[1] = s.Split(' ')[1];
  63. w[2] = s.Split(' ')[2];
  64. w[3] = s.Split(' ')[3];
  65. w[4] = s.Split(' ')[4];
  66. w[5] = s.Split(' ')[5];
  67. w[6] = s.Split(' ')[6];
  68. a[i] = new Employee(w[0], w[1], Convert.ToInt32(w[2]), w[3], w[4], w[5], Convert.ToInt32(w[6]));
  69. a[i].Print();
  70. }
  71. Console.WriteLine("");
  72. Console.WriteLine("Список Мужчин");
  73. for (int i = 0; i < n; i++)
  74. {
  75. if (a[i].Sex == "М")
  76. {
  77. a[i].Print();
  78. }
  79. }
  80. Console.WriteLine("");
  81. Console.WriteLine("Список Женщин");
  82. for (int i = 0; i < n; i++)
  83. {
  84. if (a[i].Sex == "Ж")
  85. {
  86. a[i].Print();
  87. }
  88. }
  89. Console.WriteLine("");
  90. Console.WriteLine("Люди старше 40 лет");
  91. for (int i = 0; i < n; i++)
  92. {
  93. if (a[i].Age > 40)
  94. {
  95. a[i].Print();
  96. }
  97. }
  98.  
  99. }
  100. }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment