/// <summary> /// Constructor /// </summary> /// <param name="id"></param> /// <param name="name"></param> /// <param name="lastName"></param> /// <param name="balance"></param> /// <param name="cardType"></param> /// <param name="status"></param> public Account(int id, string name, string lastName, int balance, CardType cardType, Status status) { Id = id; Name = name; LastName = lastName; Balance = balance; Type = cardType; Status = status; Bonus += BonusLogic.Add(balance, cardType); }
/// <summary> /// Add sum to account /// </summary> /// <param name="sum"></param> public void AddSum(int sum) { if (sum < 0) { throw new ArgumentException("Sum cannot be negative"); } if (IsActive) { Balance += sum; BonusLogic.Add(sum, Type); } else { throw new Exception("Account closed"); } }
/// <summary> /// Withdraw sum from account /// </summary> /// <param name="sum"></param> public void WithdrawSum(int sum) { if (sum < 0) { throw new ArgumentException("Sum cannot be negative"); } if (IsActive) { if (Balance >= sum) { Balance -= sum; Bonus = BonusLogic.Withdraw(sum, Type) < Bonus ? Bonus - BonusLogic.Withdraw(sum, Type) : 0; } else { throw new Exception("Account closed"); } } }