Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- account
- ==================
- package Classes;
- public class Account {
- protected String name;
- protected static int totalAccount=0;
- protected int loan;
- protected int accountId;
- protected double commission;
- protected int personID;
- protected double balance;
- protected int misgeret;
- public Account(String name, int personID)
- {
- this.name = name;
- this.loan = 0;
- this.commission = 0;
- this.personID = personID;
- this.balance=0;
- this.misgeret=0;
- totalAccount+=1;
- this.accountId = totalAccount;
- }
- public static int getTotalAccount()
- {
- return totalAccount;
- }
- public void deposit(int amount)
- {
- //give the amount after the bank take commission
- this.balance+=amount*(1-(this.commission/100));
- }
- public boolean withdraw(int amount)
- {
- double totalSumWithdraw=(amount*(1+(this.commission/100)));
- //check if we can withdraw
- if (this.balance-totalSumWithdraw>this.misgeret)
- {
- return false;
- }
- //give the amount after the bank take commission
- this.balance-=totalSumWithdraw;
- return true;
- }
- public boolean giveLoan(int amount)
- {
- boolean returnResult=false;
- //give loan amount after the bank take commission
- if (this.loan==0)
- {
- this.loan+=amount*(1-(this.commission/100));
- returnResult=true;
- }
- return returnResult;
- }
- public int getMisgeret() {
- return misgeret;
- }
- public void setMisgeret(int misgeret) {
- this.misgeret = misgeret;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public double getCommission() {
- return commission;
- }
- public void setCommission(double commission) {
- //we will make override for each account type
- }
- public int getLoan() {
- return loan;
- }
- public int getAccountId() {
- return accountId;
- }
- public int getPersonID() {
- return personID;
- }
- public double getBalance() {
- return balance;
- }
- @Override
- public String toString() {
- //complate at home.... :)
- return "";
- }
- }
- regular
- ================
- package Classes;
- public class Regular extends Account{
- public Regular(String name, int personID) {
- super(name, personID);
- this.commission=utl.getRegularCommission();
- }
- public void setCommission(double commission) {
- if (commission<0)
- {
- this.commission=utl.getRegularCommission();
- return;
- }
- this.commission=commission;
- }
- }
Add Comment
Please, Sign In to add comment