Exemplo n.º 1
0
 protected Account(Customer accCust, decimal interest, DateTime date, decimal saldo)
 {
     this.Customer = accCust;
     this.Interest = interest;
     this.Balance = saldo;
     this.OpenDate = date;
 }
Exemplo n.º 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);
 }
Exemplo n.º 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();
 }
Exemplo n.º 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);
 }
Exemplo n.º 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");
     }
 }
Exemplo n.º 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");
     }
 }
Exemplo n.º 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
        }
Exemplo n.º 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
        }
Exemplo n.º 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
        }
Exemplo n.º 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
        }
Exemplo n.º 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
        }
Exemplo n.º 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
        }
Exemplo n.º 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));
        }
Exemplo n.º 14
0
 public Loan(Customer cust, decimal interest)
     : base(cust, interest)
 {
 }
Exemplo n.º 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
        }
Exemplo n.º 16
0
 protected Account(Customer accCust, decimal interest)
     : this(accCust, interest, DateTime.Now, 0m)
 {
 }
Exemplo n.º 17
0
 // Constructors
 public DepositAccount(AccountType type, AccountCurrency currency, AccountPeriod period, Customer owner,
     long accountNumber)
     : base(type, currency, period, owner, accountNumber)
 {
 }
Exemplo n.º 18
0
 public Deposit(Customer cust, decimal interest)
     : base(cust, interest)
 {
 }
Exemplo n.º 19
0
 public Mortgage(Customer cust, decimal interest)
     : base(cust, interest)
 {
 }
Exemplo n.º 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!");
 }
Exemplo n.º 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
        }
Exemplo n.º 22
0
 public BankHandler()
 {
     theCustomer = new Customer("Customer");
     initialAccount = new Account("Vacation savings", 7700.50, false);
     theCustomer.AddAccount(initialAccount);
 }
Exemplo n.º 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
        }
Exemplo n.º 24
0
 protected Account(Customer customer, decimal balance, decimal interestRate)
 {
     this.AccountHolder = customer;
     this.Balance = balance;
     this.InterestRate = interestRate;
 }
Exemplo n.º 25
0
 public Loan(Customer cust, decimal interest, DateTime date, decimal saldo)
     : base(cust, interest, date, saldo)
 {
 }
Exemplo n.º 26
0
 public MortgageAccount(Customer customer, decimal balance, decimal interestRate)
     : base(customer, balance, interestRate)
 {
 }
Exemplo n.º 27
0
 public DepositAccount(Customer customer, decimal balance, decimal interestRate)
     : base(customer, balance, interestRate)
 {
 }
Exemplo n.º 28
0
 public Account(Customer customer, decimal balance, decimal interestRate)
 {
     this.Customer = customer;
     this.Balance = balance;
     this.InterestRate = interestRate;
 }
Exemplo n.º 29
0
 public void RemoveCustomer(Customer customer)
 {
     this.customers.Remove(customer);
 }
Exemplo n.º 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;
 }