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

📄 bankaccount.java

📁 用jsp+servlet
💻 JAVA
字号:
/** * A bank account has a balance that can be changed by deposits and withdrawals. */import java.io.*;public class BankAccount implements Serializable{	/**	 * Constructs a bank account with a zero balance.	 */	private int aNumber, pin;	public BankAccount(int aNumber, int pin) {		this.aNumber = aNumber;		this.pin = pin;		DBConnection db = new DBConnection();		db.executeQuery("select * from atm where accountnumber=" + aNumber				+ " and pin=" + pin);		if (db.rs_next()) {			balance = db.rs_getDouble("balanceamount");		} else {			balance = 0;		}	}	/**	 * Constructs a bank account with a given balance.	 * 	 * @param initialBalance	 *            the initial balance	 */	public BankAccount(double initialBalance) {		balance = initialBalance;	}	/**	 * Withdraws money from the account.	 * 	 * @param the	 *            amount of money to withdraw	 */	public void deposit(double amount) {		balance = balance + amount;		DBConnection db = new DBConnection();		db.execute("update atm set balanceamount=" + balance				+ "where accountnumber=" + aNumber + " and pin=" + pin);	}	/**	 * Deposits money into the account.	 * 	 * @param the	 *            amount of money to deposit	 */	public void withdraw(double amount) {		balance = balance - amount;		DBConnection db = new DBConnection();		db.execute("update atm set balanceamount=" + balance				+ "where accountnumber=" + aNumber + " and pin=" + pin);	}	/**	 * Gets the account balance.	 * 	 * @return the account balance	 */	public double getBalance() {		return balance;	}	private double balance;}

⌨️ 快捷键说明

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