Beispiel #1
0
 public CarCatalog(CarFactory carFactory, EngineFactory engineFactory, TireFactory tireFactory)
 {
     this.cars          = new List <Car>();
     this.carFactory    = carFactory;
     this.engineFactory = engineFactory;
     this.tireFactory   = tireFactory;
 }
Beispiel #2
0
 public static void Used()
 {
     var factory = new TireFactory();
     var tireA1  = factory.CreateTire <TireA>();
     var tireA2  = factory.CreateTire <TireA>();
     var tireB1  = factory.CreateTire <TireA>();
     var tireB2  = factory.CreateTire <TireA>();
 }
Beispiel #3
0
 public CarsCatalog(EngineFactory engineFactory,
                    CargoFactory cargoFactory,
                    TireFactory tireFactory,
                    CarFactory carFactory)
 {
     this.Cars          = new List <Car>();
     this.engineFactory = engineFactory;
     this.cargoFactory  = cargoFactory;
     this.tireFactory   = tireFactory;
     this.carFactory    = carFactory;
     this.dataWrite     = new ConsoleWriter();
 }
Beispiel #4
0
        public static void Main(string[] args)
        {
            int carsCount = int.Parse(Console.ReadLine());

            CarFactory    carFactory    = new CarFactory();
            EngineFactory engineFactory = new EngineFactory();
            TireFactory   tireFactory   = new TireFactory();

            CarCatalog carCatalog = new CarCatalog(carFactory, engineFactory, tireFactory);

            for (int i = 0; i < carsCount; i++)
            {
                string[] carArgs = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                carCatalog.Add(carArgs);
            }

            string command = Console.ReadLine();

            carCatalog.GetCarInfo(command);
        }
Beispiel #5
0
        public static void Run()
        {
            EngineFactory engineFactory = new EngineFactory();
            CargoFactory  cargoFactory  = new CargoFactory();
            TireFactory   tireFactory   = new TireFactory();
            CarFactory    carFactory    = new CarFactory();
            ConsoleReader consoleReader = new ConsoleReader();

            CarsCatalog cars = new CarsCatalog(engineFactory, cargoFactory, tireFactory, carFactory);

            int lines = int.Parse(consoleReader.Read());

            for (int i = 0; i < lines; i++)
            {
                string[] parameters = consoleReader.Read()
                                      .Split(" ", StringSplitOptions.RemoveEmptyEntries);

                cars.Add(parameters);
            }

            string command = consoleReader.Read();

            cars.GetCarsInfo(command);
        }