bank.cs
来自「csharp-solution,C#高效编程源码」· CS 代码 · 共 66 行
CS
66 行
using System.Collections;
namespace Banking
{
public class Bank
{
private Bank()
{
}
public static long CreateAccount()
{
BankAccount newAcc = new BankAccount();
long accNo = newAcc.Number();
accounts[accNo] = newAcc;
return accNo;
}
public static long CreateAccount(AccountType accType, decimal balance)
{
BankAccount newAcc = new BankAccount(accType, balance);
long accNo = newAcc.Number();
accounts[accNo] = newAcc;
return accNo;
}
public static long CreateAccount(AccountType accType)
{
BankAccount newAcc = new BankAccount(accType);
long accNo = newAcc.Number();
accounts[accNo] = newAcc;
return accNo;
}
public static long CreateAccount(decimal balance)
{
BankAccount newAcc = new BankAccount(balance);
long accNo = newAcc.Number();
accounts[accNo] = newAcc;
return accNo;
}
public static BankAccount GetAccount(long accNo)
{
return (BankAccount)accounts[accNo];
}
public static bool CloseAccount(long accNo)
{
BankAccount closing = (BankAccount)accounts[accNo];
if (closing != null) {
accounts.Remove(accNo);
closing.Dispose();
return true;
} else {
return false;
}
}
private static Hashtable accounts = new Hashtable();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?