Beispiel #1
0
 public AbstractBankAccount(string number, AccountOwner owner, decimal balance, decimal bonusPoints)
 {
     AccountNumber = number;
     Owner         = owner;
     Balance       = balance;
     BonusPoints   = bonusPoints;
     Status        = BankAccountStatus.Opened;
 }
        public BankAccountRepository()
        {
            Accounts = new List <BankAccount>();

            RepositoryFileName = Settings.Default.BinaryRepositoryFileName;

            if (!File.Exists(RepositoryFileName))
            {
                return;
            }

            Stream stream = File.OpenRead(RepositoryFileName);

            using (var reader = new BinaryReader(stream))
            {
                int count = reader.ReadInt32();
                for (int i = 0; i < count; i++)
                {
                    string            accountNumber  = reader.ReadString();
                    string            ownerFirstName = reader.ReadString();
                    string            ownerLastName  = reader.ReadString();
                    decimal           balance        = reader.ReadDecimal();
                    decimal           bonusPoints    = reader.ReadDecimal();
                    BankAccountStatus status         = (BankAccountStatus)reader.ReadInt32();

                    BankAccountType type = (BankAccountType)reader.ReadInt32();

                    var owner = new AccountOwner()
                    {
                        FirstName = ownerFirstName, LastName = ownerLastName
                    };

                    Accounts.Add(InitializeFields(BankAccountFactory.Create(type, accountNumber), owner, balance, bonusPoints));
                }
            }
        }
 /// <summary>
 /// constructs a platinum account with specified IBAN, owner, balance and bonus points
 /// </summary>
 /// <param name="iban">account IBAN</param>
 /// <param name="owner">account owner</param>
 /// <param name="balance">account balance</param>
 /// <param name="bonusPoints">account bonus points</param>
 public PlatinumAccount(string iban, AccountOwner owner, decimal balance, float bonusPoints, BankAccountStatus status = BankAccountStatus.Active) : base(iban, owner, balance, bonusPoints, status)
 {
     this.BalanceValue = 10;
     this.DepositValue = 5;
 }
Beispiel #4
0
 public virtual void Close()
 {
     Status      = BankAccountStatus.Closed;
     Balance     = 0;
     BonusPoints = 0;
 }
Beispiel #5
0
 public AbstractBankAccount(string number)
 {
     AccountNumber = number;
     Status        = BankAccountStatus.Opened;
 }
        /// <summary>
        /// Creates a bank account instance with specified IBAN, owner, balance and bonus points.
        /// </summary>
        /// <param name="iban">International Bank Account Number</param>
        /// <param name="owner">owner</param>
        /// <param name="balance">balance</param>
        /// <param name="bonusPoints">bonus points</param>
        protected BankAccount(string iban, AccountOwner owner, decimal balance, float bonusPoints, BankAccountStatus status)
        {
            if (string.IsNullOrWhiteSpace(iban))
            {
                throw new ArgumentException("String is not significant.", nameof(iban));
            }

            if (bonusPoints < 0 || bonusPoints > MaxBonusPoints)
            {
                throw new ArgumentOutOfRangeException("bonusPoints", $"Bonus points range is from 0 to {MaxBonusPoints}.");
            }

            this.IBAN        = iban;
            this.Owner       = owner ?? throw new ArgumentNullException(nameof(owner));
            this.Balance     = balance;
            this.BonusPoints = bonusPoints;
            this.Status      = status;
        }