Java银行管理系统源代码
this.balance=balance;
}
publicint getId(){
returnid;
}
publicvoid setId(int id){
this.id=id;
}
publicdouble getCeiling(){
returnceiling;
}
publicvoid setCeiling(double ceiling){
protected int accountType;//账号类型,0代表储蓄卡,1代表信用卡
protected double balance;//账户余额。之所以定义为protected是让他的子类可以直接用,不需要通过方法来赋值。
protecteddouble ceiling;
publicString getPassword(){
}catch(Exception e){
System.out.println("数据库连接失败");
}
returnconn;
}
//修改删除用户数据
publicboolean accountDataUpdate(String sqlpstmt=conn.prepareStatement(sql);
}
publicString getPersonId(){
returnpersonId;
}
publicvoid setPersonId(String personId){
this.personId=personId;
}
publicint getAccountType(){
returnaccountType;
balance+=money;
}
//取款
publicvoid withdraw(double money){
if(accountType==1){
if((balance+ceiling)<money){
System.out.println("对不起,已超出您的信用额度!");
}
else{
balance-=money;
Java
accounts.java
packageAccount;
publicclass accounts {
protected int id;//银行账号
protected String password;//用户密码
protected String name;//用户型号
protected String personId;//身份账号
pstmt.executeUpdate();
//System.out.println("数据更新成功");
conn.close();
returntrue;
}catch(SQLException e){
e.printStackTrace();
//System.out.println("更新失败");
returnfalse;
this.ceiling=ceiling;
}
//无参数构造方法
publicaccounts(){
}
//构造方法
publicaccounts(String password,String name,String personId,int accountType,
doublebalance,double ceiling){
}
publicvoid setAccountType(int accountType){
this.accountType=accountType;
}
publicdouble getBalance(){
returnbalance;
}
publicvoid setBalance(double balance){
returnpassword;
}
publicvoid setPassword(String password){
this.password=password;
}
publicString getName(){
returnname;
}
publicvoid setName(String name){
=name;
}
}
//依据id来修改记录
publicboolean dataupdateid(accounts user, int id) {
conn= getConnection();
try{
String sql = "update account set username=?,userpwd=?,personId=?,accountType=?,balance=?,ceiling=?whereid="
publicclass DBoper {
privateConnection conn = null;
privateStatement st = null;
privatePreparedStatement pstmt = null;
privateResultSet rs = null;
privateArrayList<accounts> result;
//连接数据库
publicConnection getConnection(){
try{
Class.forName("com.mysql.jdbc.Driver");
conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/bankmanager?useUnicode=true&characterEncoding=utf8","root","xuewei");
}
}else{
if(balance<money){
System.out.println("对不起,账户余额不足!");
}else{
balance-=money;
}
}
}
}
DBoper.java
packageDB;
importjava.sql.*;
importjava.util.ArrayList;
importAccount.accounts;
super();
this.password=password;
=name;
this.personId=personId;
this.accountType=accountType;
this.balance=balance;
this.ceiling=ceiling;
}
//存款
publicvoid deposit(double money){