Java期末课程设计——ATM柜员机模拟系统


目录

一、设计要求

二、截图

三、设计思路

四、项目结构截图

五、使用说明

六、部分代码

七、资源链接


一、设计要求

       使用图形用户界面。当输入给定的卡号和密码(初始卡号和密码为123456)时,系统能登录ATM柜员机系统,用户可以按照以下规则进行:

       1)查询余额:初始余额为10000元

       2)ATM取款:每次取款金额为100的倍数,总额不超过5000元,支取金额不允许透支。

       3)ATM存款:不能出现负存款。

       4)修改密码:新密码长度不小于6位,不允许出现6位完全相同的情况,只有旧密码正确,新密码符合要求,且两次输入相同的情况下才可以成功修改密码。

      5)使用数据库保存数据

二、截图

Java期末课程设计——ATM柜员机模拟系统_第1张图片                      Java期末课程设计——ATM柜员机模拟系统_第2张图片

Java期末课程设计——ATM柜员机模拟系统_第3张图片                   Java期末课程设计——ATM柜员机模拟系统_第4张图片

Java期末课程设计——ATM柜员机模拟系统_第5张图片                Java期末课程设计——ATM柜员机模拟系统_第6张图片

Java期末课程设计——ATM柜员机模拟系统_第7张图片            Java期末课程设计——ATM柜员机模拟系统_第8张图片 

三、设计思路

       整体项目分为页面、vo用户类、dao层、action类

      1)页面分为:登录页、菜单主页、余额查询、转账、密码修改、存款、自定义存款、取款。页面使用NetBeans拖拽成。

      2)vo用户类包含用户名、密码、账户余额

      3)dao采用JDBC链接数据库,设计对用户信息的操作,包括:通过账号查找用户、密码修改、余额修改

      4)action类负责响应页面中的点击事件,并反馈结果

四、项目结构截图

Java期末课程设计——ATM柜员机模拟系统_第9张图片

五、使用说明

项目采用NetBeans搭建。可以自己下载相应Jar包将文件导入Eclipse中。

六、部分代码

登录页:

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package team.fzn.atm.frame;

import javax.swing.JOptionPane;
import team.fzn.atm.action.AtmAction;

/**
 *
 * @author 23944
 */
public class Login extends javax.swing.JFrame {

    /**
     * Creates new form Login
     */
    public Login() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    //                           
    private void initComponents() {

        title = new javax.swing.JLabel();
        bankCard = new javax.swing.JLabel();
        passwd = new javax.swing.JLabel();
        bankCardTxt = new javax.swing.JTextField();
        passwdTxt = new javax.swing.JPasswordField();
        loginButton = new javax.swing.JButton();
        resetButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("ATM");

        title.setFont(new java.awt.Font("宋体", 0, 36)); // NOI18N
        title.setText("   ATM模拟器");

        bankCard.setText("银行卡号:");

        passwd.setText("密码:");

        loginButton.setText("确认");
        loginButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                loginButtonMouseClicked(evt);
            }
        });

        resetButton.setText("清除");
        resetButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                resetButtonMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(151, 151, 151)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(loginButton, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 126, Short.MAX_VALUE)
                        .addComponent(resetButton, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(bankCard, javax.swing.GroupLayout.DEFAULT_SIZE, 88, Short.MAX_VALUE)
                            .addComponent(passwd, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(bankCardTxt)
                            .addComponent(passwdTxt)
                            .addComponent(title, javax.swing.GroupLayout.DEFAULT_SIZE, 373, Short.MAX_VALUE))))
                .addContainerGap(158, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(39, 39, 39)
                .addComponent(title, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(57, 57, 57)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bankCard, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(bankCardTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(61, 61, 61)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(passwd)
                    .addComponent(passwdTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(77, 77, 77)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(loginButton)
                    .addComponent(resetButton))
                .addContainerGap(99, Short.MAX_VALUE))
        );

        pack();
    }//                         

    private void loginButtonMouseClicked(java.awt.event.MouseEvent evt) {                                         
        // TODO add your handling code here:
        AtmAction atmAction = new AtmAction();
        Boolean check = atmAction.login(bankCardTxt.getText(),passwdTxt.getText());
        if(check){
            this.dispose();
            new Menum().setVisible(true);
        }else{
            JOptionPane.showMessageDialog(null, "用户名或密码错误", "error", JOptionPane.ERROR_MESSAGE);
        }
    }                                        

    private void resetButtonMouseClicked(java.awt.event.MouseEvent evt) {                                         
        // TODO add your handling code here:
        bankCardTxt.setText("");
        passwdTxt.setText("");
    }                                        

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Login().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                     
    private javax.swing.JLabel bankCard;
    private javax.swing.JTextField bankCardTxt;
    private javax.swing.JButton loginButton;
    private javax.swing.JLabel passwd;
    private javax.swing.JPasswordField passwdTxt;
    private javax.swing.JButton resetButton;
    private javax.swing.JLabel title;
    // End of variables declaration                   
}

菜单页:

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package team.fzn.atm.frame;

/**
 *
 * @author 23944
 */
public class Menum extends javax.swing.JFrame {

    /**
     * Creates new form Menum
     */
    public Menum() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    //                           
    private void initComponents() {

        query = new javax.swing.JButton();
        transfer = new javax.swing.JButton();
        modify = new javax.swing.JButton();
        drawMoney = new javax.swing.JButton();
        saveMoney = new javax.swing.JButton();
        exit = new javax.swing.JButton();
        title = new javax.swing.JLabel();
        welcome = new javax.swing.JLabel();
        promot = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Menum");

        query.setText("查询");
        query.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                queryMouseClicked(evt);
            }
        });

        transfer.setText("转账");
        transfer.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                transferMouseClicked(evt);
            }
        });

        modify.setText("改密");
        modify.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                modifyMouseClicked(evt);
            }
        });

        drawMoney.setText("取款");
        drawMoney.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                drawMoneyMouseClicked(evt);
            }
        });

        saveMoney.setText("存款");
        saveMoney.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                saveMoneyMouseClicked(evt);
            }
        });

        exit.setText("退卡");
        exit.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                exitMouseClicked(evt);
            }
        });

        title.setFont(new java.awt.Font("宋体", 0, 36)); // NOI18N
        title.setText("请您选择服务");

        welcome.setFont(new java.awt.Font("宋体", 0, 24)); // NOI18N
        welcome.setText("欢迎使用ATM模拟系统");

        promot.setFont(new java.awt.Font("宋体", 0, 18)); // NOI18N
        promot.setText("如果您的密码是弱密码请及时修改");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(modify, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE)
                    .addComponent(transfer, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(query, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 159, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(title, javax.swing.GroupLayout.PREFERRED_SIZE, 230, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(exit, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(welcome)
                                .addGap(129, 129, 129)
                                .addComponent(drawMoney, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(promot)
                        .addGap(97, 97, 97)
                        .addComponent(saveMoney, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(89, 89, 89)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(query)
                            .addComponent(drawMoney))
                        .addGap(56, 56, 56)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(transfer)
                            .addComponent(saveMoney))
                        .addGap(45, 45, 45)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(modify)
                            .addComponent(exit)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(29, 29, 29)
                        .addComponent(title)
                        .addGap(38, 38, 38)
                        .addComponent(welcome)
                        .addGap(37, 37, 37)
                        .addComponent(promot, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(126, Short.MAX_VALUE))
        );

        pack();
    }//                         

    private void queryMouseClicked(java.awt.event.MouseEvent evt) {                                   
        // TODO add your handling code here:
        this.dispose();
        new Query().setVisible(true);
    }                                  

    private void transferMouseClicked(java.awt.event.MouseEvent evt) {                                      
        // TODO add your handling code here:
        this.dispose();
        new Transfer().setVisible(true);
    }                                     

    private void exitMouseClicked(java.awt.event.MouseEvent evt) {                                  
        // TODO add your handling code here:
        this.dispose();
    }                                 

    private void modifyMouseClicked(java.awt.event.MouseEvent evt) {                                    
        // TODO add your handling code here:
        this.dispose();
        new Modify().setVisible(true);
    }                                   

    private void saveMoneyMouseClicked(java.awt.event.MouseEvent evt) {                                       
        // TODO add your handling code here:
        this.dispose();
        new SaveMoney().setVisible(true);
    }                                      

    private void drawMoneyMouseClicked(java.awt.event.MouseEvent evt) {                                       
        // TODO add your handling code here:
        this.dispose();
        new DrawMoney().setVisible(true);
    }                                      


    // Variables declaration - do not modify                     
    private javax.swing.JButton drawMoney;
    private javax.swing.JButton exit;
    private javax.swing.JButton modify;
    private javax.swing.JLabel promot;
    private javax.swing.JButton query;
    private javax.swing.JButton saveMoney;
    private javax.swing.JLabel title;
    private javax.swing.JButton transfer;
    private javax.swing.JLabel welcome;
    // End of variables declaration                   
}

 

七、资源链接

https://download.csdn.net/download/weixin_43415275/12413034

你可能感兴趣的:(Java期末课程设计——ATM柜员机模拟系统)