Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new instance of the <see cref="BankAccount"/> class and adds it to account list
        /// </summary>
        /// <param name="firstName">user first name</param>
        /// <param name="secondName">user second name</param>
        /// <param name="gradation">account gradation</param>
        /// <returns>bank account</returns>
        public BankAccount CreateAccount(string firstName, string secondName, Gradation gradation)
        {
            int         number      = this.bankAccounts.Count + 1;
            BankAccount bankAccount = new BankAccount(number, firstName, secondName, gradation);

            this.bankAccounts.Add(bankAccount);
            return(bankAccount);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BankAccount"/> class
 /// </summary>
 /// <param name="number">unique number</param>
 /// <param name="firstName">user first name</param>
 /// <param name="secondName">user second name</param>
 /// <param name="accountGradation">account gradation</param>
 /// <param name="sum">money amount</param>
 /// <param name="isOpened">account status</param>
 /// <param name="bonusScore">bonus score</param>
 internal BankAccount(int number, string firstName, string secondName, Gradation accountGradation, double sum, bool isOpened, int bonusScore)
 {
     this.number           = number;
     this.firstName        = firstName;
     this.secondName       = secondName;
     this.AccountGradation = accountGradation;
     this.Sum        = sum;
     this.IsOpened   = isOpened;
     this.bonusScore = bonusScore;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BankAccount"/> class
 /// </summary>
 /// <param name="number">unique number</param>
 /// <param name="firstName">user first name</param>
 /// <param name="secondName">user second name</param>
 /// <param name="accountGradation">account gradation</param>
 internal BankAccount(int number, string firstName, string secondName, Gradation accountGradation)
 {
     this.number           = number;
     this.firstName        = firstName;
     this.secondName       = secondName;
     this.AccountGradation = accountGradation;
     this.Sum        = 0;
     this.IsOpened   = true;
     this.bonusScore = 0;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a BookListStorage property from binary file
        /// </summary>
        /// <param name="path">file path</param>
        public void LoadBankAccountsListStorageFromBinaryFile(string path)
        {
            using (FileStream fs = new FileStream(path, FileMode.Open))
            {
                using (BinaryReader br = new BinaryReader(fs))
                {
                    // bookListStorage.Clear();
                    while (br.PeekChar() > -1)
                    {
                        int    number        = br.ReadInt32();
                        string firstName     = br.ReadString();
                        string secondName    = br.ReadString();
                        int    bonusScore    = br.ReadInt32();
                        double sum           = br.ReadDouble();
                        bool   isOpened      = br.ReadBoolean();
                        string gradationName = br.ReadString();

                        Gradation gradation = null;

                        switch (gradationName)
                        {
                        case "Base":
                            gradation = new BaseGradation();
                            break;

                        case "Gold":
                            gradation = new GoldGradation();
                            break;

                        case "Platinum":
                            gradation = new PlatinumGradation();
                            break;
                        }

                        this.bankAccounts.Add(new BankAccount(number, firstName, secondName, gradation, sum, isOpened, bonusScore));
                    }
                }
            }
        }