public string RegisterProvider(List <string> arguments) { Provider provider; var type = arguments[0]; var id = arguments[1]; var energyOutput = double.Parse(arguments[2]); if (CheckIdUniqueness("harvester", id)) { if (type == "Pressure") { try { provider = ProviderFactory.CreatePressure(id, energyOutput); } catch (Exception e) { return(e.Message); } } else { try { provider = ProviderFactory.CreateSolar(id, energyOutput); } catch (Exception e) { return(e.Message); } } Providers.Add(provider); return($"Successfully registered {type} Provider - {id}"); } return($"Provider is not registered, because of it's id"); }