-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rating.cs
41 lines (36 loc) · 987 Bytes
/
Rating.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
namespace ShishaBacon
{
public class Rating: IComparable<Rating>
{
public const int Scaling = 10;
public const int MaxRating = 10;
public const int MinRating = 0;
public Rater rater;
private int value = -1;
public int Value
{
get { return value; }
set
{
if (value >= MinRating * Scaling && value <= MaxRating * Scaling)
{
this.value = value;
}
}
}
public Rating(Rater rater, int rating)
{
this.rater = rater;
this.value = rating;
}
public override string ToString()
{
return rater.Name + ": " + ((double)value / Scaling);
}
public int CompareTo(Rating other)
{
return rater.Name.CompareTo(other.rater.Name);
}
}
}