Exemplo n.º 1
0
        private static List <NumberCollectionLine> GenerateAddition(AdditionConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            var a = new List <NumberCollectionLine>();

            //需要重新实现该算法
            for (var i = config.MinValue; i <= config.MaxValue; i++)
            {
                var builder = new AdditionBuilder(i)
                              .SetItemUpperLimit(config.ItemUpperLimit)
                              .SetAddendCount(config.ItemCount);

                a.AddRange(builder.Build());
            }

            a.Sort();
            a = a.Take(config.Count).ToList();

            //查看是否存在相同的,如果有则加数顺序交换一下

            return(a);
        }
Exemplo n.º 2
0
 public HomeController(IOptions <AdditionConfig> additionOptions,
                       IOptions <SubtractionConfig> subtractionOptions,
                       IOptions <SukoduConfig> sukoduOptions)
 {
     _additionConfig    = additionOptions.Value;
     _subtractionConfig = subtractionOptions.Value;
     _sukoduConfig      = sukoduOptions.Value;
 }
Exemplo n.º 3
0
        public MathContainer SetAddition(AdditionConfig config)
        {
            if (config == null)
            {
                config = new AdditionConfig();
                config.SetDefault();
            }

            config.Repaire();

            for (var i = 0; i < config.Times; i++)
            {
                Additions.Add(GenerateAddition(config));
            }

            return(this);
        }