Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Tham khảo tài liệu 'java concepts 5th edition phần 8', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Java Concepts 5th Edition 99 100 assert state TRANSACT 101 return currentAccount.getBalance 102 103 104 105 Moves back to the previous state. 106 107 public void back 108 109 if state TRANSACT 110 state ACCOUNT 111 else if state ACCOUNT 112 state PIN 113 else if state PIN 114 state START 115 116 117 118 Gets the current state of this ATM. 119 @return the current state 120 121 public int getState 122 566 567 123 return state 124 125 126 private int state 127 private int customerNumber 128 private Customer currentCustomer 129 private BankAccount currentAccount 130 private Bank theBank 131 132 public static final int START 1 133 public static final int PIN 2 134 public static final int ACCOUNT 3 135 public static final int TRANSACT 4 136 137 public static final int CHECKING 1 138 public static final int SAVINGS 2 139 Chapter 12 Object-Oriented Design Page 51 of 77 Java Concepts 5th Edition ch12 atm Bank.java 1 import java.io.FileReader 2 import java.io.IOException 3 import java.util.ArrayList 4 import java.util.Scanner 5 6 7 A bank contains customers with bank accounts. 8 9 public class Bank 10 11 12 Constructs a bank with no customers. 13 14 public Bank 15 16 customers new ArrayList Customer 17 18 19 20 Reads the customer numbers and pins 21 and initializes the bank accounts. 22 @param filename the name of the customer file 23 24 public void readCustomers String filename 25 throws IOException 26 27 Scanner in new Scanner new FileReader filename 28 while in.hasNext 29 30 int number in.nextInt 31 int pin in.nextInt 32 Customer c new Customer number pin 33 addCustomer c 567 34 35 in.close 36 37 568 Chapter 12 Object-Oriented Design Page 52 of 77 Java Concepts 5th Edition 38 39 Adds a customer to the bank. 40 @param c the customer to add 41 42 public void addCustomer Customer c 43 44 customers.add c 45 46 47 48 Finds a customer in the bank. 49 @param aNumber a customer number 50 @param aPin a personal identification number 51 @return the matching customer or null if no .