GildedRose-Refactoring-Kata/csharp/StrategyPatternExample/Strategies/TwiceFastDegradeQualityStrategy.cs
israel f6db7aa935 · Insert comments.
· DoNothingStrategy created.
2017-10-20 13:14:29 +01:00

37 lines
803 B
C#

using System;
namespace csharp.StrategyPatternExample.Strategy
{
/// <summary>
/// Implements the strategy; Items degrade in Quality twice as fast as normal items.
/// </summary>
internal class TwiceFastDegradeQualityStrategy : ICategoryStrategy
{
#region Methods
public void Update(Item item)
{
int degrade = 2;
item.SellIn--;
if (item.SellIn < 0)
{
degrade = 4;
}
if (item.Quality > Global.MINIMUM_QUALITY)
{
item.Quality -= degrade;
}
if (item.Quality < Global.MINIMUM_QUALITY)
{
item.Quality = Global.MINIMUM_QUALITY;
}
}
#endregion
}
}