Esempio n. 1
0
 public Bancomat(IBanknote banknote)
 {
     if (banknote is Dollar)
     {
         _handler = new OneDollarHandler(null);                // 1
         _handler = new TwoDollarHandler(_handler);            // 2
         _handler = new FiveDollarHandler(_handler);           // 5
         _handler = new TenDollarHandler(_handler);            // 10
         _handler = new TwentyDollarHandler(_handler);         // 20
         _handler = new FiftyDollarHandler(_handler);          // 50
         _handler = new HundredDollarHandler(_handler);        // 100
     }
     else if (banknote is Euro)
     {
         _handler = new FiveEuroHandler(null);                 // 5
         _handler = new TenEuroHandler(_handler);              // 10
         _handler = new TwentyEuroHandler(_handler);           // 20
         _handler = new FiftyEuroHandler(_handler);            // 50
         _handler = new HundredEuroHandler(_handler);          // 100
         _handler = new TwoHundredEuroHandler(_handler);       // 200
         _handler = new FiveHundredEuroHandler(_handler);      // 500
     }
     else if (banknote is Ruble)
     {
         _handler = new TenRubleHandler(null);                    // 10
         _handler = new FiftyRubleHandler(_handler);              // 50
         _handler = new HundredRubleHandler(_handler);            // 100
         _handler = new FiveHundredRubleHandler(_handler);        // 500
         _handler = new ThousandDRubleHandler(_handler);          // 1000
         _handler = new FiveThousandRubleHandler(_handler);       // 5000
     }
 }
Esempio n. 2
0
        public override bool Validate(IBanknote banknote)
        {
            int money;

            if (!(Int32.TryParse(banknote.value_, out money)))
            {
                Console.WriteLine("Введите число.");
            }
            int cnt = (money / Value);

            if (cnt != 0)
            {
                getMoney(cnt);
                money = money - Value * cnt;
                if (money >= 10 || money != 0)
                {
                    Console.Write(" +");
                }
            }
            if (money < 10 && money != 0)
            {
                Console.WriteLine(" " + money.ToString() + " не валидная сумма =(");
                return(false);
            }
            return(base.Validate(new Ruble(money.ToString())));
        }
Esempio n. 3
0
 public virtual bool Validate(IBanknote banknote)
 {
     if (_nextHandler != null && _nextHandler.Validate(banknote))
     {
         return(true);
     }
     else
     {
         if (_nextHandler == null)
         {
             Console.WriteLine();
         }
         return(false);
     }
 }
Esempio n. 4
0
        public override bool Validate(IBanknote banknote)
        {
            int money;

            if (!(Int32.TryParse(banknote.value_, out money)) && money > 0)
            {
                Console.WriteLine("Введите число.");
            }
            int cnt = (money / Value);

            if (cnt != 0)
            {
                getMoney(cnt);
                money = money - Value * cnt;
                if (money != 0)
                {
                    Console.Write(" +");
                }
            }
            return(base.Validate(new Dollar(money.ToString())));
        }
Esempio n. 5
0
 public bool Validate(IBanknote banknote)
 {
     Console.Write($"{banknote.value_} {banknote.sign} =");
     return(_handler.Validate(banknote));
 }