Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var first_wagon  = new Wagon("Вагон-бар", "РТ-200", WagonType.Passenger, 42, 0);
            var second_wagon = new Wagon("Фитинговая платформа", "13-1258-01", WagonType.Freight, 0, 72);

            Wagon[] wagons     = new Wagon[] { first_wagon, second_wagon };
            var     locomotive = new Locomotive("Маневровый тепловоз", "ЧМЭ2-293", LocomotiveType.Thermal);
            var     train      = new Train("Подвезем за сотку", locomotive, wagons);

            XmlSerializer formatter = new XmlSerializer(typeof(Train));

            using (FileStream fs = new FileStream("train.xml", FileMode.OpenOrCreate))
            {
                formatter.Serialize(fs, train);
            }
        }
Exemplo n.º 2
0
 public Train(string number, Locomotive locomotive, Wagon[] wagons)
 {
     Number     = number;
     Locomotive = locomotive;
     Wagons     = wagons;
 }