資源簡介
賬戶管理系統(tǒng),銀行的atm機使用的微型管理系統(tǒng)模擬

代碼片段和文件信息
package?account;
import?java.util.InputMismatchException;
import?java.util.Map;
import?java.util.Vector;
import?java.util.Scanner;
import?java.util.Random;
import?java.io.IOException;
import?java.io.Serializable;
public?abstract?class?Account?implements?BankServiceComparable?Serializable{
private?int?id?;
private?String?name;
private?int?balance;
private?String?password;
private?Vector?history=new?Vector(10010);
public?Account(String?nameString?pwd){
Random?rd=new?Random();
this.id=Math.abs(rd.nextInt(10000));
this.name=name;
this.password=pwd;
}
public?Account(String?nameString?pwdint?balance){
this(namepwd);
Random?rd=new?Random();
this.id=Math.abs(rd.nextInt(10000));
this.balance=balance;
}
public?Account(int?idString?nameString?pwdint?balance){
this(namepwdbalance);
this.id=id;
}
public?int?getId(){
return?id;
}
public?void?setName(String?name){
this.name=name;
}
public?String?getName(){
return?name;
}
//存款
public?int?setBalance(int?amount){
return?balance+=amount;
}
//修改余額
public?int?setBalance1(int?amount){
return??balance=amount;
}
public?int?getBalance(){
return?balance;
}
public?String?getPassword(){
return?this.password;
}
public?void?setPassword(String?pwd){
this.password=pwd;
}
public?boolean?checkPwd()throws?WrongpwdException{
Scanner?sc=new?Scanner(System.in);
String?pwd;
int?n=0;
do{
System.out.println(“請輸入密碼:“);
pwd=sc.next();
try{
if(this.password.equals(pwd)){
return?true;
}
else{
throw?new?WrongpwdException();
}
}
catch(WrongpwdException?e){
System.out.println(e.getMessage());
}
catch(InputMismatchException?e){
System.out.println(“輸入不匹配“);
}
catch(Exception?e){
System.out.println(e.getMessage());
}
n++;
}while(n<5);
throw?new?WrongpwdException();?
}
public?void?addHistory(History?history){
this.history.add(history);
}
public?void?getHistory(){
for(History?history1:history){
System.out.println(history1);
}
}
public?int?compareTo(Account?o){
return?Integer.valueOf(this.id).compareTo(Integer.valueOf(o.getId()));
}
public?String?toString(){
return?this.name+“??“+this.id+“??當前余額是:“+this.balance;
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????2382??2011-05-10?22:03??account\Account.java
?????文件????????163??2011-05-04?20:00??account\BankService.java
?????文件???????1189??2011-05-10?22:05??account\CashAccount.java
?????文件???????1856??2011-05-04?20:00??account\CreditAccount.java
?????文件????????392??2011-05-04?20:00??account\History.java
?????文件????????147??2011-05-04?20:00??account\InsufficientFundException.java
?????文件????????136??2011-05-04?20:00??account\WrongpwdException.java
?????目錄??????????0??2011-05-26?19:10??account
-----------?---------??----------?-----??----
?????????????????6265????????????????????8
- 上一篇:Java拼寫檢查
- 下一篇:java2cpp java轉C++
評論
共有 條評論