Files
Bucket/Buckets.Logic/Container.cs
KäseToatz a33cf50a4c Part 1 & 2
2024-09-25 22:24:42 +02:00

32 lines
842 B
C#

namespace Buckets.Logic
{
public abstract class Container
{
private int content;
public int Capacity { get; }
public int Content {get => content; set { ArgumentOutOfRangeException.ThrowIfNegative(value, nameof(Content)); ArgumentOutOfRangeException.ThrowIfGreaterThan(value, Capacity, nameof(Content)); content = value; } }
public Container(int capacity, int content)
{
ArgumentOutOfRangeException.ThrowIfNegative(capacity, nameof(Capacity));
Capacity = capacity;
Content = content;
}
public void Fill(int amount)
{
Content += amount;
}
public void Empty(int amount)
{
Content -= amount;
}
public void Empty()
{
Content = 0;
}
}
}