public static void Main()
cap = int.Parse(Console.ReadLine());
amo = int.Parse(Console.ReadLine());
while (cap < 0 || amo < 0 || amo > cap);
Bucket bu = new Bucket(cap, amo);
private double currentAmount;
public Bucket(int capacity, double currentAmount)
this.capacity = capacity;
this.currentAmount = currentAmount;
public void EmptyAmount(double amountToEmpty)
currentAmount = Math.Max(currentAmount - amountToEmpty, 0);
return (currentAmount <= 0);
public void Fill(double amountToFill)
if (amountToFill > capacity)
Console.WriteLine(amountToFill - capacity + currentAmount + "WATER SPILLED OUT");
currentAmount = Math.Min(currentAmount + amountToFill, capacity);
currentAmount = capacity;
public double GetCurrentAmount()
public void PourInto(Bucket bucketInto)
double bucketResCapacity = bucketInto.GetCapacity() - bucketInto.GetCurrentAmount();
double amountToFill = Math.Min(currentAmount, bucketResCapacity);
bucketInto.Fill(amountToFill);
currentAmount -= amountToFill;
if(currentAmount==capacity)
override public string ToString()
return "The capacity: " + capacity + "\nThe current amount of water: " + currentAmount;