Esempio n. 1
0
        public virtual double Pay(double sum)
        {
            double result = 0;

            if (sum < _sum)
            {
                _sum  -= sum;
                result = sum;
                Payed?.Invoke(this, new AccountEventArgs($"The sum {sum} was withdrawed from account ,your left money is {_sum - sum }", _sum));
            }
            else
            {
                throw new ArgumentException($"There is not enough money on account. You need to pay {sum }");
            }
            return(sum);
        }
        public override double Pay(double sum)
        {
            isRegistered = true;
            double discount = sum * 0.8;

            if (_sum < sum)
            {
                throw new ArgumentException($"There is not enough money on Permanent account. You need to pay {sum }");
            }
            if (isRegistered || Age < 6)
            {
                Payed?.Invoke(this, new AccountEventArgs($"The discount sum { discount }, unless the full price {sum} was withdrawed from Permanent account, your left money is { _sum - sum}", _sum));
                return(base.Pay(discount));
            }
            else
            {
                Payed?.Invoke(this, new AccountEventArgs($"The sum { sum } was withdrawed from Permanent account, your left money is { _sum-sum }", _sum));
                return(base.Pay(sum));
            }
        }
        public override double Pay(double sum)
        {
            isRegistered = true;
            double additional_sum = sum * 1.2;

            if (_sum < sum)
            {
                throw new ArgumentException($"There is not enough money on Redistered account. You need to pay {sum }");
            }
            if (isRegistered || Age < 6)
            {
                Payed?.Invoke(this, new AccountEventArgs($"The sum { sum } was withdrawed from Registered account ,your left money is { _sum - sum }", _sum));
                return(base.Pay(sum));
            }
            else
            {
                Payed?.Invoke(this, new AccountEventArgs($"The sum { additional_sum } was withdrawed from Registered account ,your left money is { _sum - sum }", _sum));
                return(base.Pay(additional_sum));
            }
        }