using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
namespace
transactions
{
internal
class
Program
{
private
static
string
ac_no =
"12345678"
;
static
void
Main(
string
[] args)
{
Account account =
new
Account();
account.SetAccount(ac_no);
account.addDeposit(123,ac_no);
int
bal = account.checkBalance(ac_no);
Console.WriteLine(
"your current balance is "
+ bal);
int
status = account.withdrawCash(12, ac_no);
if
(status != -1)
{
Console.WriteLine(
"Withdrawal successfull"
);
int
bal1 = account.checkBalance(ac_no);
Console.WriteLine(
"your current balance is "
+ bal1);
}
account.withdrawCash(12233, ac_no);
Console.ReadLine();
}
public
interface
ITransaction
{
void
addDeposit(
int
deposit_money,
string
ac_no);
int
withdrawCash(
int
req_cash,
string
ac_no);
int
checkBalance(
string
ac_no);
}
public
class
Account : ITransaction
{
string
account_number;
int
total_cash = 0;
public
void
SetAccount(
string
ac_no)
{
this
.account_number = ac_no;
}
public
bool
CheckAccountNumber(
string
ac_no)
{
if
(ac_no ==
this
.account_number)
{
return
true
;
}
else
{
return
false
;
}
}
public
void
addDeposit(
int
deposit_money,
string
ac_no)
{
if
(CheckAccountNumber(ac_no) ==
true
)
{
total_cash += deposit_money;
Console.WriteLine(
"Rs "
+ deposit_money +
" deposit successfully"
);
}
else
{
Console.WriteLine(
"You entered wrong account number"
);
}
}
public
int
checkBalance(
string
ac_no)
{
if
(CheckAccountNumber(ac_no) ==
true
)
{
return
this
.total_cash;
}
else
{
Console.WriteLine(
"You entered wrong account number"
);
return
-1;
}
}
public
bool
isEnoughCash(
int
req_cash)
{
return
(total_cash >= req_cash);
}
public
int
withdrawCash(
int
req_cash,
string
ac_no)
{
if
(CheckAccountNumber(ac_no) ==
true
)
{
if
(isEnoughCash(req_cash) ==
true
)
{
total_cash -= req_cash;
return
req_cash;
}
else
{
Console.WriteLine("You don't have required cash,
please deposit money
in
your account");
return
-1;
}
}
else
{
Console.WriteLine(
"You entered wrong account number"
);
return
-1;
}
}
}
}
}