Finished CoffeeVendingMachine.cs Cancel class

This commit is contained in:
MarcUs7i 2024-11-18 08:58:06 +01:00
parent 66cc7055fa
commit 92421e0be9

View file

@ -45,8 +45,27 @@ public class CoffeeVendingMachine
public CoinDepot[] Cancel()
{
//TODO
return [];
int count = 0;
foreach (var inputCoin in _currentInputCoins)
{
if (inputCoin.Count > 0)
{
count++;
}
}
CoinDepot[] newInputCoins = new CoinDepot[count];
int j = 0;
for (int i = 0; i < _currentInputCoins.Length; i++)
{
if (_currentInputCoins[i].Count > 0)
{
newInputCoins[j] = new CoinDepot(_currentInputCoins[i]);
j++;
}
}
return newInputCoins;
}
/// <summary>