/// <summary>
        /// calculates the ammount of money in BanknoteContainer
        /// </summary>
        /// <param name="banknotes">BanknoteContainer to take data from</param>
        /// <returns>the ammount of money from the banknotes</returns>
        public int CalculateMoney(BanknoteContainer banknotes)
        {
            int ammount = 0;

            for (int i = 0; i < banknotes.Count; i++)
            {
                BanknoteCount banknote = banknotes.GetBanknote(i) as BanknoteCount;
                ammount += banknote.Count * banknote.Wealth;
            }

            return(ammount);
        }
        /// <summary>
        /// creates information string from a successfull withdraw operation:
        /// client's bank account number, banknotes the client just received and the ammount of money client has left
        /// </summary>
        /// <param name="client">Client who performed withdraw operation</param>
        /// <param name="banknotes">banknotes the client received from the ATM</param>
        /// <returns>formatted withdrawing operation text</returns>
        private string FormSuccessfullWithdrawingOperationString(Client client, BanknoteContainer banknotes)
        {
            string operation = string.Format("{0} {1}",
                                             client.BankAccountNumber, client.CurrentAmmount + CalculateMoney(banknotes), client.AmmountToWithdraw);

            for (int i = 0; i < banknotes.Count; i++)
            {
                BanknoteCount banknote = banknotes.GetBanknote(i) as BanknoteCount;
                operation = string.Format("{0}-{1}*{2}", operation, banknote.Wealth, banknote.Count);
            }

            operation = string.Format("{0} = {1}", operation, client.CurrentAmmount);

            return(operation);
        }
        /// <summary>
        /// formats the ammount of money in the ATM
        /// </summary>
        /// <returns>formatted string of the money in the ATM</returns>
        public override string ToString()
        {
            string atmString      = "";
            int    ammountOfMoney = 0;

            for (int i = 0; i < Banknotes.Count; i++)
            {
                BanknoteCount banknote = Banknotes.GetBanknote(i) as BanknoteCount;
                atmString       = string.Format("{0}{1}*{2}+", atmString, banknote.Wealth, banknote.Count);
                ammountOfMoney += banknote.Wealth * banknote.Count;
            }

            atmString = atmString.Substring(0, atmString.Length - 1);
            atmString = string.Format("{0} = {1}", atmString, ammountOfMoney);

            return(atmString);
        }
        /// <summary>
        /// tries to get enough right banknotes for a withdraw operation
        /// this method does not remove any banknotes from the ATM, it only creates copies of the banknotes
        /// to withdraw
        /// </summary>
        /// <param name="ammount">ammount of money to withdraw</param>
        /// <param name="success">boolean indicating wether there was enough right banknotes to withdraw</param>
        /// <returns>BanknoteContainer of banknotes to be withdrawn (will be used only is success = true)</returns>
        private BanknoteContainer GetBanknotes(int ammount, out bool success)
        {
            BanknoteContainer banknotes = new BanknoteContainer(Program.NumberOfBanknoteTypes);

            for (int i = 0; i < Banknotes.Count; i++)
            {
                BanknoteCount banknote = Banknotes.GetBanknote(i) as BanknoteCount;

                int numberOfBanknotesRequired = ammount / banknote.Wealth;
                int availableBanknotes        = (banknote.Count >= numberOfBanknotesRequired)
                    ? numberOfBanknotesRequired : banknote.Count;

                banknotes.AddBanknote(new BanknoteCount(banknote.Wealth, availableBanknotes));
                ammount -= availableBanknotes * banknote.Wealth;
            }

            success = ammount == 0;

            return(banknotes);
        }