?? bankoperationsimp.cs
字號(hào):
using System;
using System.Collections.Generic;
using System.Text;
namespace Project1
{
/// <summary>
/// This is the implementation of the BankOperation
/// Interface.
/// </summary>
public class BankOperationsImp : BankOperations
{
AccountDatabase acDB = AccountDatabaseFactory.getDatabaseInstance();
#region BankOperations Members
/// <summary>
/// Deposit operation
/// </summary>
/// <param name="acNo">Account number</param>
/// <param name="amount">Amount of money needs to be deposited</param>
public void deposit(int acNo, double amount)
{
Account tempAC = acDB.search(acNo);
tempAC.dBalance += amount;
acDB.update(tempAC);
Console.WriteLine("Deposit has been done successfully");
}
/// <summary>
/// Withdrawal operation
/// </summary>
/// <param name="acNo">Account number</param>
/// <param name="amount">Amount of money needs to be withdrawn</param>
public void withdraw(int acNo, double amount)
{
Account tempAC = acDB.search(acNo);
if ((tempAC.dBalance - 500) <= 0)
Console.WriteLine("Withdrawal cannot be done as the minimum balance is 500 dollars");
else
{
tempAC.dBalance -= amount;
acDB.update(tempAC);
Console.WriteLine("Deposit has been done successfully");
}
}
/// <summary>
/// Transfer operation
/// </summary>
/// <param name="from">Source account number</param>
/// <param name="to">Destination account number</param>
/// <param name="amount">Amount of money needs to be transfered</param>
public void transfer(int from, int to, double amount)
{
Account tempACF = acDB.search(from);
Account tempACT = acDB.search(to);
if ((tempACF.dBalance - 500) <= 0)
Console.WriteLine("Withdrawal cannot be done as the minimum balance is 500 dollars");
else
{
tempACF.dBalance -= amount;
tempACT.dBalance += amount;
acDB.update(tempACF);
acDB.update(tempACT);
Console.WriteLine("Transfer has been done successfully");
}
}
/// <summary>
/// Balance enquiry operation
/// </summary>
/// <param name="acNo">Account number</param>
/// <returns>The balance of the account number enquiried</returns>
public double getBalance(int acNo)
{
Account tempAC = acDB.search(acNo);
return tempAC.dBalance;
}
/// <summary>
/// Transaction checking operation
/// </summary>
/// <param name="acNo">Account number</param>
public void getTransDetails(int acNo)
{
// throw new Exception("The method or operation is not implemented.");
}
#endregion
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -