私は製品の小さなポーリングを書いています。この製品は、各ユーザーがそのプロパティ(清潔さと清潔さ、サービス、場所、スタッフなど)ごとに5つのスコア(後で増加する可能性があります)でポーリングできます。各スコアには形容詞があります(1:最悪、2:悪い、3:良い、4:非常に良い、5:異常)。
たとえば、ユーザーは次のような製品の1つにポーリングできます。CleanLinessandNeatness:4(非常に良い)サービス:3(良い)場所:1(最悪)スタッフ:5(異常)
このスコアの平均は製品のスコアになり、10進数になります。この例では、3.25です。
今、私はこの結果(3.25)によって製品に形容詞を与えたいと思います、それがポイントが3.25のように半分より下にある場合、それは下に丸められ(この3の場合)、ポイントが等しく、3.7のように半分より上にある場合、切り上げます(4)
これに最適なアルゴリズムは何ですか?
私のクラスのデザインは以下のようなものです。
public class Product
{}
public Class Poll
{
public int Id {get; set;}
public int ProductId {get; set;}
public Product Product {get; set;}
public decimal Score {get; set}
public string Adjective {get; set;}
public ICollection<PollAttributes> Attributes {get; set;}
}
public class Attribute // for the attribute like Services
{
public int Id {get; set;}
public string Title {get; set;}
public ICollection<PollAttributes> Attributes {get; set;}
}
public Class PollAttributes
{
public decimal score {get; set;}
public int AttributeId {get; set;}
public Attribute{get; set;}
public int PollId {get; set;}
public Poll Poll {get; set;}
}
Convert.ToInt32(Math.Round(score))を使用して、値を整数値に丸め、Dictionary()に属性値を保持させると、次のようになります。
poll.attribute = lookup[Convert.toInt32(Math.Round(score))];
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加