public static IPostScoreCalculator CreatePostScoreCalculator(BestPostFinder.eScoreCalculationStyle i_CalculationStyle) { if (i_CalculationStyle.Equals(BestPostFinder.eScoreCalculationStyle.Comments)) { return(new PostScoreCalculatorByComments()); } else if (i_CalculationStyle.Equals(BestPostFinder.eScoreCalculationStyle.Formula)) { return(new PostScoreCalculatorByFormula()); } else { return(new PostScoreCalculatorByLikes()); } }
private int getPostScore(Post i_PostToCheck) { IPostScoreCalculator postCalculator; BestPostFinder.eScoreCalculationStyle scoreCalculationStyle = getScoreCalcStyle(); postCalculator = PostScoreCalculatorCreator.CreatePostScoreCalculator(scoreCalculationStyle); int likes = i_PostToCheck.LikedBy.Count; int comments = i_PostToCheck.Comments.Count; int likeValue = 1; int commentValue = 1; if (numericUpDownLikesValue.Enabled) { likeValue = (int)numericUpDownLikesValue.Value; commentValue = (int)numericUpDownCommentsValue.Value; } return(postCalculator.GetScore(likes * likeValue, comments * commentValue)); }