using System.IO;
using System;
using System.Collections.Generic;
class Program
{
static void Main()
{
Console.WriteLine("Hello, World!");
}
public class BaseCar
{
public int Position { get; set; } // номер стояночного места
public int Box { get; set; } //номер гаража
}
public class Tipper : BaseCar
{
public int Capacity { get; set; }
}
// Автобусы
public class Autobus : BaseCar
{
public int MaxPeople { get; set; }
}
public class Garage
{
public List<Autobus> autobus_list { get; set; }
public List<Tipper> tipper_list { get; set; }
public Garage()
{
autobus_list = new List<Autobus>();
tipper_list = new List<Tipper>();
}
}
public class Logic
{
public Garage garage = new Garage();
public List<Autobus> getListAutobusInBox(int box)
{
return garage.autobus_list.FindAll(x => x.Box == box);
}
public List<Tipper> getListTipperInBox(int box)
{
return garage.tipper_list.FindAll(x => x.Box == box);
}
public List<T> SortList<T>(List<T> list) where T : BaseCar
{
return list.Sort((x, y) => object.Equals(x, y) ? 0 : x.Position.CompareTo(y.Position)).ToList();
}
}
}
public abstract class BaseCar
public abstract CarType GetCarType();
public class Autobus : BaseCar
{
public override CarType GetCarType()
{
return CarType.Autobus;
}
public int MaxPeople {get;set;}
}
car.Type == typeof(Autobus)
, но будет медленней.