⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 createaccount.cs

📁 csharp-solution,C#高效编程源码
💻 CS
字号:

using System;
using System.Collections;

// Test harness
class CreateAccount
{
    static void Main() 
    {
		// 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -