Java實(shí)現(xiàn)銀行ATM功能示例?相信很多沒(méi)有經(jīng)驗(yàn)的人對(duì)此束手無(wú)策,為此本文總結(jié)了問(wèn)題出現(xiàn)的原因和解決方法,通過(guò)這篇文章希望你能解決這個(gè)問(wèn)題。
實(shí)現(xiàn)功能
1、用戶需要通過(guò)輸入銀行卡號(hào)和密碼才能進(jìn)入ATM系統(tǒng)
2、用戶可以在ATM中實(shí)現(xiàn)取款、存款、轉(zhuǎn)賬、余額查詢、退出系統(tǒng)等功能
簡(jiǎn)單分析
1、創(chuàng)建User類(cardNo,identity,phone,username,password,balance(余額))
2、創(chuàng)建Bank類,主要實(shí)現(xiàn)初始化用戶、用戶登錄、顯示菜單、取款、存款、轉(zhuǎn)賬、余額查詢、退出系統(tǒng)等功能。
代碼實(shí)現(xiàn)
User.java
public class User { private String username; private int password; private String cardNo; private String identity; private String phone; private double blance; public User() { } public User(String username, int password, String cardNo, String identity, String phone, double blance) { this.username = username; this.password = password; this.cardNo = cardNo; this.identity = identity; this.phone = phone; this.blance = blance; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public int getPassword() { return password; } public void setPassword(int password) { this.password = password; } public String getCardNo() { return cardNo; } public void setCardNo(String cardNo) { this.cardNo = cardNo; } public String getIdentity() { return identity; } public void setIdentity(String identity) { this.identity = identity; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } public double getBlance() { return blance; } public void setBlance(double blance) { this.blance = blance; } }