Refactor code
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
public class Stat
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public decimal Value { get; set; }
|
||||
public decimal Price { get; set; }
|
||||
public decimal Quantity { get; set; }
|
||||
|
||||
public Stat(string name, decimal startValue)
|
||||
{
|
||||
Name = name;
|
||||
Value = startValue;
|
||||
}
|
||||
|
||||
public Stat(string name, decimal price, decimal quantity)
|
||||
{
|
||||
Name = name;
|
||||
Price = price;
|
||||
Quantity = quantity;
|
||||
}
|
||||
|
||||
public void increase(decimal byAmount)
|
||||
{
|
||||
Value += byAmount;
|
||||
}
|
||||
|
||||
public bool deduct(decimal amount)
|
||||
{
|
||||
if (Value >= amount)
|
||||
{
|
||||
Value -= amount;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void forceDeduct(decimal amount)
|
||||
{
|
||||
Value -= amount;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user