⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 serverwindows.java

📁 模拟银行的ATM自动取款机
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
      con1.add(pay);
      con1.add(delete);
      con1.add(over);
      
      changePassword.addActionListener(this);
      save.addActionListener(this);
      draw.addActionListener(this);
      over.addActionListener(this);
      query.addActionListener(this);
      delete.addActionListener(this);
      moveMoney.addActionListener(this);
      pay.addActionListener(this);

      add(con0);
      add(con1);
      
      setVisible(true);
   }
   
   public void actionPerformed(ActionEvent ae){
      String command=(String)ae.getActionCommand();
      if(command=="修改密码"){
         setVisible(false);
         new changeUserPassword(manager,account);
      }
      if(command=="存款"){
         setVisible(false);
         new save(manager,account);
      }
      if(command=="取款"){
         setVisible(false);
         new draw(manager,account);
      }
      if(command=="操作结束"){
         setVisible(false);
         new Manage(manager);
      }
      if(command=="帐户查询"){
         setVisible(false);
         new accountQuery(manager,account);
      }
      if(command=="帐户注销"){
         setVisible(false);
         if(account.getMoney()>1){
            new cantDelete(manager,account,0);
         }
         else if(account.getMoney()<=0){
            new cantDelete(manager,account,1);
         }
         else{
            new toDelete(manager,account);
         }
      }
      if(command=="代理缴费"){
         setVisible(false);
         new pay(manager,account);
         
      }
      if(command=="转帐"){
         setVisible(false);
         new moveMoney(manager,account);
      }
   }
}


class newUser extends Frame implements ActionListener,ItemListener{
   Label title;
   Label name;
   Label tel;
   Label idCard;
   Label initCash;
   Checkbox isCreditCard;
   TextField nameText;
   TextField idText;
   TextField telText;
   TextField idCardText;
   TextField cash;
   Button enter;
   Button back;
   ManagerOperate manager;
   Employer account;
   
   public newUser(ManagerOperate manager){
      this.manager=manager;
      
      title=new Label("新帐户注册");
      name=new Label("输入姓名");
      tel=new Label("联系电话");
      idCard=new Label("身份证号");
      initCash=new Label("开户金额");
      isCreditCard=new Checkbox("申请为信用卡");
      nameText=new TextField(10);
      idText=new TextField(10);
      cash=new TextField(10);
      idCardText=new TextField(20);
      enter=new Button("提交");
      back=new Button("返回");
      telText=new TextField(10);
      
      setBackground(Color.lightGray);
      setLocation(200,200);
      setSize(400,300);
      setLayout(new GridLayout(7,1));
      
      
      Container con0=new Container();
      con0.setLayout(new FlowLayout());
      Font font=new Font("Arial",Font.BOLD,24);
      con0.setFont(font);
      con0.add(title);
      
      Container con1=new Container();
      con1.setLayout(new FlowLayout());
      con1.add(name);
      con1.add(nameText);
      
      
      Container con3=new Container();
      con3.setLayout(new FlowLayout());
      con3.add(tel);
      con3.add(telText);
      
      Container con4=new Container();
      con4.setLayout(new FlowLayout());
      con4.add(initCash);
      con4.add(cash);
      
      Container con5=new Container();
      con5.setLayout(new FlowLayout());
      con5.add(idCard);
      con5.add(idCardText);
      
      Container con6=new Container();
      con6.setLayout(new FlowLayout());
      con6.add(isCreditCard);
      
      Container con7=new Container();
      con7.setLayout(new FlowLayout());
      con7.add(enter);
      con7.add(back);
      
      add(con0);
      add(con1);
      add(con3);
      add(con4);
      add(con5);
      add(con6);
      add(con7);
      
      enter.addActionListener(this);
      back.addActionListener(this);
      isCreditCard.addItemListener(this);
      
      setVisible(true);
   }
   
   public void actionPerformed(ActionEvent ae){
      String command=(String)ae.getActionCommand();
      if(command=="提交"){
         if(idCardText.getText().equals("")||nameText.getText().equals("")||cash.getText().equals("")||telText.getText().equals("")){
            new noText();
         }else{
         account=new Employer(manager.getid());
         if(idCardText.getText().length()!=15&&idCardText.getText().length()!=18){
            setVisible(false);
            new newManagerError(manager,1);
         }
         else
         if(isNumber.isNum(cash.getText())==false||isNumber.isNum(telText.getText())==false){
            setVisible(false);
            new inputError(manager);
         }
         else{
            float money=Float.parseFloat(cash.getText());
            int i=0;
            if(isCreditCard.getState())  i=1;
            account.createNewAccount(idCardText.getText(),nameText.getText(),telText.getText(),money,i);
            setVisible(false);
            new newUserOk(manager);
         }
      }
      }
      if(command=="返回"){
         setVisible(false);
         new Manage(manager);
      }
   }
   
   public void itemStateChanged(ItemEvent ie){}
}


class changeUserPassword extends Frame implements ActionListener{
   Label title;
   Label input;
   Label reinput;
   TextField password;
   TextField repassword;
   Button enter;
   Button back;
   ManagerOperate manager;
   Employer account;
   
   
   public changeUserPassword(ManagerOperate manager,Employer account){
      this.manager=manager;
      this.account=account;
      
      title=new Label("密码修改");
      input=new Label("输入密码");
      reinput=new Label("重新输入密码");
      password=new TextField(10);
      repassword=new TextField(10);
      enter=new Button("确定");
      back=new Button("返回");
      
      setBackground(Color.lightGray);
      setLocation(200,200);
      setSize(300,250);
      setLayout(new GridLayout(4,1));
      
      Container con0=new Container();
      Font font=new Font("Arial",Font.BOLD,24);
      con0.setFont(font);
      con0.setLayout(new FlowLayout());
      con0.add(title);
      
      Container con1=new Container();
      con1.setLayout(new FlowLayout());
      con1.add(input);
      con1.add(password);
      password.setEchoChar('*');
      
      Container con2=new Container();
      con2.setLayout(new FlowLayout());
      con2.add(reinput);
      con2.add(repassword);
      repassword.setEchoChar('*');
      
      Container con3=new Container();
      con3.setLayout(new FlowLayout());
      con3.add(enter);
      con3.add(back);
      
      enter.addActionListener(this);
      back.addActionListener(this);
      
      
      add(con0);
      add(con1);
      add(con2);
      add(con3);
      
      setVisible(true);
   }
   
   public void actionPerformed(ActionEvent ae){
      String command=(String)ae.getActionCommand();
      if(command=="返回"){
         setVisible(false);
         new operateUser(manager,account);
      }
      if(command=="确定"){
         if(password.getText().equals("")||repassword.getText().equals("")){
            new noText();
         }else{
         if(isNumber.isNum(password.getText())==false||isNumber.isNum(repassword.getText())==false){
            new inputError2(manager,account);
            setVisible(false);
         }
         else if(password.getText().equals(repassword.getText())&&password.getText().length()==6){
            setVisible(false);
            account.changePassWordCustomer(password.getText());
            new changeOk2(manager,account);
         }
         else{
            setVisible(false);
            new changeError2(manager,account);
         }
      }
      }
   }
}

class changeError2 extends Frame implements ActionListener{
   Label lab;
   Button back;
   ManagerOperate manager;
   Employer account;
   
   public changeError2(ManagerOperate manager,Employer account){
      this.manager=manager;
      this.account=account;
      
      lab=new Label("两次输入密码不等或密码不为6位!");
      back=new Button("返回");
      
      setSize(400,150);
      setBackground(Color.lightGray);
      setLocation(200,200);
      setLayout(new GridLayout(2,1));
      
      Container con0=new Container();
      con0.setLayout(new FlowLayout());
      Font font=new Font("Arial",Font.BOLD,20);
      con0.setFont(font);
      con0.add(lab);
      
      Container con1=new Container();
      con1.setLayout(new FlowLayout());
      con1.add(back);
      
      back.addActionListener(this);
      
      add(con0);
      add(con1);
      
      setVisible(true);
   }
   
   
   public void actionPerformed(ActionEvent ae){
      String command=(String)ae.getActionCommand();
      if(command=="返回"){
         setVisible(false);
         new operateUser(manager,account);
      }
   }
}

class changeOk2 extends Frame implements ActionListener{
   Label lab;
   Button back;
   ManagerOperate manager;
   Employer account;
   
   public changeOk2(ManagerOperate manager,Employer account){
      this.manager=manager;
      this.account=account;
      
      lab=new Label("密码修改成功!");
      back=new Button("返回");
      
      setSize(300,150);
      setBackground(Color.lightGray);
      setLocation(200,200);
      setLayout(new GridLayout(2,1));
      
      Container con0=new Container();
      con0.setLayout(new FlowLayout());
      Font font=new Font("Arial",Font.BOLD,24);
      con0.setFont(font);
      con0.add(lab);
      
      Container con1=new Container();
      con1.setLayout(new FlowLayout());
      con1.add(back);
      
      back.addActionListener(this);
      
      add(con0);
      add(con1);
      
      setVisible(true);
   }
   
   
   public void actionPerformed(ActionEvent ae){
      String command=(String)ae.getActionCommand();
      if(command=="返回"){
         setVisible(false);
         new operateUser(manager,account);
      }
   }
}


class save extends Frame implements ActionListener{
   Label title;
   Label lab;
   TextField saveCash;
   Button enter;
   Button back;
   ManagerOperate manager;
   Employer account;
   
   public save(ManagerOperate manager,Employer account){
      this.manager=manager;
      this.account=account;
      
      title=new Label("帐户存款");
      lab=new Label("请输入存款金额");
      saveCash=new TextField(12);
      enter=new Button("确定");
      back=new Button("返回");
      
      setSize(300,300);
      setBackground(Color.lightGray);
      setLocation(200,200);
      setLayout(new GridLayout(3,1));
      
      Container con0=new Container();
      con0.setLayout(new FlowLayout());
      Font font=new Font("Arial",Font.BOLD,24);
      con0.setFont(font);
      con0.add(title);
      
      Container con1=new Container();
      con1.setLayout(new FlowLayout());
      con1.add(lab);
      con1.add(saveCash);
      
      Container con2=new Container();
      con2.setLayout(new FlowLayout());
      con2.add(enter);
      con2.add(back);
      
      add(con0);
      add(con1);
      add(con2);
      
      back.addActionListener(this);
      enter.addActionListener(this);
      
      setVisible(true);
   }
   
   public void actionPerformed(ActionEvent ae){
      String command=(String)ae.getActionCommand();
      if(command=="返回"){
         setVisible(false);
         new operateUser(manager,account);

      }
      if(command=="确定"){
         setVisible(false);
         boolean b=isNumber.isNum(saveCash.getText());
         if(b==false){
            new inputError2(manager,account);
         }
         else{
            float money=Float.parseFloat(saveCash.getText());
            if(money<=0){
               new saveError(manager,account);
            }
            else{
               account.save(money);
               new saveOver(manager,account);
            }
         }
      }
   }
}

class saveOver extends Frame implements ActionListener{
   Label lab;
   Button back;
   ManagerOperate manager;
   Employer account;
   
   public saveOver(ManagerOperate manager,Employer account){
      this.manager=manager;
      this.account=account;
      
      lab=new Label("存款成功!!");
      back=new Button("返回");
      
      setSize(300,150);
      setBackground(Color.lightGray);
      setLocation(200,200);
      setLayout(new GridLayout(2,1));
      
      Container con0=new Container();
      con0.setLayout(new FlowLayout());
      Font font=new Font("Arial",Font.BOLD,24);
      con0.setFont(font);
      con0.add(lab);
      
      Container con1=new Container();
      con1.setLayout(new FlowLayout());
      con1.add(back);
      
      add(con0);
      add(con1);
      
      back.addActionListener(this);
      
      setVisible(true);
   }
   
   
   public void actionPerformed(ActionEvent ae){
      String command=(String)ae.getActionCommand();
      if(command=="返回"){
         setVisible(false);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -