Java-银行管理系统源代码
- 格式:docx
- 大小:35.53 KB
- 文档页数:56
Java小型银行管理系统源代码(图形界面)
accounts.java
package Account;
public class accounts {
protected int id;//银行账号
protected String password;//用户密码
protected String name;//用户型号
protected String personId;//身份账号
protected int accountType;//账号类型,0代表储蓄卡,1代表信用卡
protected double balance;//账户余额。之所以定义为protected是让他的子类可以直接用,不需要通过方法来赋值。
protected double ceiling;
public String getPassword(){
return password;
}
public void setPassword(String password){
this.password=password;
}
public String getName(){
return name;
}
public void setName(String name){
=name;
}
public String getPersonId(){
return personId;
}
public void setPersonId(String personId){ this.personId=personId;
}
public int getAccountType(){
return accountType;
}
public void setAccountType(int accountType){ this.accountType=accountType;
}
public double getBalance(){
return balance;
}
public void setBalance(double balance){ this.balance=balance;
}
public int getId(){
return id;
}
public void setId(int id){
this.id=id;
}
public double getCeiling(){
return ceiling;
}
public void setCeiling(double ceiling){
this.ceiling=ceiling;
}
//无参数构造方法
public accounts(){
}
//构造方法
public accounts(String password,String name,String personId,int accountType, double balance,double ceiling){
super();
this.password=password;
=name;
this.personId=personId;
this.accountType=accountType;
this.balance=balance;
this.ceiling=ceiling;
}
//存款
public void deposit(double money){
balance+=money;
}
//取款
public void withdraw(double money){
if(accountType==1){
if((balance+ceiling) System.out.println("对不起,已超出您的信用额度!"); } else{ balance-=money; } }else{ if(balance System.out.println("对不起,账户余额不足!"); }else{ balance-=money; } } } } DBoper.java package DB; import java.sql.*; import java.util.ArrayList; import Account.accounts; public class DBoper { private Connection conn = null; private Statement st = null; private PreparedStatement pstmt = null; private ResultSet rs = null; private ArrayList //连接数据库 public Connection getConnection(){ try{ Class.forName("com.mysql.jdbc.Driver"); conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/bankmanager?use Unicode=true&characterEncoding=utf8","root","xuewei"); }catch(Exception e){