-
Notifications
You must be signed in to change notification settings - Fork 0
/
Item.cs
53 lines (45 loc) · 1.2 KB
/
Item.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
42
43
44
45
46
47
48
49
50
51
52
53
namespace csharp
{
public class Item
{
protected const int MinQuality = 0;
private const int MaxQuality = 50;
internal Item()
{
}
public static Item NormalItem(string name, int sellin, int quality)
{
return new Item {Name = name, SellIn = sellin, Quality = quality};
}
public static AgedBrie AgedBrie(string name, int sellin, int quality)
{
return new AgedBrie { Name = name, SellIn = sellin, Quality = quality };
}
public string Name { get; set; }
public int SellIn { get; set; }
public int Quality { get; set; }
public override string ToString()
{
return this.Name + ", " + this.SellIn + ", " + this.Quality;
}
public virtual void Update()
{
if (SellIn <= 0)
{
Quality -= 2;
}
else
{
Quality--;
}
SellIn--;
}
protected void EnsureMaxQuality()
{
if (Quality > Item.MaxQuality)
{
Quality = Item.MaxQuality;
}
}
}
}