?? hehe.txt
字號(hào):
/**
* @version 1.0
* @author Devil_Angel
* 該程序的功能為實(shí)現(xiàn)模擬銀行ATM自動(dòng)取款機(jī)提款,查詢等功能.
*
*/
import java.io.*;
/*該類為實(shí)現(xiàn)客戶信息及部分功能*/
class Account {
private String code =null; //信用卡號(hào)
private String name =null; //客戶姓名
private String password=null; //客戶密碼
private double money =0.0; //卡里金額
/********************/
public Account(String code,String name,String password,double money)
{
this.code=code;
this.name=name;
this.password=password;
this.money=money;
}
protected String get_Code() {
return code;
}
protected String get_Name() {
return name;
}
protected String get_Password() {
return password;
}
public double get_Money() {
return money;
}
/*得到剩余的錢的數(shù)目*/
protected void set_Balance(double mon) {
money -= mon;
}
}
/**********實(shí)現(xiàn)具體取款機(jī)功能*********/
class ATM {
Account act;
// private String name;
// private String pwd;
public ATM() {
act=new Account("000000","Devil","123456",50000);
}
/***********歡迎界面***********/
protected void Welcome()
{
String str="---------------------------------";
System.out.print(str+"\n"+
"歡迎使用Angel模擬自動(dòng)取款機(jī)程序.\n"+str+"\n");
System.out.print(" 1.>取款."+"\n"+
" 2.>查詢信息."+"\n"+
" 3.>密碼設(shè)置."+"\n"+
" 4.>退出系統(tǒng)."+"\n");
}
/**********登陸系統(tǒng)**********/
protected void Load_Sys() throws Exception
{
String card,pwd;
int counter=0;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
do {
System.out.println("請(qǐng)輸入您的信用卡號(hào):");
card=br.readLine();
System.out.println("請(qǐng)輸入您的密碼:");
pwd=br.readLine();
if(!isRight(card,pwd))
{
System.out.println("您的卡號(hào)或密碼輸入有誤.");
counter++;
}
else
SysOpter();
}while(counter<3);
Lock_Sys();
}
/**********系統(tǒng)操作**********/
protected void SysOpter() throws Exception
{
int num;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("請(qǐng)選擇您要操作的項(xiàng)目(1-4):");
num=br.read(); //num為ASICC碼轉(zhuǎn)換的整數(shù)
switch(num) {
case 49: BetBalance(); break;
case 50: Inqu_Info(); break;
case 51: Set_Password(); break;
case 52: Exit_Sys(); break;
}
System.exit(1);
}
/**********信息查詢**********/
protected void Inqu_Info() {
System.out.print("---------------------\n"+
act.get_Code()+"\n"+
act.get_Name()+"\n"+
act.get_Money()+"\n"+
"-----------------------");
}
/**********取款**********/
public void BetBalance() throws Exception
{
String str=null,str1;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
do {
System.out.println("請(qǐng)輸入您要取的數(shù)目:");
str=br.readLine();
str1=String.valueOf(act.get_Money());
if(str.compareTo(str1)>0) {
System.out.println("超過已有的錢數(shù),請(qǐng)重新輸入您要取的數(shù)目:");
}
else {
/*操作成功*/
// act.set_Balance(str);
System.out.println("取款成功,請(qǐng)收好您的錢.");
Welcome();
SysOpter();
}
}while(true);
}
/**********判斷卡內(nèi)是否有錢**********/
protected boolean isBalance() {
if(act.get_Money()<0) {
// System.out.println("對(duì)不起,您的錢數(shù)不夠或卡已透支.");
return false;
}
return true;
}
/********卡號(hào)密碼是否正確******/
protected boolean isRight(String card,String pwd)
{
if(act.get_Code().equals(card) && act.get_Password().equals(pwd))
return true;
else
return false;
}
/**********密碼修改**********/
protected void Set_Password() throws Exception
{
String pwd=null;
int counter=0;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
do {
System.out.println("請(qǐng)輸入舊密碼:");
pwd=br.readLine();
if(act.get_Password().equals(pwd))
{
do {
System.out.println("請(qǐng)輸入新密碼:");
String pwd1=br.readLine();
System.out.println("請(qǐng)?jiān)俅屋斎胄旅艽a:");
String pwd2=br.readLine();
if(!pwd1.equals(pwd2))
{
System.out.println("兩次輸入不一致,請(qǐng)?jiān)俅屋斎?");
}
else
{
System.out.println("密碼修改成功,請(qǐng)使用新密碼.");
Welcome();
SysOpter();
}
}while(true);
}
}while(counter>3);
}
/**********鎖定機(jī)器**********/
protected void Lock_Sys() {
System.out.println("對(duì)不起,您的操作有誤,卡已被沒收.");
System.exit(1);
}
/**********結(jié)束系統(tǒng)**********/
protected void Exit_Sys() {
System.out.println("感謝您使用本系統(tǒng),歡迎下次在來,再見!");
System.exit(1);
}
}
public class Text
{
public static void main(String[] args) throws Exception
{
ATM atm=new ATM();
atm.Welcome();
atm.Load_Sys();
// atm.Exit_Sys();
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -