I'm writing a small polling for products,which product could be polled by each user in 5 scores (which can increase later) for each of its attributes(like: Cleanliness and neatness , Services , location , Staff ). each score has an adjective (1:the worst, 2:bad , 3:good , 4:very good , 5:extraordinary).
for example a user can poll to one of the product like this: CleanLiness and Neatness : 4 (very good) Services : 3 (good) location : 1 (the worst) Staff : 5 (extraordinary)
the average of this scores would be the score of product, and it will be decimal, for this example , it is 3.25 .
now i want to give a adjective to the product by this result(3.25), if it's point is under of the half like 3.25, it rounds to down( for this 3) and if it's point is equal and above the half like 3.7, it rounds to up( 4)
I'm wonder what is the best algorithm or pattern for this ?
my classs' design is like below:
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;}
}
Aucun commentaire:
Enregistrer un commentaire