Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.74 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.IO;
  11. namespace Девятая
  12. {
  13.  
  14. public partial class Form1 : Form
  15. {
  16.  
  17. public Form1()
  18. {
  19. Dispatcher me = new Dispatcher();
  20. me.initial();
  21.  
  22. InitializeComponent();
  23. button1.Click += Button1_Click;
  24. for (int i = 0; i < me.voyages.Count(); i++)
  25. {
  26. listBox1.Items.Add(me.voyages[i].from + "-" + me.voyages[i].where);
  27. }
  28. }
  29.  
  30. private void Button1_Click(object sender, EventArgs e)
  31. {
  32. button1.Text = "ы";
  33.  
  34. }
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45. class Dispatcher
  46. {
  47. //сюда методы пользователя
  48. public StreamReader sr_voyage = new StreamReader("../../Тесты/Рейсы.txt");
  49. public StreamReader sr_driver = new StreamReader("../../Тесты/Водители.txt");
  50. public StreamReader sr_car = new StreamReader("../../Тесты/Автомобили.txt");
  51. public StreamWriter sw = new StreamWriter("../../Тесты/Тесты.txt");
  52.  
  53. public List<Voyage> voyages = new List<Voyage>();
  54. public List<Car> cars = new List<Car>();
  55. public List<Driver> drivers = new List<Driver>();
  56.  
  57. public void initial()
  58. {
  59.  
  60.  
  61. for (string l = sr_voyage.ReadLine(); !sr_voyage.EndOfStream; l = sr_voyage.ReadLine())
  62. {
  63. Voyage a = new Voyage(l, sr_voyage.ReadLine(), sr_voyage.ReadLine(), sr_voyage.ReadLine());
  64. voyages.Add(a);
  65.  
  66. }
  67. for (string l = sr_driver.ReadLine(); !sr_driver.EndOfStream; l = sr_driver.ReadLine())
  68. {
  69. Driver a = new Driver(l, sr_driver.ReadLine());
  70. drivers.Add(a);
  71.  
  72.  
  73. }
  74. for (string l = sr_car.ReadLine(); !sr_car.EndOfStream; l = sr_car.ReadLine())
  75. {
  76. Car a = new Car(l, sr_car.ReadLine());
  77. cars.Add(a);
  78.  
  79.  
  80. }
  81.  
  82. sw.WriteLine(voyages.Count());
  83. sw.WriteLine(voyages[0].from);
  84. sw.Close();
  85. sr_voyage.Close();
  86. sr_driver.Close();
  87. sr_car.Close();
  88.  
  89. StreamWriter sw_voyage = new StreamWriter("../../Тесты/Рейсы.txt");
  90. StreamWriter sw_driver = new StreamWriter("../../Тесты/Водители.txt");
  91. StreamWriter sw_car = new StreamWriter("../../Тесты/Автомобили.txt");
  92.  
  93. for (int i = 0; i < voyages.Count(); i++)
  94. {
  95. sw_voyage.WriteLine(voyages[i].from);
  96. sw_voyage.WriteLine(voyages[i].where);
  97. sw_voyage.WriteLine(voyages[i].data);
  98. sw_voyage.WriteLine(voyages[i].time);
  99.  
  100. }
  101.  
  102. for (int i = 0; i < drivers.Count(); i++)
  103. {
  104. sw_driver.WriteLine(drivers[i].name);
  105. sw_driver.WriteLine(drivers[i].status);
  106.  
  107. }
  108. for (int i = 0; i < cars.Count(); i++)
  109. {
  110. sw_car.WriteLine(cars[i].name);
  111. sw_car.WriteLine(cars[i].status);
  112.  
  113.  
  114. }
  115.  
  116. sw_voyage.Close();
  117. sw_car.Close();
  118. sw_voyage.Close();
  119.  
  120. }
  121. }
  122. class Car
  123. {
  124. public string name;
  125. public string status;
  126. public Car(string name, string status)
  127. {
  128. this.name = name;
  129. this.status = status;
  130. }
  131. }
  132. class Driver
  133. {
  134. public string name;
  135. public string status;
  136.  
  137. public Driver(string name, string status)
  138. {
  139. this.name = name;
  140. this.status = status;
  141. }
  142. }
  143. class Voyage
  144. {
  145. public string from;
  146. public string where;
  147. public string data;
  148. public string time;
  149.  
  150. public Voyage(string from, string where, string data, string time)
  151. {
  152. this.from = from;
  153. this.where = where;
  154. this.data = data;
  155. this.time = time;
  156. }
  157. }
  158.  
  159.  
  160.  
  161.  
  162. }
  163. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement