国产粉嫩无码不卡在线观看,酒店大战丝袜高跟鞋人妻,特级精品毛片免费观看,欧美亚洲日本国产综合在线

Java基礎(chǔ)課程設(shè)計(jì)-模擬ATM銀行管理系統(tǒng)《控制臺(tái)版本》(atm柜員機(jī)模擬系統(tǒng)java課程設(shè)計(jì))

前言介紹:

最近很多同學(xué)找我?guī)兔ψ鲆恍┱n程設(shè)計(jì)或Web前端大作業(yè)、其中控制臺(tái)項(xiàng)目應(yīng)該是初學(xué)者必須經(jīng)歷的一個(gè)過程、作為java初學(xué)者這個(gè)控制臺(tái)版本的模擬ATM銀行管理系統(tǒng)十分合適、用到的技術(shù)也是最簡(jiǎn)單的JavaList集合、變量的聲明、對(duì)象的創(chuàng)建、一些基本的while語(yǔ)句、switch語(yǔ)句、循環(huán)遍歷等基礎(chǔ)語(yǔ)法。一個(gè)最基礎(chǔ)版本的控制臺(tái)模擬ATM銀行管理系統(tǒng)也就是CRUD功能、 直接上完整代碼****

創(chuàng)建抽象類Card類

abstract class Card { int cardId; public Card() { super(); } public Card(int cardId) { super(); this.cardId = cardId; } public abstract String getCardId(); public abstract void setCardId(int cardId); }

創(chuàng)建普通銀行類繼承Card

public class CommonCard extends Card{ public CommonCard() { super(); } public CommonCard(int cardId) { super(); this.cardId = cardId; } @Override public String getCardId() { return "普通銀行卡卡號(hào)為:" cardId; } @Override public void setCardId(int cardId) { this.cardId = cardId; } }

創(chuàng)建普通信用卡繼承Card

package com.railway.modules.base.test;public class CreditCard extends Card{ public CreditCard() { super(); } public CreditCard(int cardId) { super(cardId); } @Override public String getCardId() { return "信用卡卡號(hào)為:" cardId; } @Override public void setCardId(int cardId) { this.cardId = cardId; }}

創(chuàng)建普通醫(yī)保卡繼承Card

package com.railway.modules.base.test;public class MedicalInsuranceCard extends Card{ public MedicalInsuranceCard() { super(); } public MedicalInsuranceCard(int cardId) { super(cardId); } @Override public String getCardId() { return "醫(yī)??ㄌ?hào)為:" cardId; } @Override public void setCardId(int cardId) { this.cardId = cardId; } }

ATM主要方法業(yè)務(wù)類邏輯實(shí)現(xiàn)

package com.railway.modules.base.test;import java.util.Scanner;public class ATM { Scanner input = new Scanner(System.in); private User[] user=new User[100]; User atm = new User(); private User usr; private int accountId = 1; private Card card; public void Select() { while(true) { System.out.println("=======ATM管理系統(tǒng)======="); System.out.print("1.開戶n2.登錄n3.取款n4.存款n5.余額查詢n6.修改密碼n7.查看用戶信息n8.退出登錄n9.退出系統(tǒng)n請(qǐng)選擇需要選擇的項(xiàng)目:"); switch(input.nextInt()) { case 1: setAccount(); //開戶 break; case 2: usr=userLogin(); //登錄 break; case 3: drawMoney(); //取款 break; case 4: depositMoney(); //存款 break; case 5: showBalance(); //余額查詢 break; case 6: revisePassword(); //修改密碼 break; case 7: lookAccount(); //查看用戶信息 break; case 8: cancel();//退出登錄 break; case 9: System.out.println("======================="); System.out.println("歡迎下次登錄該系統(tǒng)!"); //退出系統(tǒng) System.exit(0); break; default: System.out.println("======================="); System.out.println("輸入錯(cuò)誤!請(qǐng)重新輸入!"); break; } } } public void setAccount(){ //開戶 if (usr!=null) { System.out.println("======================="); System.out.println("請(qǐng)先退出上一個(gè)賬戶!"); } else{ boolean x = true; while(x) { System.out.println("======================="); System.out.print("1.普通銀行卡n2.信用卡n3.醫(yī)保卡n0.返回n請(qǐng)選擇開戶類型:"); switch(input.nextInt()) { case 1: card = new CommonCard(); card.setCardId(accountId); x=false; break; case 2: card = new CreditCard(); card.setCardId(accountId); x=false; break; case 3: card = new MedicalInsuranceCard(); card.setCardId(accountId); x=false; break; case 0: Select(); default: System.out.println("======================="); System.out.println("輸入錯(cuò)誤!請(qǐng)重新輸入!"); break; } } System.out.print("請(qǐng)輸入姓名:"); String name=input.next(); System.out.print("請(qǐng)輸入性別:"); String sex=input.next(); System.out.print("請(qǐng)輸入年齡:"); String age=input.next(); System.out.print("請(qǐng)輸入身份證號(hào):"); String ID=input.next(); System.out.print("請(qǐng)輸入銀行卡要設(shè)置的密碼:"); String password1=input.next(); System.out.print("請(qǐng)?jiān)俅屋斎朊艽a:"); String password2=input.next(); if(password1.equals(password2)){ user[accountId]=new User(name,sex,age,password1,ID,0,card); System.out.println("======================="); System.out.println("開戶成功!你的卡號(hào)為:" accountId); accountId ; } else { System.out.println("======================="); System.out.println("兩次密碼不同!請(qǐng)重新開始!"); } } } public User userLogin(){ //登錄 if (usr!=null) { System.out.println("======================="); System.out.println("請(qǐng)先退出上一個(gè)賬戶!"); return usr; } else{ System.out.print("請(qǐng)輸入卡號(hào):"); int aId=input.nextInt(); System.out.print("請(qǐng)輸入密碼:"); String password=input.next(); for(int i=0;i<user.length;i ){ if (user[i]!=null) { if (aId==user[i].getCard()&&password.equals(user[i].getPassword())) { System.out.println("======================="); System.out.println(user[i].getName() ",歡迎登錄!"); return user[i]; } } } System.out.println("======================="); System.out.println("卡號(hào)或密碼有誤"); return null; } } public void drawMoney(){ //取款 if(usr==null){ System.out.println("======================="); System.out.println("請(qǐng)先登錄賬戶!"); } else{ System.out.print("請(qǐng)輸入取款金額:"); double blc=input.nextDouble(); while(blc>usr.getBalance()) { System.out.println("======================="); System.out.print("取款金額大于余額,請(qǐng)重新輸入取款金額:"); blc=input.nextDouble(); } while(blc<=0){ System.out.println("======================="); System.out.print("取款金額錯(cuò)誤,請(qǐng)重新輸入取款金額:"); blc=input.nextDouble(); } usr.setBalance(usr.getBalance()-blc); System.out.println("======================="); System.out.println("取款成功!"); System.out.println("賬戶余額:" usr.getBalance()); } } public void depositMoney(){ //存款 if(usr==null){ System.out.println("======================="); System.out.println("請(qǐng)先登錄賬戶!"); } else{ System.out.print("請(qǐng)輸入存款金額:"); double dsm=input.nextDouble(); while(dsm<=0){ System.out.println("======================="); System.out.print("輸入金額錯(cuò)誤,請(qǐng)重新輸入:"); dsm=input.nextDouble(); } usr.setBalance(usr.getBalance() dsm); System.out.println("======================="); System.out.println("存款成功!"); System.out.println("賬戶余額:" usr.getBalance()); } } public void showBalance(){ //余額查詢 if(usr==null){ System.out.println("======================="); System.out.println("請(qǐng)先登錄賬戶!"); } else{ System.out.println("======================="); System.out.println("賬戶余額:" usr.getBalance()); } } public void revisePassword(){ //修改密碼 if(usr==null){ System.out.println("======================="); System.out.println("請(qǐng)先登錄賬戶!"); } else{ System.out.print("請(qǐng)輸入原密碼:"); String password=input.next(); for(int i=2;i>=0;i--) { if(password.equals(usr.getPassword())) break; if(i==0) { System.out.println("三次密碼輸入錯(cuò)誤!即將退出賬戶!"); cancel(); Select(); } System.out.println("密碼錯(cuò)誤!你還有" i "次機(jī)會(huì)!"); System.out.print("請(qǐng)輸入原密碼:"); password=input.next(); } System.out.print("驗(yàn)證成功,請(qǐng)輸入新密碼:"); String password1=input.next(); System.out.print("請(qǐng)?jiān)俅屋斎朊艽a:"); String password2=input.next(); while(!password1.equals(password2)) { System.out.println("======================="); System.out.print("兩次密碼不同,請(qǐng)重新輸入新密碼:"); password1=input.next(); System.out.print("請(qǐng)?jiān)俅屋斎朊艽a:"); password2=input.next(); } usr.setPassword(password1); System.out.println("======================="); System.out.println("修改成功!"); } } public void lookAccount() { //查看用戶信息 if(usr==null){ System.out.println("======================="); System.out.println("請(qǐng)先登錄賬戶!"); } else{ System.out.println("======================="); System.out.println("姓名:" usr.getName()); System.out.println("性別:" usr.getSex()); System.out.println(usr.getCardId()); System.out.println("身份證號(hào):" usr.getID()); System.out.println("余額:" usr.getBalance()); } } public void cancel() { if(usr==null){ System.out.println("======================="); System.out.println("請(qǐng)先登錄賬戶!"); } else{ usr=null; System.out.println("======================="); System.out.println("賬戶退出成功!"); } }}

main方法測(cè)試啟動(dòng)類

public class TestATM { public static void main(String[] args) { ATM atm = new ATM(); atm.Select(); }}

控制臺(tái)打?。?/h1>

=======ATM管理系統(tǒng)=======1.開戶2.登錄3.取款4.存款5.余額查詢6.修改密碼7.查看用戶信息8.退出登錄9.退出系統(tǒng)請(qǐng)選擇需要選擇的項(xiàng)目:1=======================1.普通銀行卡2.信用卡3.醫(yī)保卡0.返回請(qǐng)選擇開戶類型:1請(qǐng)輸入姓名:admin請(qǐng)輸入性別:男請(qǐng)輸入年齡:22請(qǐng)輸入身份證號(hào):513922199555555555請(qǐng)輸入銀行卡要設(shè)置的密碼:123456請(qǐng)?jiān)俅屋斎朊艽a:123456=======================開戶成功!你的卡號(hào)為:1=======ATM管理系統(tǒng)=======1.開戶2.登錄3.取款4.存款5.余額查詢6.修改密碼7.查看用戶信息8.退出登錄9.退出系統(tǒng)請(qǐng)選擇需要選擇的項(xiàng)目:2請(qǐng)輸入卡號(hào):1請(qǐng)輸入密碼:123456=======================admin,歡迎登錄!=======ATM管理系統(tǒng)=======1.開戶2.登錄3.取款4.存款5.余額查詢6.修改密碼7.查看用戶信息8.退出登錄9.退出系統(tǒng)請(qǐng)選擇需要選擇的項(xiàng)目:

很基礎(chǔ)、 適合java初學(xué)者來進(jìn)行練習(xí)以及當(dāng)做課程作業(yè)來使用

版權(quán)聲明:本文內(nèi)容由互聯(lián)網(wǎng)用戶自發(fā)貢獻(xiàn),該文觀點(diǎn)僅代表作者本人。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如發(fā)現(xiàn)本站有涉嫌抄襲侵權(quán)/違法違規(guī)的內(nèi)容, 請(qǐng)發(fā)送郵件至 舉報(bào),一經(jīng)查實(shí),本站將立刻刪除。