i m working on bank + atm project and i have to submtted on monday the account and bank class is working but in atm class i m very confused i want to add following methods in atm class
withdrawmoney
withdrawinstantmoney
please suggest some ideas i m worried
here is code for account class
public class Account { private String number; private String owner; private String type; private int money; private int age; private String currentCard; private String currentPIN; public Account(String number,String owner,String type,int money,int age,String currentCard,String currentPIN ) { this.number=number; this.owner=owner; this.type=type; this.money=money; this.age=age; this.currentPIN=currentPIN; this.currentCard=currentCard; } public void setCard(String currentCard) { this.currentCard=currentCard; } public void setPIn(String currentPIN) { this.currentPIN=currentPIN; } public String getCard() { return currentCard; } public String getPin() { return currentPIN; } public String getNo() { return number; } public String getOnwer() { return owner; } public int getage() { return age; } public String getType() { return type; } public int getMoney() { return money; } public void setNo(String number) { this.number=number; } public void setOnwer(String Nowner) { this.owner=owner; } public void setType(String type) { this.type=type; } public void setMoney(int money) { this.money=money; } public void setAge(int age) { this.age=age; } public void print() { System.out.println("Number="+number); System.out.println("onwer="+owner); System.out.println("type="+type); System.out.println("money="+money); System.out.println("your age="+age); System.out.println("card="+currentCard); System.out.println("pin="+currentPIN); }
here is code for Bank class
import java.util.ArrayList; import java.util.Scanner; public class Bank { private ArrayList<Account> allAccounts; private Scanner readIn; public double deposit; public Bank() { allAccounts = new ArrayList<Account>(); readIn = new Scanner(System.in); } public void setDeposit(double d) { deposit = d; } public double getDeposit() { return deposit; } public void addAccount(String number,String owner,String type,int money,int age,String currentCard,String currentPIN) { Account a=new Account(number,owner,type,money,age,currentCard,currentPIN); allAccounts.add(a); } private boolean indexValid(int index) { boolean valid; if(index < 0) { System.out.println("Index cannot be negative: " + index); valid = false; } else if(index >= allAccounts.size()) { System.out.println("Index is too large: " + index); valid = false; } else { valid = true; } return valid; } public void closeAccount(int index) { if(indexValid(index)) { allAccounts.remove(index); } } public void displayAcc(int index) { if(index >= 0 && index <allAccounts.size()) { Account newfilename = allAccounts.get(index); newfilename.print(); } } public void displayAllAcc() { for(Account theAccounts : allAccounts){ theAccounts.print(); System.out.println(); } } public void accountSearch(String owner) { for(Account acc : allAccounts) { if(acc.getOnwer().contains(owner)) { // System.out.println(acc.getDetails()); acc.print(); } else { System.out.println("no account found"); } } } public void depositMoney(String owner) { for(Account acc : allAccounts) { if(acc.getOnwer().contains(owner)) { System.out.println(acc.getMoney()+getDeposit()); } } } }
the main problem is in atm class i m confused
import java.util.Scanner; public class AtmMachine { private Scanner input; private Scanner readIn; private Account theAccount; private Bank theBank; private String Card; private String PIN; private int withdrawal; public AtmMachine() { readIn = new Scanner(System.in); input = new Scanner(System.in); }
please suggest some solution so i can do this