/// <summary> /// Gets the command. /// </summary> /// <param name="str">Inputed array of strings.</param> /// <returns>The command.</returns> private Commands GetCommand(string[] str) { switch (str.Length) { case 1 when(str[0].Equals("Execute")): return(Commands.Execute); case 1 when(str[0].Equals("Exit")): return(Commands.Exit); case 2 when(str[0].Equals("Count_types")) && ((str[1].Equals("Car")) || (str[1].Equals("Truck"))): _currentStorage = str[1].Equals("Car") ? _carsStorage : _truckStogare; return(Commands.Count_types); case 2 when(str[0].Equals("Count_all")) && ((str[1].Equals("Car")) || (str[1].Equals("Truck"))): _currentStorage = str[1].Equals("Car") ? _carsStorage : _truckStogare; return(Commands.Count_all); case 2 when(str[0].Equals("Average_price")) && ((str[1].Equals("Car")) || (str[1].Equals("Truck"))): _currentStorage = str[1].Equals("Car") ? _carsStorage : _truckStogare; return(Commands.Average_price); case 3 when(str[0].Equals("Average_price")): _currentStorage = str[1].Equals("Car") ? _carsStorage : _truckStogare; return(Commands.Average_priceType); default: return(Commands.UnknownCommand); } }
/// <summary> /// Constructor. /// </summary> /// <param name="carsStorage">Cars storage.</param> /// <param name="truckStogare">Trucks storage.</param> public CommandHandler(VehiclesStorage carsStorage, VehiclesStorage truckStogare) { _carsStorage = carsStorage; _truckStogare = truckStogare; }