📄 atmmain.java
字号:
private synchronized void cardqKeyPressed()
{
if(mode2==true)
{ textC.setText(" 谢谢使用");
lock=!lock;
mode1=false;
}
}
private synchronized void two0KeyPressed()
{
if(mode==true)
string2=string2+"*";
string1=string1+"00";
if(mode==true)
text2.setText(string2);
else
text2.setText(string1);
}
private synchronized void enterKeyPressed()
{
if(mode3==true)
{ try {
java.lang.Runtime.getRuntime().exec("cmd /c time 00:00:44");
} catch (java.io.IOException e)
{
e.printStackTrace();
}
mode1=true;
if(mode == false)
string4 = text2.getText();
else
if(mode == true)
string4 =string1;
// state2= !state2 ;
if(modepassw&&modemoney)
fun();
else
if(modepassw==false)
{
if(num==1)
{
string2="";
stringfir= new String(string1) ;
text2.setText("");
textC.setText(" 重输入一次密码");
string1="";
num++;
}
else if(num>=1)
{
if(string1.equals(stringfir)==true)
{
string2="";
newcard.setpasswor(stringfir);
textC.setText(" 修改密码成功");
text2.setVisible(false);
mode3=false;
modepassw=true;
}else
{
string2="";
textC.setText(" 输入错误!请重新输入");
text2.setText("");
state2=true;
string1="";
num=1;
}
}
}
else
if(modemoney==false)
{
money = Integer.parseInt(text2.getText());
if(money%100==0&&money<=1000&&newcard.getmoney()-money>=0)
{
newcard.setmoney(newcard.getmoney()-money);
textC.setText(" 取钱成功");
for(int i=0;i<4;i++)
textB[i].setVisible( true);
text2.setVisible(false);
mode3=false;
state2=true;
modemoney=true;
}
else if(newcard.getmoney()-money<0)
{
text2.setVisible(false);
textC.setText(" 您的余额不足");
for(int i=0;i<4;i++)
textB[i].setVisible( true);
state2=!state2;}
else
{
textC.setText(" 取钱金额必修为100以上的整数。而且一次不能超过一百");
text2.setText("");
string1="";
}
}
}
}
private synchronized void powerKeyPressed( int j)
{
if(mode1==true)
{
if( state2==false)
{
for(int i=0;i<6;i++)
textA[i].setVisible(state2);
if(j==5)
{
mode=false;
string2="";
string1="";
text2.setVisible(true);
textC.setText(" 请输入你需要的金额");
modemoney=false;
mode3=true;
}
else
{
if(newcard.getmoney()-(j+1)*100>=0)
{
newcard.setmoney(newcard.getmoney()-(j+1)*100);
textC.setText(" 取钱成功!");
for(int i=0;i<4;i++)
textB[i].setVisible( true);
state2=!state2;
}
else
{
textC.setText(" 您的余额不足");
for(int i=0;i<4;i++)
textB[i].setVisible( true);
state2=!state2; }
}}
else if(state2==true)
{
///////
switch (j)
{
case 0:
textC.setText("");
text2.setVisible(false);
modepassw=true;
num=1;
for(int i=0;i<4;i++)
textB[i].setVisible( !state1);
for(int i=0;i<6;i++)
textA[i].setVisible( state1);
state2=false;
break;
case 1:
text2.setVisible(false);
textC.setText(" 您的余额为"+newcard.getmoney()+".00元");
modepassw=true;
num=1;
break;
case 2:
mode = true;
text2.setVisible(true);
text2.setText("");
string1="";
textC.setText(" 请输入您的新密码");
modepassw=false;
string2="";
mode3=true;
break;
case 5:
textC.setText(" 谢谢使用!请取卡!");
for(int i=0;i<4;i++)
textB[i].setVisible( false);
mode2=true;
break;
default :
break;
}
}
}
}
private synchronized void digitKeyPressed(int i)
{
if(mode3==true)
{
if(mode==true)
string2=string2+"*";
switch(i)
{
case 1: //
string1=string1+ "1";
break;
case 2: //
string1=string1+ "2";
break;
case 3: // ' '
string1=string1+ "3";
break;
case 4: //
string1=string1+ "4";
break;
case 5: //
string1=string1+ "5";
break;
case 6: //
string1=string1+ "6";
break;
case 7: //
string1=string1+ "7";
break;
case 8: //
string1=string1+ "8";
break;
case 9: //
string1=string1+ "9";
break;
case 0: //
string1=string1+ "0";
break;
default:
break;
}
if(mode==true)
text2.setText(string2);
else
text2.setText(string1);
}
}
private void fun()
{
if(mode||mode4==false)
{
if(string1.equals(newcard.getpasswor())==true)
{
textC.setText(" 您已成功进入系统");
for(int i=0;i<4;i++)
textB[i].setVisible( state1);
text2.setVisible(false);
mode3=false;
mode4=false;
state2=true;
}
else
{
string1="";
string2="";
textC.setText(" 密码错误,请重新输入");
text2.setText("");
state2=true;
}
}
else if(!mode)
{
money = Integer.parseInt(string1);
newcard.setmoney(newcard.getmoney()-money);
state2=true;
}
}
public static void main(String args[])
{
ATMmain newATM = new ATMmain();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -