Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var endCommand = "end";
            var curCommand = String.Empty;
            var catalog    = new Catalog();

            while ((curCommand = Console.ReadLine()) != endCommand)
            {
                var vehicleArgs = curCommand.Split('/', StringSplitOptions.RemoveEmptyEntries);
                var type        = vehicleArgs[0];
                var brand       = vehicleArgs[1];
                var model       = vehicleArgs[2];
                var hpOrWeight  = int.Parse(vehicleArgs[3]);

                if (type.ToLower() == "car")
                {
                    var curCar = new Car(model, brand, hpOrWeight);
                    catalog.AddCar(curCar);
                }
                else if (type.ToLower() == "truck")
                {
                    var curTruck = new Truck(model, brand, hpOrWeight);
                    catalog.AddTruck(curTruck);
                }
            }

            var cars   = catalog.Cars.OrderBy(x => x.Brand);
            var trucks = catalog.Trucks.OrderBy(x => x.Brand);

            if (cars.Any())
            {
                PrintsCars(cars);
            }

            if (trucks.Any())
            {
                PrintsTrucks(trucks);
            }
        }
Ejemplo n.º 2
0
 public void Execute()
 {
     catalog.AddCar(this, Brand, Model, NumberOfCars, Price);
 }