Example #1
0
 public void SetMoney(int count, int MoneyCost)
 {
     if (count > 0)
     {
         if ((count / MoneyCost) != 0)
         {
             var MoneyCount = count / MoneyCost;
             count -= MoneyCost * MoneyCount;
             for (int i = 0; i < AllPapers.Count; i++)
             {
                 if (AllPapers[i].GetCost() == MoneyCost)
                 {
                     if ((AllPapers[i].GetAmount() + MoneyCount) <= AllPapers[i].GetMaxAmount())
                     {
                         var temp = new Papers(AllPapers[i].GetAmount(), AllPapers[i].GetCost(), AllPapers[i].GetMaxAmount());
                         temp.increaseAmount(MoneyCount);
                         AllPapers[i] = temp;
                         answer      += "Будет внесено " + MoneyCount + " номиналом " + MoneyCost + "\r\n";
                     }
                     else
                     {
                         answer += "Количество купюр достоинством " + MoneyCost + " максимально";
                     }
                 }
             }
         }
     }
     else
     {
         answer += "Введённая сумма меньше нуля \r\n";
     }
 }
Example #2
0
 public void SetMoney(int count)
 {
     if (count > 0)
     {
         for (int i = 0; i < AllPapers.Count; i++)
         {
             if ((count / AllPapers[i].GetCost()) != 0)
             {
                 if (AllPapers[i].CheckMaxAmount())
                 {
                     var money = count / AllPapers[i].GetCost();
                     if ((AllPapers[i].GetAmount() + money) < AllPapers[i].GetMaxAmount())
                     {
                         var temp = new Papers(AllPapers[i].GetAmount(), AllPapers[i].GetCost(), AllPapers[i].GetMaxAmount());
                         temp.increaseAmount(money);
                         AllPapers[i] = temp;
                         answer      += "Было внеено " + money + " купюр, достоинства " + AllPapers[i].GetCost() + "\r\n";
                         count       -= money * AllPapers[i].GetCost();
                     }
                 }
                 else
                 {
                     answer += "Количество купюр достоинством " + AllPapers[i].GetCost() + " максимально \r\n";
                 }
             }
         }
     }
     else
     {
         answer += "Введённая сумма меньше нуля \r\n";
     }
 }