導航:首頁 > 編程語言 > 銀行賬戶java

銀行賬戶java

發布時間:2025-07-09 06:21:11

java語言程序設計:設計銀行賬戶類,屬性包括賬號、儲戶名稱、開戶時間、身份證號碼、存款余額等

寫個例子吧,既沒有分,又不付費。。。。真的是。。
public class account{
public static int serviceNum;
private String account;
private String password;
......
public String getAccount(){
return this.account;
}
public void setAccount(String account){
this.account = account;
}
public String getPassword(){
return this.password;
}
public void setPassword(String password){
this.password = password
}
public Account(String account,String password){
this.account = account;
this.password = password;
}
public Account(String account){
this.account = account;
}
@overrite
public String toString(){
return this.account + "-" + this.password;
}
}

❷ java定義一個類實現銀行賬戶的概念。

public class BankAccount {

String account ;
int account_num;

//構造函數
public BankAccount(String account,int account_num){
this.account=account;
this.account_num=account_num;
}
//存錢
public String addNum(int num){
account_num= account_num+num;
return "存錢成功";
}

//取錢
public String getNum(int num){
String result;
if(account_num>num){
account_num =account_num-num;
result="取錢成功";
}else{
result="賬戶余額不足,還剩"+account_num;
}
return result;
}

//顯示余額
public String displayNum(){
return "賬戶余額:"+account_num;
}

//顯示賬號
public String displayAccount(){
return "賬戶:"+account;
}

public static void main(String[] args){
BankAccount lucy = new BankAccount("lucy",100);
BankAccount jack = new BankAccount("jack",50);
//顯示他們各自的余額
System.out.println("===顯示他們各自的余額===");
System.out.println("lucy:"+lucy.displayNum());
System.out.println("jack:"+jack.displayNum());
//存錢取錢
System.out.println("===存錢取錢===");
System.out.println("lucy取50:"+lucy.getNum(50));
System.out.println("jack存200:"+jack.addNum(200));
//顯示賬戶 顯示余額
System.out.println("===存錢取錢===");
System.out.println(lucy.displayAccount()+""+lucy.displayNum());
System.out.println(jack.displayAccount()+""+jack.displayNum());

}

}

運行結果:
===顯示他們各自的余額===
lucy:賬戶余額:100
jack:賬戶余額:50
===存錢取錢===
lucy取50:取錢成功
jack存200:存錢成功
===存錢取錢===
賬戶:lucy賬戶余額:50
賬戶:jack賬戶余額:250

閱讀全文

與銀行賬戶java相關的資料

熱點內容
如何把文件加入data 瀏覽:505
u盤出現的奇怪文件 瀏覽:256
怎麼隱藏蘋果的app 瀏覽:807
電腦店pe破密碼 瀏覽:840
flex上傳文件到伺服器 瀏覽:541
js判斷firefox 瀏覽:717
資料庫恢復的基礎是利用轉儲的冗餘數據 瀏覽:227
後盾網mysql原創視頻教程 瀏覽:110
三菱m70程序輸入 瀏覽:986
家庭網路公共網路不設置 瀏覽:235
列印機接網路就死機 瀏覽:831
cs導入excel文件 瀏覽:410
u盤找不到源文件怎麼辦 瀏覽:867
網路電視如何設置連續播放 瀏覽:223
zp網路是什麼意思 瀏覽:694
狀態欄有個數據標識怎麼取消 瀏覽:575
win10水印去除工具 瀏覽:661
word2007怎麼添加背景音樂 瀏覽:552
r星手機app在哪裡下載 瀏覽:392
聯想硬碟保護系統密碼找回器 瀏覽:74

友情鏈接