Exemplo n.º 1
0
 //Constructor
 public Account(Customer customer, DateTime startDate, decimal balance, decimal interestRate)
 {
     this.Customer = customer;
     this.StartDate = startDate;
     this.Balance = balance;
     this.MonthlyInterestRate = interestRate;
 }
Exemplo n.º 2
0
 //constructor
 protected Account(Customer customer, DateTime creationDate, decimal balance = 0, decimal interest = 0)
 {
     this.Cutomer = customer;
     this.Balance = balance;
     this.Interest = interest;
     this.CreationDate = creationDate;
 }
Exemplo n.º 3
0
 private void ValidateLastName(Customer iCustomer)
 {
     if (!Regex.IsMatch(iCustomer.LastName, "[A-Z,a-z]"))
     {
         throw new ArgumentException("Please enter only characters");
     }
 }
Exemplo n.º 4
0
 private void ValidateAge(Customer iCustomer)
 {
     if (iCustomer.Age <= 18)
     {
         throw new ArgumentException("Customer should be older than 18 years");
     }
 }
Exemplo n.º 5
0
        public override decimal CalculateInterest(Customer client)
        {
            decimal numOfMonts=this.PeriodInMonts;
            if (client == Customer.Individual)
            {
                numOfMonts -= 6;
            }
            else
            {
                if (numOfMonts>12)
                {
                    //more than 12 monts mortgage
                    decimal currentNumOfMonts = 0;
                    for (int i = 1; i <= numOfMonts; i++)
                    {
                        if (i<=12)
                        {
                            currentNumOfMonts += 0.5m;
                        }
                        currentNumOfMonts++;
                    }
                    numOfMonts = currentNumOfMonts;
                }
                else
                {
                    //only 1 year mortgage
                    numOfMonts /= 2;
                }

            }
            decimal interest= numOfMonts * this.InterestRate;

            return interest;
        }
Exemplo n.º 6
0
 private void ValidatePhoneNumber(Customer iCustomer)
 {
     if (iCustomer.PhoneNumber.ToString().Length != 10)
     {
         throw new ArgumentException("Please enter valid phone number");
     }
 }
Exemplo n.º 7
0
        private Customer KindOfCustomer; //this is object from class Customer

        #endregion Fields

        #region Constructors

        //constructor
        public Account()
        {
            this.KindOfCustomer = kindOfCustomer;
            this.Balance = balance;
            this.InterestRate = interestRate;
            this.NumberOfMounths = numberOfMounts;
        }
Exemplo n.º 8
0
 //Constructor
 public Account(string customerID, Customer client, decimal balance, decimal interestRate, int periodInMonts)
 {
     this.CustomerID = customerID;
     this.client = client;
     this.balance = balance;
     this.interestRate = interestRate;
     this.periodInMonts = periodInMonts;
 }
Exemplo n.º 9
0
 public DepositAccount(
 Customer owner,
 decimal balance,
 decimal monthlyInterestRate,
 int periodInMonths)
     : base(owner, balance, monthlyInterestRate)
 {
     this.interestCalculator = new DepositAccountInterestCalculator(
     balance, monthlyInterestRate, periodInMonths);
 }
Exemplo n.º 10
0
 public int AddCustomer(Customer iCustomer)
 {
     ValidateLastName(iCustomer);
     ValidateFirstName(iCustomer);
     ValidatePhoneNumber(iCustomer);
     ValidateAge(iCustomer);
     Account account = new Account();
     iCustomer.BankAccount = account;
     customers.Add(iCustomer);
     return iCustomer.BankAccount.AccountNumber;
 }
Exemplo n.º 11
0
Arquivo: Loan.cs Projeto: kicata/OPP
 public override decimal CalculateInterest(Customer client)
 {
     int numOfMonts = this.PeriodInMonts;
     if (client == Customer.Individual)
     {
         numOfMonts -= 3;
     }
     else
     {
         numOfMonts -= 2;
     }
     decimal interest = numOfMonts * this.InterestRate;
     return interest;
 }
 public LoanAccountInterestCalculator(
 Customer owner, decimal principal, decimal monthlyInterestRate, int periodInMonths)
 {
     this.Principal = principal;
     if (owner is IndividualCustomer)
     {
         this.InterestFreePeriodInMonths = 3;
     }
     else
     {
         this.InterestFreePeriodInMonths = 2;
     }
     this.MonthlyInterestRate = monthlyInterestRate;
     this.PeriodInMonths = periodInMonths;
 }
Exemplo n.º 13
0
        public override decimal CalculateInterest(Customer client)
        {
            decimal balance = this.Balance;
            if (balance>0 && balance<1000)
            {
                return 0;
            }
            else
            {
                int numOfMonts = this.PeriodInMonts;

                decimal interest = numOfMonts * this.InterestRate;

                return interest;
            }
        }
Exemplo n.º 14
0
        public Account(Customer customer, decimal startBalance, double interestRate, byte months, DateTime dateOfCreation)
        {
            if (startBalance <= 0)
            {
                throw new ArgumentOutOfRangeException("The start balance must be bigger than 0.");
            }
            else
            {
                this.balance = startBalance;
            }

            this.customer = customer;
            this.interestRate = interestRate / 100;
            this.months = months;
            this.dateOfCreation = dateOfCreation;
        }
Exemplo n.º 15
0
 public MortgageAccount(Customer customer, decimal balance, decimal interestRate)
     : base(customer, balance, interestRate)
 {
 }
Exemplo n.º 16
0
 public Loan(decimal balance, float interestRate, Customer customer)
     : base(balance, interestRate, customer)
 {
 }
Exemplo n.º 17
0
 //constructor
 public Mortgage(Customer kindOfCustomer, decimal balance, decimal interestRate, int mortgagePeriod)
     : base(kindOfCustomer, balance, interestRate)
 {
     this.MortgagePeriod = mortgagePeriod;
 }
Exemplo n.º 18
0
 public Mortgage(decimal balance, float interestRate, Customer customer)
     : base(balance, interestRate, customer)
 {
 }
Exemplo n.º 19
0
 protected Account(Customer customer, decimal balance, decimal interest)
 {
     this.customer = customer;
     this.balance = balance;
     this.interest = interest;
 }
Exemplo n.º 20
0
 /// <summary>
 /// Make a deposit to a new customer. Enter customer name, starting balance and interest rate.
 /// </summary>
 /// <param name="customer"></param>
 /// <param name="startBalance"></param>
 /// <param name="interestRate"></param>
 public Deposit(Customer customer, decimal startBalance, double interestRate, byte months)
     : base(customer, startBalance, interestRate, months, DateTime.Now)
 {
 }
Exemplo n.º 21
0
 /// <summary>
 /// Get new customer a loan. Enter customer name, loan sum and interest rate.
 /// </summary>
 /// <param name="customer"></param>
 /// <param name="startBalance"></param>
 /// <param name="interestRate"></param>
 public Loan(Customer customer, decimal loanSum, double interestRate, byte months)
     : base(customer, loanSum, interestRate, months, DateTime.Now)
 {
 }
Exemplo n.º 22
0
 //base constructor
 public Account(decimal balance, float interestRate, Customer customer)
 {
     this.balance = balance;
     this.interestRate = interestRate;
     this.customer = customer;
 }
Exemplo n.º 23
0
 public Loan(Customer owner, decimal balance, decimal interestRate)
     : base(owner, balance, interestRate)
 {
 }
Exemplo n.º 24
0
 public BankAccount(Customer owner, decimal balance, decimal interestRate)
 {
     this.Owner = owner;
     this.Balance = balance;
     this.InterestRate = interestRate;
 }
Exemplo n.º 25
0
 protected Account(Customer customer, decimal balance, decimal interestRate)
 {
     this.Customer = customer;
     this.Balance = balance;
     this.InterestRate = interestRate;
 }
Exemplo n.º 26
0
 //constructor
 public AccountLoan(Customer customer, decimal balance, double interest)
 {
     this.Customer = customer;
     this.Balance = balance;
     this.InterestRate = interest;
 }
 public DepositAccount(Customer customer, decimal balance, decimal interestRate) 
     : base(customer, balance, interestRate)
 {
 }
Exemplo n.º 28
0
 public BankAccountBase(Customer customer, decimal balance, decimal interestRate)
 {
     this.Customer = customer;
     this.Balance = balance;
     this.InterestRate = interestRate;
 }
Exemplo n.º 29
0
 public LoanAccount(Customer client, decimal balance, decimal interest)
     : base(client, balance, interest)
 {
 }
Exemplo n.º 30
0
 public MortgageAccount(Customer customer, DateTime creationDate, decimal balance = 0, decimal interest = 0)
     : base(customer, creationDate, balance, interest)
 {
 }