ex-oop-05-coffe-vending-mac.../CoffeeVendingMachines/CoinDepot.cs
MarcUs7i bc7f2da775 Initialized the CoffeeVendingMachine.cs class
Rewrote from get/set like in the README
2024-11-16 19:48:16 +01:00

45 lines
720 B
C#

namespace CoffeeVendingMachines;
public class CoinDepot
{
public readonly CoinType Coin;
public int Count { get; private set; }
public CoinDepot(CoinType coin, int count = 0)
{
Coin = coin;
Count = count;
}
public CoinDepot(CoinDepot coinDepot)
{
Coin = coinDepot.Coin;
Count = coinDepot.Count;
}
public void Add()
{
Count++;
}
public void Clear()
{
Count = 0;
}
public override string ToString()
{
return $"{Coin}: {Count}";
}
public bool Withdraw()
{
if (Count > 0)
{
Count--;
return true;
}
return false;
}
}