⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bank.java

📁 用jsp+servlet
💻 JAVA
字号:
import java.io.*;import java.util.ArrayList;import java.rmi.*;import java.rmi.server.*;/** * A bank contains customers with bank accounts. */public class Bank extends UnicastRemoteObject implements Serializable,		BankInterface {	/**	 * Constructs a bank with no customers.	 */	public Bank() throws RemoteException {		customers = new ArrayList<Customer>();	}	/**	 * Reads the customer numbers and pins and initializes the bank accounts.	 * 	 * @param filename	 *            the name of the customer file	 */	public void readCustomers(String filename) throws RemoteException {		DBConnection db = new DBConnection();		db.executeQuery("select * from atm");		while (db.rs_next()) {			int number = db.rs_getInt("accountnumber");			int pin = db.rs_getInt("pin");			Customer c = new Customer(number, pin);			addCustomer(c);		}	}	/**	 * Adds a customer to the bank.	 * 	 * @param c	 *            the customer to add	 */	public void addCustomer(Customer c) throws RemoteException {		customers.add(c);	}	/**	 * Finds a customer in the bank.	 * 	 * @param aNumber	 *            a customer number	 * @param aPin	 *            a personal identification number	 * @return the matching customer, or null if no customer matches	 */	public Customer findCustomer(int aNumber, int aPin) throws RemoteException {		for (int i = 0; i < customers.size(); i++) {			Customer c = (Customer) customers.get(i);			if (c.match(aNumber, aPin))				return c;		}		return null;	}	public static void main(String args[]) {		try {			Bank bank = new Bank();			java.rmi.registry.LocateRegistry.createRegistry(1099);			Naming.rebind("rmi://localhost:1099/bank", bank);		} catch (Exception e) {			// TODO: handle exception		}	}	private ArrayList<Customer> customers;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -