Finished CoffeeVendingMachine.cs Cancel class
This commit is contained in:
parent
66cc7055fa
commit
92421e0be9
1 changed files with 21 additions and 2 deletions
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue