Exemple #1
0
 public CommandLineParser(IConsoleInputOutput console, Dictionary <string, Commands> commandDictionary, IVehicleManager vehicleManager, ICommandExecuterFactory commandExecuterFactory)
 {
     this.console                = console;
     this.commandDictionary      = commandDictionary;
     this.vehicleManager         = vehicleManager;
     this.commandExecuterFactory = commandExecuterFactory;
 }
        private string[] preParse(IConsoleInputOutput console, int count, out int parkingPlaceId)
        {
            parkingPlaceId = 0;
            var str             = console.ReadLine();
            var propertyStrings = str.Split(',');

            if (propertyStrings.Count() == count)
            {
                int.TryParse(propertyStrings[count - 1], out parkingPlaceId);
            }
            return(propertyStrings);
        }
 public CommandExecuterFactory(
     IVehicleManager vehilceManager,
     IConsoleInputOutput console,
     IVehicleParser vehicleParser,
     IGarageManager garageManager,
     IGarageParser garageParser,
     ICsvImporter csvImporter,
     IFileInputOutput file)
 {
     this.vehicleParser  = vehicleParser;
     this.vehilceManager = vehilceManager;
     this.console        = console;
     this.garageManager  = garageManager;
     this.garageParser   = garageParser;
     this.csvImporter    = csvImporter;
     this.file           = file;
 }
Exemple #4
0
 public CommandExecuter(IVehicleManager vehicleManager,
                        IConsoleInputOutput consoleInputOutput,
                        IVehicleParser vehicleParser,
                        IGarageManager garageManager,
                        IGarageParser garageParser,
                        ICsvImporter csvImporter,
                        IFileInputOutput file
                        )
 {
     this.selectedVehicles = new Dictionary <Vehicle, ParkingPlaceOutput>();
     this.vehicleManager   = vehicleManager;
     this.console          = consoleInputOutput;
     this.vehicleParser    = vehicleParser;
     this.garageManager    = garageManager;
     this.garageParser     = garageParser;
     this.csvImporter      = csvImporter;
     this.file             = file;
 }
Exemple #5
0
        public Garage Parse(IConsoleInputOutput console, out uint count)
        {
            console.WriteLine("Geben Sie das Parkhaus in folgendem Format ein:");
            console.WriteInfo("Ort, Plz, Straße & Nummer, Anzahl der Parkplätze");
            var str             = console.ReadLine();
            var propertyStrings = str.Split(',');

            count = (uint)propertyStrings.Count();
            if (count == 4)
            {
                uint.TryParse(propertyStrings[count - 1], out count);
                return(new Garage()
                {
                    City = propertyStrings[0],
                    Zip = propertyStrings[1],
                    Street = propertyStrings[2]
                });
            }
            return(null);
        }
        public Vehicle Parse(IConsoleInputOutput console, string parameter)
        {
            string str;

            if (parameter == "c")
            {
                console.WriteLine("Geben Sie den PKW in folgendem Format ein:");
                console.WriteInfo("Hersteller, Modell, Kennzeichen, Jahr der Erstzulassung, Anschaffungspreis, Hubraum, Leistung, Schadstoffklasse [0-schadstoffarm, 1-normal, 2-Diesel] ");
                str = console.ReadLine();
                var propertyStrings = str.Split(',');
                if (propertyStrings.Count() == 8)
                {
                    return(Parse(propertyStrings, parameter));
                }
            }
            else if (parameter == "m")
            {
                console.WriteLine("Geben Sie das Motorrad in folgendem Format ein:");
                console.WriteInfo("Hersteller, Modell, Kennzeichen, Jahr der Erstzulassung, Anschaffungspreis, Hubraum");
                str = console.ReadLine();
                var propertyStrings = str.Split(',');
                if (propertyStrings.Count() == 6)
                {
                    return(Parse(propertyStrings, parameter));
                }
            }
            else if (parameter == "t")
            {
                console.WriteLine("Geben Sie den LKW in folgendem Format ein:");
                console.WriteInfo("Hersteller, Modell, Kennzeichen, Jahr der Erstzulassung, Anschaffungspreis, Anzahl der Achsen, Zuladung in t ");
                str = console.ReadLine();
                var propertyStrings = str.Split(',');
                if (propertyStrings.Count() == 7)
                {
                    return(Parse(propertyStrings, parameter));
                }
            }
            return(null);
        }
 public Vehicle Parse(IConsoleInputOutput console, string parameter, out int parkingPlaceId)
 {
     parkingPlaceId = 0;
     string[] propertyStrings = null;
     if (parameter == "c")
     {
         console.WriteLine("Geben Sie den PKW in folgendem Format ein:");
         console.WriteInfo("Hersteller, Modell, Kennzeichen, Jahr der Erstzulassung, Anschaffungspreis, Hubraum, Leistung, Schadstoffklasse [0-schadstoffarm, 1-normal, 2-Diesel], Parkplatznummer ");
         propertyStrings = this.preParse(console, 923, out parkingPlaceId);
     }
     else if (parameter == "m")
     {
         console.WriteLine("Geben Sie das Motorrad in folgendem Format ein:");
         console.WriteInfo("Hersteller, Modell, Kennzeichen, Jahr der Erstzulassung, Anschaffungspreis, Hubraum, Parkplatznummer");
         propertyStrings = this.preParse(console, 7, out parkingPlaceId);
     }
     else if (parameter == "t")
     {
         console.WriteLine("Geben Sie den LKW in folgendem Format ein:");
         console.WriteInfo("Hersteller, Modell, Kennzeichen, Jahr der Erstzulassung, Anschaffungspreis, Anzahl der Achsen, Zuladung in t, Parkplatznummer ");
         propertyStrings = this.preParse(console, 8, out parkingPlaceId);
     }
     return(this.Parse(propertyStrings, parameter));
 }
Exemple #8
0
 public Vehicle Parse(IConsoleInputOutput str, string parameter, out int parkingPlaceId)
 {
     throw new NotImplementedException();
 }
Exemple #9
0
 public Vehicle Parse(IConsoleInputOutput str, string parameter)
 {
     throw new NotImplementedException();
 }
Exemple #10
0
 public Garage Parse(IConsoleInputOutput console, out uint count)
 {
     count = 0;
     ParseAction?.Invoke(console, out count);
     return(ParseReturn);
 }