public Harvester CreateHarvester(List <string> arguments) { var type = arguments[0]; var id = arguments[1]; var oreOutput = double.Parse(arguments[2]); var energyRequirement = double.Parse(arguments[3]); switch (type) { case "Sonic": var sonicFactor = int.Parse(arguments[4]); var sonicHarvester = new SonicHarvester(id, oreOutput, energyRequirement, sonicFactor); return(sonicHarvester); //this.harvesters.Add(id, sonicHarvester); //return $"Successfully registered {type} Harvester - {id}"; case "Hammer": var hammerHarvester = new HammerHarvester(id, oreOutput, energyRequirement); return(hammerHarvester); //this.harvesters.Add(id, hammerHarvester); //return $"Successfully registered {type} Harvester - {id}"; default: throw new InvalidOperationException(); } }
public string RegisterHarvester(List <string> arguments) { //• RegisterHarvester {type} {id} {oreOutput} {energyRequirement} //RegisterHarvester Sonic { id} { oreOutput} { energyRequirement} { sonicFactor} var type = arguments[0]; var id = arguments[1]; var oreOutput = double.Parse(arguments[2]); var energyRequirement = double.Parse(arguments[3]); try { switch (type) { case "Sonic": var sonicFactor = int.Parse(arguments[4]); var sonicHarvester = new SonicHarvester(id, oreOutput, energyRequirement, sonicFactor); this.harvesters.Add(id, sonicHarvester); return($"Successfully registered {type} Harvester - {id}"); case "Hammer": var hammerHarvester = new HammerHarvester(id, oreOutput, energyRequirement); this.harvesters.Add(id, hammerHarvester); return($"Successfully registered {type} Harvester - {id}"); default: return(""); } } catch (ArgumentException argEx) { return($"Harvester is not registered, because of it's {argEx.Message}"); } }
public string RegisterHarvester(List <string> arguments) { var type = arguments[0]; var id = arguments[1]; var oreOutput = double.Parse(arguments[2]); var energyRequirement = double.Parse(arguments[3]); var sonicFactor = 0; if (arguments.Count == 5) { sonicFactor = int.Parse(arguments[4]); } try { if (type == "Sonic") { var sonicHarvester = new SonicHarvester(id, oreOutput, energyRequirement, sonicFactor); harvesters.Add(sonicHarvester); } else { var hammerHarvester = new HammerHarvester(id, oreOutput, energyRequirement); harvesters.Add(hammerHarvester); } } catch (Exception e) { return(e.Message); } return($"Successfully registered {type} Harvester - {id}"); }
public string RegisterHarvester(List <string> arguments) { string type = arguments[0]; string id = arguments[1]; double oreOutput = double.Parse(arguments[2]); double energyReq = double.Parse(arguments[3]); if (type == "Sonic") { int sonicFactor = int.Parse(arguments[4]); try { var sonicHarvester = new SonicHarvester(id, oreOutput, energyReq, sonicFactor); this.sonicHarvesters.Add(sonicHarvester); } catch (Exception e) { return($"Harvester is not registered, because of it's {e.Message}"); } return($"Successfully registered Sonic Harvester - {id}"); } else { try { var hammerHarvester = new HammerHarvester(id, oreOutput, energyReq); this.hammerHarvesters.Add(hammerHarvester); } catch (Exception e) { return$ "Harvester is not registered, because of it's {e.Message}"; } return($"Successfully registered Hammer Harvester - {id}"); } }
public string RegisterHarvester(List <string> arguments) { try { var type = arguments[0]; var id = arguments[1]; var oreOutput = double.Parse(arguments[2]); var energyRequirement = double.Parse(arguments[3]); if (type == "Sonic") { var sonicFactor = int.Parse(arguments[4]); harvesterCollection[id] = new SonicHarvester(id, oreOutput, energyRequirement, sonicFactor); } else { harvesterCollection[id] = new HammerHarvester(id, oreOutput, energyRequirement); } return($"Successfully registered {type} Harvester - {id}"); } catch (ArgumentException ae) { return(ae.Message); } }
public string RegisterHarvester(List <string> arguments) { try { var type = arguments[0]; var id = arguments[1]; var oreOutput = double.Parse(arguments[2]); var energyRequirement = double.Parse(arguments[3]); Harvester harvester = null; if (type.Equals("Hammer")) { harvester = new HammerHarvester(id, oreOutput, energyRequirement); } else if (type.Equals("Sonic")) { var sonicFactor = int.Parse(arguments[4]); harvester = new SonicHarvester(id, oreOutput, energyRequirement, sonicFactor); } harvesters.Add(harvester); return($"Successfully registered {type} Harvester - {id}"); } catch (ArgumentException ex) { return(ex.Message); } }
public Harvester CreateHarvester(List <string> arr) { Harvester harvester; string type = arr[0]; string id = arr[1]; double oreOutput = double.Parse(arr[2]); double energyRequirement = double.Parse(arr[3]); switch (type) { case "Hammer": harvester = new HammerHarvester(id, oreOutput, energyRequirement); break; case "Sonic": int sonicFactor = int.Parse(arr[4]); harvester = new SonicHarvester(id, oreOutput, energyRequirement, sonicFactor); break; default: throw new ArgumentException($"Harvester is not registered, because of it's {type}"); } return(harvester); }
public string RegisterHarvester(List <string> arguments) { try { if (arguments[0] == "Sonic") { SonicHarvester sH = new SonicHarvester(arguments[1], double.Parse(arguments[2]), double.Parse(arguments[3]), int.Parse(arguments[4])); harvesters.Add(sH); } else if (arguments[0] == "Hammer") { HammerHarvester hH = new HammerHarvester(arguments[1], double.Parse(arguments[2]), double.Parse(arguments[3])); harvesters.Add(hH); } } catch (ArgumentException ex) { return(ex.Message); } return($"Successfully registered {arguments[0]} Harvester - {arguments[1]}"); }
public Harvester CreateHarvester(List <string> arguments) { string type = arguments[0]; string id = arguments[1]; double oreOutput = double.Parse(arguments[2]); double energyRequirement = double.Parse(arguments[3]); Harvester harvester = null; switch (type) { case "Hammer": harvester = new HammerHarvester(id, oreOutput, energyRequirement); break; case "Sonic": int sonicFactor = int.Parse(arguments[4]); harvester = new SonicHarvester(id, oreOutput, energyRequirement, sonicFactor); break; //default: // break; } return(harvester); }
public Harvester CreateHarvester(List <string> arguments) { var type = arguments[0]; var id = arguments[1]; var oreOutput = double.Parse(arguments[2]); if (oreOutput < 0) { throw new ArgumentException($"Harvester is not registered, because of it's OreOutput"); } var energyRequirement = double.Parse(arguments[3]); if (energyRequirement < 0 || energyRequirement >= 20000) { throw new ArgumentException($"Harvester is not registered, because of it's EnergyRequirement"); } Harvester harvester = null; switch (type) { case "Sonic": var sonicFactor = int.Parse(arguments[4]); harvester = new SonicHarvester(id, oreOutput, energyRequirement, sonicFactor); break; case "Hammer": harvester = new HammerHarvester(id, oreOutput, energyRequirement); break; } return(harvester); }
public string RegisterHarvester(List <string> arguments) { try { var type = arguments[1]; var id = arguments[2]; var oreOutput = double.Parse(arguments[3]); var energyRequirement = double.Parse(arguments[4]); int sonicFactor = 0; Harvester currHarvester = null; switch (type) { case "Hammer": currHarvester = new HammerHarvester(id, oreOutput, energyRequirement); break; case "Sonic": sonicFactor = int.Parse(arguments[5]); currHarvester = new SonicHarvester(id, oreOutput, energyRequirement, sonicFactor); break; } harvesters.Add(currHarvester); return($"Successfully registered {type} Harvester - {id}"); } catch (Exception e) { return(e.Message); } }
public Harvester MakeHarvester(List <string> arguments) { var type = arguments[0]; var id = arguments[1]; var oreOutput = double.Parse(arguments[2]); var energyRequirement = double.Parse(arguments[3]); Harvester currentHarvester = null; switch (type) { case "Sonic": var sonicFactor = int.Parse(arguments[4]); currentHarvester = new SonicHarvester(id, oreOutput, energyRequirement, sonicFactor); break; case "Hammer": currentHarvester = new HammerHarvester(id, oreOutput, energyRequirement); break; default: throw new NotSupportedException(); } return(currentHarvester); }
public string RegisterHarvester(List <string> arguments) { try { Harvester harvester = null; switch (arguments[1]) { case "Sonic": { harvester = new SonicHarvester(arguments[2], double.Parse(arguments[3]), double.Parse(arguments[4]), int.Parse(arguments[5])); break; } case "Hammer": { harvester = new HammerHarvester(arguments[2], double.Parse(arguments[3]), double.Parse(arguments[4])); break; } } this.SystemState.Harvesters.Add(harvester); return($"Successfully registered {harvester.Type} Harvester - {harvester.Id}\n"); } catch (Exception ex) { return(ex.Message + Environment.NewLine); } }
public string RegisterHarvester(List <string> arguments) { string msg = String.Empty; try { string type = arguments[0]; string id = arguments[1]; double oreOutput = double.Parse(arguments[2]); double energyRequirement = double.Parse(arguments[3]); Harvester harvester; if (type == "Sonic") { int sonicFactor = int.Parse(arguments[4]); harvester = new SonicHarvester(id, oreOutput, energyRequirement, sonicFactor); harvesters.Add(id, harvester); } else if (type == "Hammer") { harvester = new HammerHarvester(id, oreOutput, energyRequirement); harvesters.Add(id, harvester); } msg = $"Successfully registered {type} Harvester - {id}"; } catch (ArgumentException ex) { msg = ex.Message; } return(msg); }
public SonicHarvester GenerateSonicHarvester(string id, double oreOutput, double energyRequirement, int sonicFactor) { var sonicHarvester = new SonicHarvester(id, oreOutput, energyRequirement, sonicFactor); return(sonicHarvester); }
public string RegisterHarvester(List <string> arguments) { var toReturn = string.Empty; try { if (arguments[0] == "Sonic") { Harvester harvester = new SonicHarvester(arguments[1], double.Parse(arguments[2]), double.Parse(arguments[3]), int.Parse(arguments[4])); Harvesters.Add(harvester); toReturn = $"Successfully registered Sonic Harvester - {arguments[1]}"; } else { Harvester harvester = new HammerHarvester(arguments[1], double.Parse(arguments[2]), double.Parse(arguments[3])); Harvesters.Add(harvester); toReturn = $"Successfully registered Hammer Harvester - {arguments[1]}"; } } catch (ArgumentException e) { toReturn = e.Message; } return(toReturn); }
public static Harvester CreateHarvester(List <string> arguments) { Harvester newHarvester = null; string type = arguments[0]; string id = arguments[1]; double oreOutput = double.Parse(arguments[2]); double energyRequirement = double.Parse(arguments[3]); if (type == "Sonic") { string sonicFactor = arguments[4]; newHarvester = new SonicHarvester(id, oreOutput, energyRequirement, int.Parse(sonicFactor)); } else if (type == "Hammer") { newHarvester = new HammerHarvester(id, oreOutput, energyRequirement); } else { throw new ArgumentException("Invalid entry"); } return(newHarvester); }
public static Harvester Get(string type, List <string> arguments) { Harvester harvester = null; switch (type) { case "Hammer": harvester = new HammerHarvester(arguments[1], double.Parse(arguments[2]), double.Parse(arguments[3])); break; case "Sonic": harvester = new SonicHarvester(arguments[1], double.Parse(arguments[2]), double.Parse(arguments[3]), int.Parse(arguments[4])); break; } return(harvester); }
public Harvester ProduceHarvester(string type, string id, double oreOutput, double energyRequirement, int sonicFactor = 0) { Harvester newHarvester = null; if (type == "Sonic") { newHarvester = new SonicHarvester(id, oreOutput, energyRequirement, sonicFactor); } else if (type == "Hammer") { newHarvester = new HammerHarvester(id, oreOutput, energyRequirement); } return(newHarvester); }
public static Harvester GetHarvester(List <string> harvesterArgs) { var type = harvesterArgs[0]; var id = harvesterArgs[1]; var oreOutput = double.Parse(harvesterArgs[2]); var energyRequirement = double.Parse(harvesterArgs[3]); switch (type) { case "Hammer": Harvester harvester = new HammerHarvester(harvesterArgs[1], oreOutput, energyRequirement); return(harvester); default: Harvester sonic = new SonicHarvester(id, oreOutput, energyRequirement, int.Parse(harvesterArgs[4])); return(sonic); } }
public static Harvester CreateHarvester(List <string> arguments) { string type = arguments[0]; string id = arguments[1]; double oreOutput = double.Parse(arguments[2]); double energyRequirement = double.Parse(arguments[3]); Harvester harvester = null; if (type == "Sonic") { int sonicFactor = int.Parse(arguments[4]); harvester = new SonicHarvester(id, oreOutput, energyRequirement, sonicFactor); } else if (type == "Hammer") { harvester = new HammerHarvester(id, oreOutput, energyRequirement); } return(harvester); }
public static void Main(string[] args) { List <IHarvester> harvesters = new List <IHarvester>(); //List<Harvester> harvesters = new List<Harvester>(); //RegisterHarvester Hammer CDD 100 50 // RegisterHarvester Sonic AS - 51 100 100 10 // RegisterHarvester Sonic { id} //{ oreOutput} //{ energyRequirement} //{ sonicFactor} string input = Console.ReadLine(); while (input != "END") { string[] harvesterInfo = input.Split(); string type = harvesterInfo[1]; string id = harvesterInfo[2]; double oreOutput = double.Parse(harvesterInfo[3]); double energyRequirement = double.Parse(harvesterInfo[4]); if (harvesterInfo.Length == 5) { IHarvester harvester = new HammerHarvester(id, oreOutput, energyRequirement); harvesters.Add(harvester); } else if (harvesterInfo.Length == 6) { int sonicFactor = int.Parse(harvesterInfo[5]); IHarvester harvester = new SonicHarvester (id, oreOutput, energyRequirement, sonicFactor); harvesters.Add(harvester); } input = Console.ReadLine(); } foreach (var harvester in harvesters) { Console.WriteLine(harvester); } }
public Harvester GenerateHarvester(List <string> arguments) { var type = arguments[0]; var id = arguments[1]; var oreOutput = double.Parse(arguments[2]); var energyRequirement = double.Parse(arguments[3]); if (type == "Sonic") { var sonicFactor = int.Parse(arguments[4]); var sonicHarvester = new SonicHarvester(id, oreOutput, energyRequirement, sonicFactor); return(sonicHarvester); } else { var hammerHarvester = new HammerHarvester(id, oreOutput, energyRequirement); return(hammerHarvester); } }
public Harvester GetHarvester(List <string> arguments) { var typeOfHarvester = arguments[0]; var idOfHarvester = arguments[1]; var oreOutput = double.Parse(arguments[2]); var energyRequirement = double.Parse(arguments[3]); switch (typeOfHarvester) { case "Sonic": var sonicFactor = int.Parse(arguments[4]); Harvester sonicHarvester = new SonicHarvester(idOfHarvester, oreOutput, energyRequirement, sonicFactor); return(sonicHarvester); case "Hammer": Harvester hammeHarvester = new HammerHarvester(idOfHarvester, oreOutput, energyRequirement); return(hammeHarvester); } return(null); }
public static Harvester ProduceHarvester(List <string> harvesterTokens) { Harvester harvester = null; string type = harvesterTokens[0]; string id = harvesterTokens[1]; double oreOutput = double.Parse(harvesterTokens[2]); double energyRequirement = double.Parse(harvesterTokens[3]); switch (type) { case "Sonic": harvester = new SonicHarvester(id, oreOutput, energyRequirement, int.Parse(harvesterTokens[4])); break; case "Hammer": harvester = new HammerHarvester(id, oreOutput, energyRequirement); break; default: break; } return(harvester); }
public Harvester Create(List <string> arguments) { var type = arguments[0]; var id = arguments[1]; var oreOutput = double.Parse(arguments[2]); var energyRequerement = double.Parse(arguments[3]); Harvester harvester = null; if (type == "Sonic") { var sonicFactor = int.Parse(arguments[4]); harvester = new SonicHarvester(id, oreOutput, energyRequerement, sonicFactor); } else if (type == "Hammer") { harvester = new HammerHarvester(id, oreOutput, energyRequerement); } return(harvester); }
public Harvester Get(List <string> data) { var type = data[0]; var id = data[1]; var oreOutput = double.Parse(data[2]); var energyReq = double.Parse(data[3]); Harvester harvesterObj = null; if (type != "Sonic") { harvesterObj = new HammerHarvester(id, oreOutput, energyReq); } else { int sonicFactor = int.Parse(data[4]); harvesterObj = new SonicHarvester(id, oreOutput, energyReq, sonicFactor); } return(harvesterObj); }
//public Harvester CreateSonicHarvester(string id, double oreOutput, double energyRequirement, int sonicFactor) //{ // return new SonicHarvester(id,oreOutput,energyRequirement,sonicFactor); //} //public Harvester CreateHammerHarvester(string id, double oreOutput, double energyRequirement) //{ // return new HammerHarvester(id, oreOutput, energyRequirement); //} //public Harvester Get(int id) //{ // switch (id) // { // case 0: // return new Manager(); // case 1: // case 2: // return new Clerk(); // case 3: // default: // return new Programmer(); // } //} // if (arguments[0] == "Solar") // { // var id = arguments[1]; // var oreOutput = double.Parse(arguments[2], CultureInfo.InvariantCulture); // //var provider = this.providerFactory.CreateSolarProvider(id, oreOutput); // Provider provider = new SolarProvider(id, oreOutput); // this.providers.Add(provider); // return $"Successfully registered Solar Provider - {id}"; // } // else // { // var id = arguments[1]; // var oreOutput = double.Parse(arguments[2], CultureInfo.InvariantCulture); ////var provider = this.providerFactory.CreatePressureProvider(id, oreOutput); // Provider provider = new PressureProvider(id, oreOutput); // this.providers.Add(provider); // return $"Successfully registered Pressure Provider - {id}"; // } public Harvester Create(List <string> args) { if (args[0] == "Solar") { var id = args[1]; var oreOutput = double.Parse(args[2], CultureInfo.InvariantCulture); var energy = double.Parse(args[3], CultureInfo.InvariantCulture); var sonik = int.Parse(args[4]); Harvester provider = new SonicHarvester(id, oreOutput, energy, sonik); return(provider); } else { var id = args[1]; var oreOutput = double.Parse(args[2], CultureInfo.InvariantCulture); var energy = double.Parse(args[3], CultureInfo.InvariantCulture); Harvester provider = new HammerHarvester(id, oreOutput, energy); return(provider); } }
public static Harvester CreateHarvester(List <string> arguments) { string type = arguments[0]; string id = arguments[1]; double oreOutput = double.Parse(arguments[2]); double energyRequirement = double.Parse(arguments[3]); if (type == "Sonic") { int sonicFactor = int.Parse(arguments[4]); Harvester sonicHarvester = new SonicHarvester(id, oreOutput, energyRequirement, sonicFactor); return(sonicHarvester); } if (type == "Hammer") { Harvester hammerHarvester = new HammerHarvester(id, oreOutput, energyRequirement); return(hammerHarvester); } throw new ArgumentException("Harvester is not registered, because of it's Type"); }
public string RegisterHarvester(List <string> arguments) { var type = arguments[0]; var id = arguments[1]; var oreOutput = double.Parse(arguments[2]); var energyRequirement = double.Parse(arguments[3]); if (type == "Hammer") { Harvester harvester = new HammerHarvester(id, oreOutput, energyRequirement); this.harvesters.Add(id, harvester); } if (type == "Sonic") { var sonicFactor = int.Parse(arguments[4]); Harvester harvester = new SonicHarvester(id, oreOutput, energyRequirement, sonicFactor); this.harvesters.Add(id, harvester); } return($"Successfully registered {type} Harvester - {id}"); }