public Blood Store(Blood value) { if (value < new Blood()) { return(-Consume(-value)); } if (currentValue + value > capacity) { value -= capacity - currentValue; currentValue = capacity; return(value); } currentValue += value; return(new Blood()); }
public Blood Consume(Blood value) { if (value < new Blood()) { return(-Store(-value)); } if (currentValue - value < new Blood()) { value -= currentValue; currentValue = new Blood(); return(value); } currentValue -= value; return(new Blood()); }
public static Blood Max(Blood a, Blood b) => a > b ? a : b;
public BloodStorage(Blood capacity) { this.capacity = capacity; }
public static Blood Min(Blood a, Blood b) => a < b ? a : b;