Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.IO;
- namespace Девятая
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- Dispatcher me = new Dispatcher();
- me.initial();
- InitializeComponent();
- button1.Click += Button1_Click;
- for (int i = 0; i < me.voyages.Count(); i++)
- {
- listBox1.Items.Add(me.voyages[i].from + "-" + me.voyages[i].where);
- }
- }
- private void Button1_Click(object sender, EventArgs e)
- {
- button1.Text = "ы";
- }
- class Dispatcher
- {
- //сюда методы пользователя
- public StreamReader sr_voyage = new StreamReader("../../Тесты/Рейсы.txt");
- public StreamReader sr_driver = new StreamReader("../../Тесты/Водители.txt");
- public StreamReader sr_car = new StreamReader("../../Тесты/Автомобили.txt");
- public StreamWriter sw = new StreamWriter("../../Тесты/Тесты.txt");
- public List<Voyage> voyages = new List<Voyage>();
- public List<Car> cars = new List<Car>();
- public List<Driver> drivers = new List<Driver>();
- public void initial()
- {
- for (string l = sr_voyage.ReadLine(); !sr_voyage.EndOfStream; l = sr_voyage.ReadLine())
- {
- Voyage a = new Voyage(l, sr_voyage.ReadLine(), sr_voyage.ReadLine(), sr_voyage.ReadLine());
- voyages.Add(a);
- }
- for (string l = sr_driver.ReadLine(); !sr_driver.EndOfStream; l = sr_driver.ReadLine())
- {
- Driver a = new Driver(l, sr_driver.ReadLine());
- drivers.Add(a);
- }
- for (string l = sr_car.ReadLine(); !sr_car.EndOfStream; l = sr_car.ReadLine())
- {
- Car a = new Car(l, sr_car.ReadLine());
- cars.Add(a);
- }
- sw.WriteLine(voyages.Count());
- sw.WriteLine(voyages[0].from);
- sw.Close();
- sr_voyage.Close();
- sr_driver.Close();
- sr_car.Close();
- StreamWriter sw_voyage = new StreamWriter("../../Тесты/Рейсы.txt");
- StreamWriter sw_driver = new StreamWriter("../../Тесты/Водители.txt");
- StreamWriter sw_car = new StreamWriter("../../Тесты/Автомобили.txt");
- for (int i = 0; i < voyages.Count(); i++)
- {
- sw_voyage.WriteLine(voyages[i].from);
- sw_voyage.WriteLine(voyages[i].where);
- sw_voyage.WriteLine(voyages[i].data);
- sw_voyage.WriteLine(voyages[i].time);
- }
- for (int i = 0; i < drivers.Count(); i++)
- {
- sw_driver.WriteLine(drivers[i].name);
- sw_driver.WriteLine(drivers[i].status);
- }
- for (int i = 0; i < cars.Count(); i++)
- {
- sw_car.WriteLine(cars[i].name);
- sw_car.WriteLine(cars[i].status);
- }
- sw_voyage.Close();
- sw_car.Close();
- sw_voyage.Close();
- }
- }
- class Car
- {
- public string name;
- public string status;
- public Car(string name, string status)
- {
- this.name = name;
- this.status = status;
- }
- }
- class Driver
- {
- public string name;
- public string status;
- public Driver(string name, string status)
- {
- this.name = name;
- this.status = status;
- }
- }
- class Voyage
- {
- public string from;
- public string where;
- public string data;
- public string time;
- public Voyage(string from, string where, string data, string time)
- {
- this.from = from;
- this.where = where;
- this.data = data;
- this.time = time;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement