コード例 #1
0
    public string RegisterHarvester(List <string> arguments)
    {
        // RegisterHarvester {type} {id} {oreOutput} {energyRequirement}
        // RegisterHarvester Sonic {id} {oreOutput} {energyRequirement} {sonicFactor}

        try
        {
            var harvester = HarvesterFactory.CreateHarvester(arguments);
            this.harvesters[harvester.Id] = harvester;

            return($"Successfully registered {harvester.GetTypeName()} - {harvester.Id}");
        }
        catch (Exception e)
        {
            return(e.Message);
        }
    }
コード例 #2
0
    public string RegisterHarvester(List <string> arguments)
    {
        //•	RegisterHarvester {type} {id} {oreOutput} {energyRequirement}
        //RegisterHarvester Sonic { id} { oreOutput} { energyRequirement} { sonicFactor}


        try
        {
            var harvester = harvesterFactory.CreateHarvester(arguments);
            harvesters.Add(harvester.Id, harvester);
            return($"Successfully registered {harvester.Type} Harvester - {harvester.Id}");
        }
        catch (ArgumentException argEx)
        {
            return($"Harvester is not registered, because of it's {argEx.Message}");
        }
    }
コード例 #3
0
    public string RegisterHarvester(List <string> arguments)
    {
        var type = arguments[0];
        var id   = arguments[1];

        try
        {
            var harvester = HarvesterFactory.CreateHarvester(arguments);

            harvesters.Add(harvester);
        }
        catch (ArgumentException ex)
        {
            return(ex.Message);
        }
        return($"Successfully registered {type} Harvester - {id}");
    }
コード例 #4
0
    public string RegisterHarvester(List <string> arguments)
    {
        //•	RegisterHarvester Sonic {id} {oreOutput} {energyRequirement} {sonicFactor}
        try
        {
            var id        = arguments[1];
            var harvester = HarvesterFactory.CreateHarvester(arguments);
            harvesters.Add(id, harvester);
            miningUnits.Add(id, harvester);

            return($"Successfully registered {arguments[0]} Harvester - {id}");
        }
        catch (ArgumentException ex)
        {
            return($"{ex.Message}");
        }
    }
コード例 #5
0
    public string RegisterHarvester(List <string> arguments)
    {
        var typeOfHarvester = arguments[0];
        var id = arguments[1];

        try
        {
            var newHarvester = HarvesterFactory.CreateHarvester(arguments);
            this.harvesters.Add(newHarvester);

            return($"Successfully registered {typeOfHarvester} Harvester - {newHarvester.Id}");
        }
        catch (Exception ex)
        {
            return(ex.Message);
        }
    }
コード例 #6
0
    public string RegisterHarvester(List <string> arguments)
    {
        try
        {
            Harvester harvester = HarvesterFactory.CreateHarvester(arguments);

            this.Harvesters[harvester.Id] = harvester;

            string fullType = harvester.GetType().Name;
            string type     = fullType.Substring(0, fullType.LastIndexOf('H'));

            return($"Successfully registered {type} Harvester - {harvester.Id}");
        }
        catch (ArgumentException argumentException)
        {
            return(argumentException.Message);
        }
    }
コード例 #7
0
    public string RegisterHarvester(List <string> arguments)
    {
        var sb = new StringBuilder();

        try
        {
            var    harvester = harvesterFactory.CreateHarvester(arguments);
            string type      = arguments[0];
            this.harvesters.Add(harvester);
            sb.AppendLine($"Successfully registered {type} Harvester - {harvester.Id}");
        }
        catch (Exception ex)
        {
            sb.AppendLine($"Harvester is not registered, because of it's {ex.Message}");
        }

        return(sb.ToString().Trim());
    }
コード例 #8
0
    public string RegisterHarvester(List <string> arguments)
    {
        string type = arguments[0];
        string id   = arguments[1];

        string msg = string.Empty;

        try
        {
            harvesters.Add(id, HarvesterFactory.CreateHarvester(arguments));
            msg = $"Successfully registered {type} Harvester - {id}";
        }
        catch (ArgumentException argEx)
        {
            msg = argEx.Message;
        }
        return(msg);
    }
コード例 #9
0
    public string RegisterHarvester(List <string> arguments)
    {
        string msg = string.Empty;

        try
        {
            var       harvesterType = arguments[0];
            Harvester harvester     = HarvesterFactory.CreateHarvester(arguments);
            this.harvesters[harvester.Id] = harvester;

            msg = $"Successfully registered {harvesterType} Harvester - {harvester.Id}";
        }
        catch (ArgumentException ex)
        {
            msg = ex.Message;
        }

        return(msg);
    }
コード例 #10
0
    public string RegisterHarvester(List <string> arguments)
    {
        string message = "";

        try
        {
            var type    = arguments[0];
            var harvest = HarvesterFactory.CreateHarvester(arguments);
            harvesters[harvest.Id] = harvest;

            message = $"Successfully registered {type} Harvester - {harvest.Id}";
        }
        catch (ArgumentException e)
        {
            message = e.Message;
        }

        return(message);
    }
コード例 #11
0
    public string RegisterHarvester(List <string> arguments)
    {
        var message = string.Empty;

        if (arguments[0].Equals("Hammer"))
        {
            try
            {
                var hammerHarvester = HarvesterFactory.CreateHarvester(arguments);
                harvesters.Add(hammerHarvester);

                message =
                    $"Successfully registered Hammer Harvester - {hammerHarvester.Id}";
            }
            catch (Exception exception)
            {
                message = exception.Message;
            }
        }

        else
        {
            try
            {
                var sonicHarvester = HarvesterFactory.CreateHarvester(arguments);
                harvesters.Add(sonicHarvester);

                message =
                    $"Successfully registered Sonic Harvester - {sonicHarvester.Id}";
            }
            catch (Exception exception)
            {
                message = exception.Message;
            }
        }

        return(message);
    }
コード例 #12
0
    public string RegisterHarvester(List <string> arguments)
    {
        var    type              = arguments[0];
        string id                = arguments[1];
        double oreOutput         = double.Parse(arguments[2]);
        double energyRequirement = double.Parse(arguments[3]);
        int    sonicFactor       = 0;

        if (type == "Sonic")
        {
            sonicFactor = int.Parse(arguments[4]);
        }
        try
        {
            var harvester = HarvesterFactory.CreateHarvester(type, id, oreOutput, energyRequirement, sonicFactor);
            harvesters.Add(id, harvester);
        }
        catch (Exception ex)
        {
            return(ex.Message);
        }

        return($"Successfully registered {type} Harvester - {id}");
    }