欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

项目总结(一)

程序员文章站 2022-03-05 08:09:23
...

1.List<int> to  string[] 

List<int> recommendSubjectCodes = GetRecommendSubjectListByResult(result, provinceCode);
string[] ids = Array.ConvertAll(recommendSubjectCodes.ToArray(), new Converter<int, string>(a => Convert.ToString(a)));

2.平均分:

raiInfo.avgScore = Math.Round((raiInfo.interest + raiInfo.ability) / 2, 2);

3.委托:

List<Func<ResultAnalyseInfo, bool>> quadrantCalcFuncList = new List<Func<ResultAnalyseInfo, bool>>
            {
                (p)=> p.interest >= 3 && p.ability >= 3,    //第一象限
                (p)=> p.interest >= 3 && p.ability < 3,    //第二象限
                (p)=> p.interest < 3  && p.ability >=3  //第四象限
            };
public List<string> CalcQuadrantList(List<ResultAnalyseInfo> subjectList, string firstSubject, int needKemuCount, List<Func<ResultAnalyseInfo, bool>> funcList)
        {
            var resultSubjects = new List<string>();
            foreach (var func in funcList)
            {
                var quadrantSubjects = new List<string>();
                List<ResultAnalyseInfo> quadrantList = subjectList.Where(item => func(item)).ToList();

                if (quadrantList.Any() && quadrantList.Count <= needKemuCount)
                    quadrantSubjects.AddRange(quadrantList.Select(p => p.name).ToList());

                if (quadrantList.Count > needKemuCount)
                {
                    //开始相同得分优先级算法
                    quadrantSubjects.AddRange(SortOverSubjects(quadrantList, firstSubject, needKemuCount));
                }
                needKemuCount = needKemuCount - quadrantSubjects.Count;

                resultSubjects.AddRange(quadrantSubjects);

                if (needKemuCount <= 0) break;
            }

            return resultSubjects;
        }

 

相关标签: 项目经验总结