createaccount.cs
来自「csharp-solution,C#高效编程源码」· CS 代码 · 共 56 行
CS
56 行
using System;
using System.Collections;
using Banking;
// Test harness
class CreateAccount
{
static void Main()
{
//BankAccount created = new BankAccount();
// Insert test code here
Console.WriteLine("Sid's Account");
long sidsAccNo = Bank.CreateAccount();
BankAccount sids = Bank.GetAccount(sidsAccNo);
TestDeposit(sids);
TestWithdraw(sids);
Write(sids);
if (Bank.CloseAccount(sidsAccNo)) {
Console.WriteLine("Account closed");
} else {
Console.WriteLine("Something went wrong closing the account");
}
}
// Useful methods for the test harness
static void Write(BankAccount acc)
{
Console.WriteLine("Account number is {0}", acc.Number());
Console.WriteLine("Account balance is {0}", acc.Balance());
Console.WriteLine("Account type is {0}", acc.Type());
// Print out the transactions (if any)
Console.WriteLine("Transactions");
Queue tranQueue = acc.Transactions();
foreach (BankTransaction tran in tranQueue) {
Console.WriteLine("Date: {0}\tAmount: {1}", tran.When(), tran.Amount());
}
}
static void TestDeposit(BankAccount acc)
{
Console.Write("Enter amount to deposit: ");
decimal amount = decimal.Parse(Console.ReadLine());
acc.Deposit(amount);
}
static void TestWithdraw(BankAccount acc)
{
Console.Write("Enter amount to withdraw: ");
decimal amount = decimal.Parse(Console.ReadLine());
acc.Withdraw(amount);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?