public static void Main(string[] args) { var depositAccount = new DepositAccount(Clients.Person, 100, 20); Console.WriteLine(depositAccount.ShowBalance()); try { depositAccount.Deposit(-1); } catch (Exception ex) { Console.WriteLine(ex.Message); } try { Console.WriteLine(depositAccount.CalculateInterestOverPeriod(-10)); } catch (Exception ex) { Console.WriteLine(ex.Message); } depositAccount.Deposit(203); Console.WriteLine(depositAccount.ShowBalance()); Console.WriteLine(depositAccount.CalculateInterestOverPeriod(10)); try { Console.WriteLine($"Fail?: {depositAccount.Withdraw(100000)}"); depositAccount.Withdraw(-10); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
static void Main() { //Make na instance of the log system AccountOperationsFileLogger accountLogger = new AccountOperationsFileLogger(); CustomerOperationsFileLogger customerLogger = new CustomerOperationsFileLogger(); //Add subscribers to the event add/remove account/customer BankEngine.Instance.AccountOperation += accountLogger.AddToLog; BankEngine.Instance.CustomerOperation += customerLogger.AddToLog; //Make a list of employees List<Employee> mladostEmployees = new List<Employee>{ new Employee("Pesho","Peshev","Peshev", Sex.Male,new Address("Bulgaria", "Sofia",1713,"Mladost 1A",604,'A',4,18),7812123558M,852.75M,Position.President), new Employee("Kiro","Kirov","Kirov", Sex.Male,new Address("Bulgaria", "Sofia",1713,"Mladost 1A",607,'A',7,32),7412123558M,852.75M,Position.Casher), }; //Make an address Address locationMladost = new Address("Bulgaria", "Sofia", 1713, "bul.Al. Malinow 75"); //Make an office with the current employee set Office officeMladost1A = new Office("Mladost 1A", locationMladost, mladostEmployees); //Add the office to the system BankEngine.Instance.AddLocation(officeMladost1A); //Add an ATM to the system BankEngine.Instance.AddLocation(new ATM("Mladost 1A", locationMladost, 5410, Priority.High)); //Add an individual customer to the system IndividualCustomer peshoIvanov = new IndividualCustomer("IC745547", "Pesho", "Ivanov", "Ivanov", Sex.Male, new Address("Bulgaria", "Sofia", 1713, "ul.Bydnina 13"), 8709122554M); //IMPORTANT BankEngine.Instance.AddCustomer(peshoIvanov); //Make an account and add it to the system DepositAccount peshoOODDeposit = new DepositAccount(AccountType.Corporate, AccountCurrency.EUR, AccountPeriod.Six, new CorporateCustomer("CC55475", "PeshoOOD", new Address("Bulgaria", "Sofia", 1713, "ul.Igumen 12"), "BGCT855474V", "Pesho", "Ivanov", "Ivanov", Sex.Male, 8709122554M), 558574L); //IMPORTANT BankEngine.Instance.AddAccount(peshoOODDeposit); Console.WriteLine("BankEngine added new customer and account! The information was logged!"); Console.WriteLine(); //Deposit some money in peshoOODDeposit peshoOODDeposit.Deposit(5841.54M); //Trying to withdraw more than the balance of peshoOODDeposit try { Console.WriteLine("Try to withdraw more than the balance of an account:"); peshoOODDeposit.Withdraw(6000M); } catch (InsufficientFundsException ife) { Console.WriteLine(ife.Message + "You've tried to withdraw {0} but the current balance is {1}!", ife.Amount, ife.Balance); } Console.WriteLine(); }
static void Main() { Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(new string('=', 42)); // Create an instances of the new accounts DepositAccount depositAcc = new DepositAccount(CustomerType.Individual, "Gaius Julius Caesar", 3750, 5); LoanAccount loanAccInd = new LoanAccount(CustomerType.Individual, "King Leonidas", 5700, 4); LoanAccount loanAccComp = new LoanAccount(CustomerType.Company, "Naglite Corp.", 67879, 3); MortgageAccount mortgageAcc = new MortgageAccount(CustomerType.Company, "Talasumi Ltd.", 3700, 4); // Testing of the Deposit Account, Custumer Type - Individual Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("Customer Name: {0}\nCustomer Type: {1}", depositAcc.Customer, depositAcc.CustomerType); Console.WriteLine("Deposit balance is: {0}", depositAcc.Balance); depositAcc.DepositMoney(3000); Console.WriteLine("After depositing of 3000 the balance is: {0}", depositAcc.Balance); Console.WriteLine("Deposit balance is: {0}", depositAcc.Balance); depositAcc.WithdrawMoney(1000); Console.WriteLine("After withdrawing 1000 the balance is: {0}", depositAcc.Balance); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(new string('=', 42)); // Testing of the Loan Account, Custumer Type - Individual Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine("Customer Name: {0}\nCustomer Type: {1}", loanAccInd.Customer, loanAccInd.CustomerType); Console.WriteLine("Deposit balance is: {0}", loanAccInd.Balance); loanAccInd.DepositMoney(1000); Console.WriteLine("After deposition of 1000 balance is: {0}", loanAccInd.Balance); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(new string('=', 42)); // Testing of the Loan Account, Custumer Type - Company Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Customer Name: {0}\nCustomer Type: {1}", loanAccComp.Customer, loanAccComp.CustomerType); Console.WriteLine("Deposit balance is: {0}", loanAccComp.Balance); loanAccComp.DepositMoney(7500); Console.WriteLine("After deposition of 7500 balance is: {0}", loanAccComp.Balance); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(new string('=', 42)); // Testing the Interest Amount Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Interest Ammount of the accounts for 18 months: \n{0}: {1} \n{2}: {3} \n{4}: {5}", depositAcc.Customer, depositAcc.InterestAmount(18), loanAccInd.Customer, loanAccInd.InterestAmount(18), loanAccComp.Customer, loanAccComp.InterestAmount(18), mortgageAcc.Customer, mortgageAcc.InterestAmount(18)); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(new string('=', 42)); }
static void Main(string[] args) { //Customer customer = new CompanyCustomer(); CompanyCustomer customer = new CompanyCustomer("Philips", "Munich", "Main company address", BusinessSector.Other); DepositAccount account = new DepositAccount(customer, 12132358.47M, 5M); Console.WriteLine(account.Balance); Console.WriteLine(account.CalculateInterest(14)); account.Deposit(100000M); Console.WriteLine(account.Balance); account.Withdraw(500000M); Console.WriteLine(account.Balance); }
static void Main(string[] args) { Bank fib = new Bank("First Investment Bank"); IndividualCustomer pesho = new IndividualCustomer("Pesho"); DepositAccount depositAccount = new DepositAccount(pesho, 2M, 0.05m); fib.AddCustomer(pesho); fib.AddAccount(depositAccount); depositAccount.Deposit(1000M); Console.WriteLine("Current blanace: " + depositAccount.Balance); Console.WriteLine("Interest amount: " + depositAccount.CalculateInterest(23)); depositAccount.Withdraw(153.03M); Console.WriteLine("Current blanace: " + depositAccount.Balance); }
static void Main() { DepositAccount deposit = new DepositAccount(Customer.Individual, 0, 0.5m); deposit.Deposit(2000); deposit.Deposit(3000); deposit.Withdraw(500); //Console.WriteLine(deposit.Balance); //Console.WriteLine(deposit.CalculateInterest(5)); Account loan = new LoanAccount(Customer.Individual, 2000, 1m); //Console.WriteLine(loan.CalculateInterest(5)); Account mortgage = new LoanAccount(Customer.Individual, 30000, 1m); Console.WriteLine(mortgage.CalculateInterest()); }
/// <summary> /// Обработчик нажатия кнопки ОК /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Accept_Click(object sender, RoutedEventArgs e) { Type selectTypeAccount = ((KeyValuePair <String, Type>)(AccountType.SelectedItem)).Value; if (!Int32.TryParse(balanceTextBox.Text, out int balance)) { MessageBox.Show("Баланс введен не корректно!"); return; } if ((!Int32.TryParse(countMonthTextBox.Text, out int countMonth) || countMonth < 1) && (selectTypeAccount == typeof(DepositAccount))) { MessageBox.Show("Не верно указано количество месяцеы"); return; } try { if (selectTypeAccount == typeof(DepositAccount)) { Account = new DepositAccount(nametextBox.Text, balance, Convert.ToBoolean(capitalizaztionCheckBox.IsChecked), Convert.ToInt32(interestRateComboBox.Text), countMonth); } else { Account = new Account(nametextBox.Text, balance); } this.DialogResult = true; } catch (AccountException ex) { MessageBox.Show(ex.Message); } }
public static void Main() { ICustomer gosho = new IndividualCustomer("Georgi Georgiev"); ICustomer myCompany = new CompanyCustomer("My Company Ltd."); IAccount mortAccInd = new MortgageAccount(gosho, 924m, 2.4m); IAccount mortgageAccComp = new MortgageAccount(myCompany, 888m, 7.4m); IAccount loanAccInd = new LoanAccount(gosho, 2048m, 4.5m); IAccount loanAccComp = new LoanAccount(myCompany, 512m, 6.0m); IAccount depositAccIndBig = new DepositAccount(gosho, 888, 6.6m); IAccount depositAccIndSmall = new DepositAccount(gosho, 1111m, 7.9m); IAccount depositAccComp = new DepositAccount(myCompany, 50326m, 4.9m); List<IAccount> accounts = new List<IAccount>() { mortAccInd, mortgageAccComp, loanAccInd, loanAccComp, depositAccIndBig, depositAccIndSmall, depositAccComp }; foreach (var acc in accounts) { Console.WriteLine( "{5} {0,-15}: {1:N2}, {2:N2}, {3:N2}, {4:N2}", acc.GetType().Name, acc.CalculateRate(2), acc.CalculateRate(3), acc.CalculateRate(10), acc.CalculateRate(13), acc.Customer.GetType().Name); } }
public static void Main() { ICustomer pesho = new IndividualCustomer("Petar Petrov"); ICustomer agroCompany = new CompanyCustomer("Agro Company Ltd."); IAccount mortgageAccInd = new MortgageAccount(pesho, 1024m, 5.3m); IAccount mortgageAccComp = new MortgageAccount(agroCompany, 1024m, 5.3m); IAccount loanAccInd = new LoanAccount(pesho, 1024m, 5.3m); IAccount loanAccComp = new LoanAccount(agroCompany, 1024m, 5.3m); IAccount depositAccIndBig = new DepositAccount(pesho, 1024m, 5.3m); IAccount depositAccIndSmall = new DepositAccount(pesho, 999m, 5.3m); IAccount depositAccComp = new DepositAccount(agroCompany, 11024m, 4.3m); List<IAccount> accounts = new List<IAccount>() { mortgageAccInd, mortgageAccComp, loanAccInd, loanAccComp, depositAccIndBig, depositAccIndSmall, depositAccComp }; foreach (var acc in accounts) { Console.WriteLine( "{5} {0,-15}: {1:N2}, {2:N2}, {3:N2}, {4:N2}", acc.GetType().Name, acc.CalculateRate(2), acc.CalculateRate(3), acc.CalculateRate(10), acc.CalculateRate(13), acc.Customer.GetType().Name); } }
public static void Main() { ICustomer pesho = new IndividualCustomer("Petar Petrov"); ICustomer agroCompany = new CompanyCustomer("Agro Company Ltd."); IAccount mortgageAccInd = new MortgageAccount(pesho, 1024m, 5.3m); IAccount mortgageAccComp = new MortgageAccount(agroCompany, 1024m, 5.3m); IAccount loanAccInd = new LoanAccount(pesho, 1024m, 5.3m); IAccount loanAccComp = new LoanAccount(agroCompany, 1024m, 5.3m); IAccount depositAccIndBig = new DepositAccount(pesho, 1024m, 5.3m); IAccount depositAccIndSmall = new DepositAccount(pesho, 999m, 5.3m); IAccount depositAccComp = new DepositAccount(agroCompany, 11024m, 4.3m); List <IAccount> accounts = new List <IAccount>() { mortgageAccInd, mortgageAccComp, loanAccInd, loanAccComp, depositAccIndBig, depositAccIndSmall, depositAccComp }; foreach (var acc in accounts) { Console.WriteLine( "{5} {0,-15}: {1:N2}, {2:N2}, {3:N2}, {4:N2}", acc.GetType().Name, acc.CalculateRate(2), acc.CalculateRate(3), acc.CalculateRate(10), acc.CalculateRate(13), acc.Customer.GetType().Name); } }
public static List <Account> Accounts() { var accounts = new List <Account>(); var customer = new CustromerType(); var depositAccount = new DepositAccount(); var loanAccount = new LoanAccount(); Console.Write("Number of accounts to add: "); var numberOfAccounts = int.Parse(Console.ReadLine()); for (int i = 1; i <= numberOfAccounts; i++) { var customerType = 0; var accountType = 0; Console.WriteLine("[{0}] Account", i); do { Console.WriteLine("Custromer types"); Console.WriteLine("1. Individual"); Console.WriteLine("2. Company"); Console.Write("Custromer: "); customerType = int.Parse(Console.ReadLine()); } while (customerType < 1 || customerType > 2); do { Console.WriteLine("Account types"); Console.WriteLine("1. Deposit account"); Console.WriteLine("2. Loan account"); Console.WriteLine("3. Mortgage account"); Console.Write("Account: "); accountType = int.Parse(Console.ReadLine()); } while (accountType < 1 || accountType > 3); Console.Write("Balance: "); decimal balance = decimal.Parse(Console.ReadLine()); Console.Write("Interest rate: "); decimal interestRate = decimal.Parse(Console.ReadLine()); switch (customerType) { case 1: customer = CustromerType.Individual; break; case 2: customer = CustromerType.Company; break; } switch (accountType) { case 1: accounts.Add(new DepositAccount(customer, balance, interestRate)); break; case 2: accounts.Add(new LoanAccount(customer, balance, interestRate)); break; case 3: accounts.Add(new MortgageAccount(customer, balance, interestRate)); break; default: break; } Console.Clear(); } return(accounts); }
public static List<Account> Accounts() { var accounts = new List<Account>(); var customer = new CustromerType(); var depositAccount = new DepositAccount(); var loanAccount = new LoanAccount(); Console.Write("Number of accounts to add: "); var numberOfAccounts = int.Parse(Console.ReadLine()); for (int i = 1; i <= numberOfAccounts; i++) { var customerType = 0; var accountType = 0; Console.WriteLine("[{0}] Account", i); do { Console.WriteLine("Custromer types"); Console.WriteLine("1. Individual"); Console.WriteLine("2. Company"); Console.Write("Custromer: "); customerType = int.Parse(Console.ReadLine()); } while (customerType < 1 || customerType > 2); do { Console.WriteLine("Account types"); Console.WriteLine("1. Deposit account"); Console.WriteLine("2. Loan account"); Console.WriteLine("3. Mortgage account"); Console.Write("Account: "); accountType = int.Parse(Console.ReadLine()); } while (accountType < 1 || accountType > 3); Console.Write("Balance: "); decimal balance = decimal.Parse(Console.ReadLine()); Console.Write("Interest rate: "); decimal interestRate = decimal.Parse(Console.ReadLine()); switch (customerType) { case 1: customer = CustromerType.Individual; break; case 2: customer = CustromerType.Company; break; } switch (accountType) { case 1: accounts.Add(new DepositAccount(customer, balance, interestRate)); break; case 2: accounts.Add(new LoanAccount(customer, balance, interestRate)); break; case 3: accounts.Add(new MortgageAccount(customer, balance, interestRate)); break; default: break; } Console.Clear(); } return accounts; }