本文整理汇总了C#中Bank.AddAccount方法的典型用法代码示例。如果您正苦于以下问题:C# Bank.AddAccount方法的具体用法?C# Bank.AddAccount怎么用?C# Bank.AddAccount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bank
的用法示例。
在下文中一共展示了Bank.AddAccount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
Bank myBank = new Bank();
myBank.AddAccount(new DepositAccount(Customer.Company, 200m, 1.5m));
myBank.AddAccount(new LoanAccount(Customer.Individual, -20, 2m));
myBank.AddAccount(new MortgageAccount(Customer.Individual, -100m, 3m));
Account acc = new DepositAccount(Customer.Individual, 200m, 4m);
myBank.AddAccount(acc);
foreach (var account in myBank.Accounts)
{
Console.WriteLine("{0}(Money = {1})'s interest => {2}", account.GetType(), account.Balance, account.CalculateInterest(14));
}
myBank.RemoveAccount(acc);
if (acc is DepositAccount)
{
DepositAccount changeAcc = acc as DepositAccount;
changeAcc.Deposit(1000);
changeAcc.WithDraw(100);
myBank.AddAccount(changeAcc);
}
Console.WriteLine();
foreach (var account in myBank.Accounts)
{
Console.WriteLine("{0}(Money = {1})'s interest => {2}", account.GetType(), account.Balance, account.CalculateInterest(14));
}
}
示例2: Main
// Write a program to model the bank system by classes and interfaces.
// Identify the classes, interfaces, base classes and abstract actions
// and implement the calculation of the interest functionality through overridden methods.
private static void Main()
{
Client client1 = new ClientIndividual("Neo");
Client client2 = new ClientCompany("Office 1");
Client client3 = new ClientIndividual("Nakov");
Account acc1 = new DepositAccount(client1, 5, "BG13TLRK01");
Account acc2 = new LoanAccount(client2, 4.5m, "BG13TLRK02");
Account acc3 = new MortgageAccount(client3, 8.8m, "BG13TLRK03");
acc1.DepositMoney(1000);
((DepositAccount)acc1).WithdrawMoney(500);
acc2.DepositMoney(10000);
Bank bank = new Bank("New Bank");
bank.AddAccount(acc1);
bank.AddAccount(acc2);
bank.AddAccount(acc3);
Console.WriteLine(bank.Accounts);
Console.WriteLine();
Console.WriteLine("IBAN: {0} ({1}), Interest: {2:F2}", acc1.IBAN, acc1.Owner.Name, acc1.CalculateInterest(5));
Console.WriteLine("IBAN: {0} ({1}), Interest: {2:F2}", acc2.IBAN, acc2.Owner.Name, acc2.CalculateInterest(6));
Console.WriteLine("IBAN: {0} ({1}), Interest: {2:F2}", acc3.IBAN, acc3.Owner.Name, acc3.CalculateInterest(18));
Console.WriteLine("\nRemoving account 1");
bank.RemoveAccount(acc1);
Console.WriteLine(bank.Accounts);
}
示例3: TestBankAccountIndexer
public void TestBankAccountIndexer()
{
var bank = new Bank();
var acc = new Account();
bank.AddAccount(acc);
var sameAcc = bank[0];
Assert.AreSame(acc, sameAcc);
var secondAcc = new Account();
bank.AddAccount(secondAcc);
var sameSecondAcc = bank[1];
Assert.AreSame(secondAcc, sameSecondAcc);
Assert.AreNotSame(sameAcc, sameSecondAcc);
}
示例4: Main
public static void Main()
{
Bank bank = new Bank();
Account jhonAccount = new Account("0000121", "Jhon Doe", 10000m);
Account fooAccount = new Account("0000169", "Foo", 2000m);
bank.AddAccount(jhonAccount);
bank.AddAccount(fooAccount);
jhonAccount.Accept(new DepositVisitor(400m));
bank.Accept(new RemunerationAccountVisitor());
bank.Accept(new WithDrawVisitor(100m));
bank.Accept(new LogVisitor());
}
示例5: TestBankAccountIndexerInvalidRange
public void TestBankAccountIndexerInvalidRange()
{
var bank = new Bank();
var acc = new Account();
bank.AddAccount(acc);
var accFromBank = bank[1];
}
示例6: Main
static void Main()
{
var bank = new Bank("International Asset Bank");
bank.AddAccount(
new DepositAccount(CustomerType.Individual, 2330, 45).WithDraw(250.23m), // Test WithDraw()
new LoanAccount(CustomerType.Company, 250, 25).Deposit(250.23m), // Test Deposit()
new LoanAccount(CustomerType.Individual, 444, 44), // Remove
new MortgageAccount(CustomerType.Company, 2300, 15));
bank.RemoveAccount(new LoanAccount(CustomerType.Individual, 444, 44));
Console.WriteLine(bank);
/* ------------ */
Console.WriteLine(new DepositAccount(CustomerType.Individual, 2330, 45).CalculateInterestAmount(20));
Console.WriteLine(new LoanAccount(CustomerType.Company, 250, 25).Deposit(250.23m).CalculateInterestAmount(15));
Console.WriteLine(new MortgageAccount(CustomerType.Company, 2300, 15).CalculateInterestAmount(45) + "\n\n");
/* ------------ */
Console.WriteLine(new DepositAccount(CustomerType.Individual, 2330, 45));
}
示例7: TestBankRemoveInvalidAccount
public void TestBankRemoveInvalidAccount()
{
Bank bank = new Bank();
Account acc = new Account();
bank.AddAccount(acc);
Account anotherAcc = new Account();
bank.RemoveAccount(anotherAcc);
}
示例8: TestBankAddAccount
public void TestBankAddAccount()
{
Bank bank = new Bank();
Account acc = new Account();
bank.AddAccount(acc);
Assert.AreEqual(bank.AccountsCount, 1);
Assert.AreSame(bank[0], acc);
}
示例9: TestBankAddRemoveAccount
public void TestBankAddRemoveAccount()
{
Bank bank = new Bank();
Account acc = new Account();
bank.AddAccount(acc);
Assert.AreEqual(bank.AccountsCount, 1);
bank.RemoveAccount(acc);
Assert.AreEqual(bank.AccountsCount, 0);
}
示例10: TestBankAddAccount
public void TestBankAddAccount()
{
//// Arrange
Bank bank = new Bank();
Account acc = new Account();
//// Act
bank.AddAccount(acc);
//// Assert
Assert.AreEqual(bank.AccountsCount, 1, "Account is not added.");
Assert.AreSame(bank[0], acc);
////Assert.IsTrue(bank.AccountsCount != 0, "The account was not added to the bank.");
}
示例11: Main
static void Main()
{
Bank bank = new Bank("Bank Antinari inc.");
Customer newOwner = new Customer("Tano Caridi", CustomerType.Individual);
Deposit myDeposit = new Deposit(newOwner, 120000000, 13.45m);
bank.AddAccount(myDeposit);
Customer secondOwner = new Customer("Bai Ivan", CustomerType.Company);
Mortage GoshoLoan = new Mortage(secondOwner, 50000, 25.99m);
bank.AddAccount(GoshoLoan);
Console.WriteLine(bank);
for (int i = 0; i < bank.AllAccounts.Count; i++)
{
Console.WriteLine();
Console.WriteLine("Account {0}: ", i + 1);
Console.WriteLine(bank.AllAccounts[i]);
}
}
示例12: Main
static void Main()
{
Bank bank = new Bank();
DepositAccount depAccC = new DepositAccount(new Company(), 300M, 0.4M);
DepositAccount depAccI = new DepositAccount(new Individual(), 1000M, 0.4M);
LoanAccount loanAccC = new LoanAccount(new Company(), 1000M, 0.4M);
LoanAccount loanAccI = new LoanAccount(new Individual(), 1000M, 0.4M);
MortgageAccount mortAccC = new MortgageAccount(new Company(), 1000M, 0.4M);
MortgageAccount mortAccI = new MortgageAccount(new Individual(), 1000M, 0.4M);
bank.AddAccount(depAccC);
bank.AddAccount(depAccI);
bank.AddAccount(loanAccC);
bank.AddAccount(loanAccI);
bank.AddAccount(mortAccC);
bank.AddAccount(mortAccI);
foreach (var acc in bank.Accounts)
{
Console.WriteLine(acc.CalculateInterestAmount(12));
}
}
示例13: TestBankAddMoreAccounts
public void TestBankAddMoreAccounts()
{
//// Arrange + Act
var accountsCount = 10;
Bank bank = new Bank();
for (int i = 0; i < accountsCount; i++)
{
var account = new Account();
bank.AddAccount(account);
}
//// Assert
Assert.AreEqual(bank.AccountsCount, accountsCount, "Not all accounts are added");
Assert.IsTrue(bank.AccountsCount != 0, "The accounts was were not added to the bank.");
}
示例14: Main
static void Main()
{
Deposite depositeIndividualStanimir = new Deposite(new Individual("Stanimir"), 2003, 5);
Deposite depositeCompanyGeograficNational = new Deposite(new Company("GeograficNational"), 198032, 17);
Loan loanIndividualGerasim = new Loan(new Individual("Gerasim"), 315, 2);
Loan loanCompanyTouristOOD = new Loan(new Company("TouristOOD"), 43707, 9);
Mortgage mortgageIndividualPetkan = new Mortgage(new Individual("Petkan"), 200, 6);
Mortgage mortgageCompanySoftCom = new Mortgage(new Company("SoftCom"), 299387, 19);
Console.WriteLine(new string('-', 80));
Bank alianzBank = new Bank("Alianz");
alianzBank.AddAccount(depositeIndividualStanimir);
alianzBank.AddAccount(depositeCompanyGeograficNational);
alianzBank.AddAccount(loanIndividualGerasim);
alianzBank.AddAccount(loanCompanyTouristOOD);
alianzBank.AddAccount(mortgageIndividualPetkan);
alianzBank.AddAccount(mortgageCompanySoftCom);
Console.WriteLine(alianzBank.ToString());
}
示例15: TestBankAddNullAccount
public void TestBankAddNullAccount()
{
Bank bank = new Bank();
bank.AddAccount(null);
}