예제 #1
0
 protected Account(Customer accCust, decimal interest, DateTime date, decimal saldo)
 {
     this.Customer = accCust;
     this.Interest = interest;
     this.Balance = saldo;
     this.OpenDate = date;
 }
예제 #2
0
 static void testDatabase()
 {
     Database d = new Database();
     List<Customer> list = new List<Customer>();
     Customer c = new Customer("Test","Console App",0,0,0);
     list.Add(c);
     d.save(list);
     Console.WriteLine("Testing Database.cs.....\n");
     Console.WriteLine("Customer's name: " + c.name+"\nNumbers of customers in the list: "+list.Count);
 }
예제 #3
0
 // Constructors
 public BankAccount(AccountType type, AccountCurrency currency, AccountPeriod period, Customer owner,
     long accountNumber)
 {
     this.Type = type;
     this.Currency = currency;
     this.Period = period;
     this.Owner = owner;
     this.CurrentBalance = 0;
     this.accountNumber = accountNumber;
     this.CalculateInterestRate();
 }
예제 #4
0
 static void Main()
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Database db = new Database();
     Customer c1 = new Customer("D, Trump", "Atlantic City,NJ", 000, 100, 80);
     new Thread(A).Start(db);  //A thread for ATM
     new Thread(A).Start(db);  //A thread for ATM
     Thread t = new Thread(T); // A thread for teller.
     t.SetApartmentState(ApartmentState.STA);
     t.Start(db);
 }
예제 #5
0
 // Constructors
 public LoanAccount(AccountType type, AccountCurrency currency, AccountPeriod period, decimal loanAmount, Customer owner,
     long accountNumber)
     : base(type, currency, period, owner, accountNumber)
 {
     if (loanAmount > 0)
     {
         this.loanAmount = loanAmount;
     }
     else
     {
         throw new ArgumentException("Amount of the loan must be bigger than 0");
     }
 }
예제 #6
0
 // Constructors
 public MortgageAccount(AccountType type, AccountCurrency currency, AccountPeriod period, RealEstate ownerProperty, decimal loanAmount,
     Customer owner, long accountNumber)
     : base(type, currency, period, owner, accountNumber)
 {
     this.ownerProperty = ownerProperty;
     if (loanAmount > 0)
     {
         if (this.ownerProperty.Price >= loanAmount)
         {
             this.loanAmount = loanAmount;
         }
         else
         {
             throw new ArgumentException(String.Format("Loan amount cannot exceed: {0}", this.ownerProperty.Price));
         }
     }
     else
     {
         throw new ArgumentException("Amount of the loan must be bigger than 0");
     }
 }
예제 #7
0
        public void TestAddAccount_AddOneAccount_OneAccountInListAndTrue()
        {
            #region Arrange
            Customer customer = new Customer("Sven Svensson");
            Account account = new Account("Savings", 250, false);
            List<Account> accountList = new List<Account>();
            #endregion

            #region Act
            accountList = customer.GetAllAccounts();
            bool result = customer.AddAccount(account);
            bool expected = true;
            int resultTwo = accountList.Count;
            int expectedTwo = 1;
            #endregion

            #region Assert
            Assert.AreEqual(expected, result);
            Assert.AreEqual(expectedTwo, resultTwo);
            #endregion
        }
예제 #8
0
        public void TestAddAccount_AddTwoAccountsWithUniqueNames_TwoAccountsInListAndTrue()
        {
            #region Arrange
            Customer customer = new Customer("Sven Svensson");
            Account account = new Account("Savings", 6500, false);
            Account accountTwo = new Account("Poker winnings", 3100, false);
            #endregion

            #region Act
            bool result = customer.AddAccount(account);
            bool expected = true;
            bool resultTwo = customer.AddAccount(accountTwo);
            bool expectedTwo = true;
            int resultThree = customer.GetAllAccounts().Count;
            int expectedThree = 2;
            #endregion

            #region Assert
            Assert.AreEqual(expected, result);
            Assert.AreEqual(expectedTwo, resultTwo);
            Assert.AreEqual(expectedThree, resultThree);
            #endregion
        }
예제 #9
0
        public void TestGetSpecificAccount_GetSpecificAccountWhenNameMatches_SpecificAccountWithMatchingName()
        {
            #region Arrange
            Customer customer = new Customer("Per Persson");
            Account account = new Account("Poker winnings", 6500, false);
            customer.AddAccount(account);
            #endregion

            #region Act
            Account matchingAccount = customer.GetSpecificAccount("Poker winnings");
            string result = matchingAccount.GetAccountName();
            string expected = "Poker winnings";
            #endregion

            #region Assert
            Assert.AreEqual(expected, result);
            #endregion
        }
예제 #10
0
        public void TestGetSpecificAccount_GetAccountWhenNoAccount_Null()
        {
            #region Arrange
            Customer customer = new Customer("Per Persson");
            #endregion

            #region Act
            Account result = customer.GetSpecificAccount("Savings account");
            Account expected = null;
            #endregion

            #region Assert
            Assert.AreEqual(expected, result);
            #endregion
        }
예제 #11
0
        public void TestGetAllAccounts_GetAccountsWhenTwoAccounts_ListWithTwoAccounts()
        {
            #region Arrange
            Customer customer = new Customer("Sven Svensson");
            Account accountOne = new Account("Poker winnings", 6500, false);
            Account accountTwo = new Account("Stryktipset winnings", 14500, false);
            customer.AddAccount(accountOne);
            customer.AddAccount(accountTwo);
            #endregion

            #region Act
            int result = customer.GetAllAccounts().Count;
            int expected = 2;
            #endregion

            #region Assert
            Assert.AreEqual(expected, result);
            #endregion
        }
예제 #12
0
        /// <summary>
        /// Method that will let teller to open a new account for customer.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void openActBtn_Click(object sender, EventArgs e)
        {
            if (name.Text.Length == 0 || address.Text.Length == 0 || amount.Text.Length == 0)
            {
                MessageBox.Show("Please fill out the full information!");
            }
            else
            {
                double bal = Convert.ToDouble(amount.Text);
                c = new Customer(name.Text, address.Text, (list.Count),(list.Count+100),bal);
                list.Add(c);
                dbase.save(list);
                name.Text = ""; address.Text = ""; amount.Text = "";
                MessageBox.Show("Customer Created Succesfully,\n\nCustomer Number will be: 00" + (list.Count - 1)+"\nAccount number will be: 0"+(list.Count+100));
            }

            //x(sender, e);
            //List of Customer and pass the parameter of Customer  object and then pass C into it, may want to use delegates.s
        }
예제 #13
0
        //Add customer
        public void AddCustomer(Customer customerToAdd)
        {
            var addCustomer = (
                from customer in this.customers
                where (customer.CustomerID == customerToAdd.CustomerID) ||
                      (customer.Pin == customerToAdd.Pin &&
                      customer.GetType() == customerToAdd.GetType())
                select customer).ToList();

            if (addCustomer.Count != 0)
            {
                throw new ArgumentException(String.Format("Customer with ID: {0} or PIN: {1} already exists in the system!",
                                                           customerToAdd.CustomerID, customerToAdd.Pin));
            }

            this.customers.Add(customerToAdd);
            OnCustomerOperation(new CustomerOperationsEventArgs(customerToAdd.CustomerID, customerToAdd.FirstName, customerToAdd.LastName,
                                                                customerToAdd.Pin, "ADD", customerToAdd.GetType().Name));
        }
예제 #14
0
 public Loan(Customer cust, decimal interest)
     : base(cust, interest)
 {
 }
예제 #15
0
        public void TestInstantiateCustomer_EmptyNameString_EmptyNameString()
        {
            #region Arrange
            Customer customer = new Customer("");
            #endregion

            #region Act
            string resultName = customer.Name;
            string expectedName = "";
            #endregion

            #region Assert
            Assert.AreEqual(expectedName, resultName);
            #endregion
        }
예제 #16
0
 protected Account(Customer accCust, decimal interest)
     : this(accCust, interest, DateTime.Now, 0m)
 {
 }
예제 #17
0
 // Constructors
 public DepositAccount(AccountType type, AccountCurrency currency, AccountPeriod period, Customer owner,
     long accountNumber)
     : base(type, currency, period, owner, accountNumber)
 {
 }
예제 #18
0
 public Deposit(Customer cust, decimal interest)
     : base(cust, interest)
 {
 }
예제 #19
0
 public Mortgage(Customer cust, decimal interest)
     : base(cust, interest)
 {
 }
예제 #20
0
 /// <summary>
 /// This method will just load a customer when the progarm begins.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Tellr_Load(object sender, EventArgs e)
 {
     Customer c1 = new Customer("D, Trump", "Atlantic City,NJ", 000, 100, 80);
     list.Add(c1);
     dbase.save(list);
     MessageBox.Show(list.Count + " Customer found in Database!");
 }
예제 #21
0
        public void TestInstantiateCustomer_SvenSvensson_SvenSvensson()
        {
            #region Arrange
            Customer customer = new Customer("Sven Svensson");
            #endregion

            #region Act
            string resultName = customer.Name;
            string expectedName = "Sven Svensson";
            #endregion

            #region Assert
            Assert.AreEqual(expectedName, resultName);
            #endregion
        }
예제 #22
0
 public BankHandler()
 {
     theCustomer = new Customer("Customer");
     initialAccount = new Account("Vacation savings", 7700.50, false);
     theCustomer.AddAccount(initialAccount);
 }
예제 #23
0
        public void TestGetAllAccounts_GetAccountsWhenNoAccounts_EmptyList()
        {
            #region Arrange
            Customer customer = new Customer("Sven Svensson");
            #endregion

            #region Act
            int result = customer.GetAllAccounts().Count;
            int expected = 0;
            #endregion

            #region Assert
            Assert.AreEqual(expected, result);
            #endregion
        }
예제 #24
0
 protected Account(Customer customer, decimal balance, decimal interestRate)
 {
     this.AccountHolder = customer;
     this.Balance = balance;
     this.InterestRate = interestRate;
 }
예제 #25
0
 public Loan(Customer cust, decimal interest, DateTime date, decimal saldo)
     : base(cust, interest, date, saldo)
 {
 }
예제 #26
0
 public MortgageAccount(Customer customer, decimal balance, decimal interestRate)
     : base(customer, balance, interestRate)
 {
 }
예제 #27
0
 public DepositAccount(Customer customer, decimal balance, decimal interestRate)
     : base(customer, balance, interestRate)
 {
 }
예제 #28
0
 public Account(Customer customer, decimal balance, decimal interestRate)
 {
     this.Customer = customer;
     this.Balance = balance;
     this.InterestRate = interestRate;
 }
예제 #29
0
 public void RemoveCustomer(Customer customer)
 {
     this.customers.Remove(customer);
 }
예제 #30
0
 /// <summary>
 /// This method will update the changes to the customer that has been stored in the list/Database.
 /// </summary>
 /// <param name="w"></param>
 /// <param name="x"></param>
 public void update(Customer w, int x)
 {
     lock (this)
     this.cust[x] = w;
 }