You need to sign in to do that
Don't have an account?
Aravind Y B
Hai Guys,
How to create Bank Class With Deposit And Withdraw Methods?
(i want to Add Min balance Condition in withdraw)
please help me
Thanks
(i want to Add Min balance Condition in withdraw)
please help me
Thanks
public class bank {
//Properties
public String accholdername;
public String accNumber;
public String acctype;
Public string accBranch;
public Decimal mainBalance;
public decimal minbalance;
public Decimal totalaccbal;
//constutor:
public Bank(){
accholdername = 'naga';
accNumber = '8758245748';
acctype = 'Saving';
accBranch ='atp';
mainBalance=100000;
minbalance=10000;
system.debug('accholdername================='+accholdername);
system.debug('accNumber==========='+accNumber);
system.debug('acctype========='+acctype);
system.debug('accBranch==========='+accBranch);
system.debug('mainBalance========'+mainBalance);
system.debug('minbalance========'+minbalance);
}
//Method
public Void Deposite(Decimal amount){
totalaccbal = mainBalance+amount;
system.debug('==After deposit account balance====='+totalaccbal);
}
public void withdraw(Decimal withdrawamount){
if((totalaccbal-withdrawamount)<=minbalance){
system.debug('Minimum balance is required');
}
else{
totalaccbal = totalaccbal- withdrawamount;
system.debug('After withdraw acooount balance========='+totalaccbal);
}
}
}
this the bank class this is usefull u and others
any errors can best onswer
All Answers
Hey Aravind,
Can you please provide all your requirement and how do you want to achieve ? I mean using Visualaforce page + apex class or lightning component?
Regards,
Priya Ranjan
public class bank {
//Properties
public String accholdername;
public String accNumber;
public String acctype;
Public string accBranch;
public Decimal mainBalance;
public decimal minbalance;
public Decimal totalaccbal;
//constutor:
public Bank(){
accholdername = 'naga';
accNumber = '8758245748';
acctype = 'Saving';
accBranch ='atp';
mainBalance=100000;
minbalance=10000;
system.debug('accholdername================='+accholdername);
system.debug('accNumber==========='+accNumber);
system.debug('acctype========='+acctype);
system.debug('accBranch==========='+accBranch);
system.debug('mainBalance========'+mainBalance);
system.debug('minbalance========'+minbalance);
}
//Method
public Void Deposite(Decimal amount){
totalaccbal = mainBalance+amount;
system.debug('==After deposit account balance====='+totalaccbal);
}
public void withdraw(Decimal withdrawamount){
if((totalaccbal-withdrawamount)<=minbalance){
system.debug('Minimum balance is required');
}
else{
totalaccbal = totalaccbal- withdrawamount;
system.debug('After withdraw acooount balance========='+totalaccbal);
}
}
}
this the bank class this is usefull u and others
any errors can best onswer