By GokiSoft.com| 14:05 08/05/2020|
Java Advanced

Mini Project - Phân tích dự án + Phát triển phần mềm ATM BT1299

Mini Project - Phân tích dự án + Phát triển phần mềm ATM

Thực hiện phân tích thiết kế chương trình ATM với các chức năng chính sau

- Chức năng đăng nhập

- Chức năng quản lý tài khoản > quản lý số dư, lịch sử rút tiền + lịch sử chuyển tiền

- Viết chức năng rút tiền

- Viết chức năng chuyển tiền

Chương trình : Code bàng Java Console hoặc Java Swing

Dữ liệu lưu vào CSDL.

Liên kết rút gọn:

https://gokisoft.com/1299

Bình luận

avatar
Minh Nghia [T1907A]
2020-05-11 08:39:12



- giao diện đăng nhập :
 + chức năng quên mk , lấy 
 + ng dùng -> đăng nhập user pass -> login giao diện quản lí tài khoản
- Giao diện quản lí tài khoản gồm :
 + Tổng số tiền, stk,tên ng dùng
 +  các chức năng : chuyển tiền ,lịch sử rút tiền , lịch sử chuyển tiền
    + chức năng rút tiền -> giao diện 
	+ số tiền rút , số tiền dư , stk, tên ng dùng, sdt -> button thực hiện ( tối đa 5tr 1 lần và 30tr 1 ngay)
    + chức năng chuyển tiền => giao diện
	+ 2 lựa chọn trong ngân hàng và liên ngân hàng 
		+ trong ngân hàng -> 
			ng chuyển : stk, tên ng chuyển,số dư
			Ng nhận : stk ng nhân , nhập số tiền , nội dung thông điêp 
				-> 1 button thực hiện -> bắt nhập mã OTP
		+ liên ngân hàng ->
			ng chuyển : stk , tên ng chuyển , số dư
			ng nhận : chọn ngân hàng , stk ng nhận,số tiền ,nọi dung 
				-> 1 button thực hiện -> bắt nhập mã OTP



/*
 * 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 ATM;

import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class ATM_Transaction {
    static Scanner scan = new Scanner(System.in);
    public static void main(String[] args) {
        login();
        int balance = 7000  , withdraw, deposit;
        int choose;
        
        do{
            menu();
            choose = Integer.parseInt(scan.nextLine());
            switch(choose){
                case 1:
                    System.out.println("Enter money to be withdraw :");
                    withdraw = Integer.parseInt(scan.nextLine());
                    if(balance >= withdraw){
                        balance = balance - withdraw;
                        System.out.println("Successfull withdraw !! ");
                    }else{
                        System.out.println("Insufficient Balance");
                    }
                    break;
                case 2:
                    System.out.print("Enter money to be deposited:");
                    deposit = Integer.parseInt(scan.nextLine());
                    balance = balance + deposit;
                    System.out.println("Your Money has been successfully depsited");
                    break;
                case 3:
                    System.out.println("Current balance in the account" +balance);
                    
                    break;
                case 4:
                    System.out.println("Exit ");
                    break;
                default:
                    System.out.println("Input failed !!!");
                    break;
                            
            }
        }while(choose != 4);
        
    }
    public static void login(){
        System.out.println("Enter Account");
        System.out.println("User name :");
        String username = scan.nextLine();
        
        System.out.println("Password :");
        String password = scan.nextLine();
        
        if(username.equals("aptech") || (password.equals("aptech123"))){
            System.out.println("Login succesfull !!!");
        }else{
            System.out.println("Login failed !!!");
            login();
        }
    }
    public static void menu(){
        System.out.println("Automated Teller Machine");
            System.out.println("1. Withdraw");
            System.out.println("2. Deposit");
            System.out.println("3. Check Balance");
            System.out.println("4.  EXIT");
            System.out.print("Choose the operation you want to perform:");
    }
}


avatar
NguyenHuuThanh [T1907A]
2020-05-11 06:06:29



/*
 * 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 atm;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

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

    /**
     * Creates new form Chuyentien
     */
    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")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        btnLogin = new javax.swing.JButton();
        txtAccountID = new javax.swing.JTextField();
        txtPassword = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setText("AccountID");

        jLabel2.setText("Password");

        btnLogin.setText("Login");
        btnLogin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLoginActionPerformed(evt);
            }
        });

        txtAccountID.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtAccountIDActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(jLabel1))
                .addGap(104, 104, 104)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(btnLogin)
                    .addComponent(txtPassword, javax.swing.GroupLayout.DEFAULT_SIZE, 207, Short.MAX_VALUE)
                    .addComponent(txtAccountID))
                .addContainerGap(16, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txtAccountID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(55, 55, 55)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 86, Short.MAX_VALUE)
                .addComponent(btnLogin)
                .addGap(56, 56, 56))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 20, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>                        

    private void txtAccountIDActionPerformed(java.awt.event.ActionEvent evt) {                                             
        // TODO add your handling code here:
    }                                            

    private void btnLoginActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
        
        String accountID = txtAccountID.getText();
        String password01  = txtPassword.getText();
        
        Connection connection = null ;
        Statement statement   = null ;
        
        try {
            connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/account?serverTimezone=UTC", "root", "");
            
            String sql = " select accountID , password from account where accountID = '" + accountID +"'";
            
            statement = connection.createStatement();
            
            ResultSet resultSet = statement.executeQuery(sql);
            
            if (password01.equals(resultSet.getString("password")))
            {
                JOptionPane.showMessageDialog(rootPane, " Login successfully ");
                Ruttien ruttien = new Ruttien();
                
                ruttien.setVisible(true);
            }
            else 
            {
                JOptionPane.showMessageDialog(rootPane , " Not existed ");
            }
        } catch (SQLException ex) {
            Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
        }finally
        {
            if ( statement != null)
            {
                try {
                    statement.close();
                } catch (SQLException ex) {
                    Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
            
            if ( connection != null)
            {
                try {
                    connection.close();
                } catch (SQLException ex) {
                    Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
        
        
        
        
           
    }                                        

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* 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);
        }
        //</editor-fold>
        //</editor-fold>

        /* 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.JButton btnLogin;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField txtAccountID;
    private javax.swing.JTextField txtPassword;
    // 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 atm;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/**
 *
 * @author abc
 */
public class Ruttien extends javax.swing.JFrame {

    /**
     * Creates new form Chuyentien
     */
    public Ruttien() {
        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")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        txtAmount = new javax.swing.JTextField();
        btnRuttien = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        txtAccountID = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setText("Amount");

        btnRuttien.setText("Ruttien");
        btnRuttien.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRuttienActionPerformed(evt);
            }
        });

        jLabel2.setText("AccountID");

        txtAccountID.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtAccountIDActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(39, 39, 39)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel2)
                    .addComponent(jLabel1))
                .addGap(58, 58, 58)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(btnRuttien)
                    .addComponent(txtAmount)
                    .addComponent(txtAccountID, javax.swing.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE))
                .addContainerGap(41, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(58, 58, 58)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txtAmount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(25, 25, 25)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtAccountID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 73, Short.MAX_VALUE)
                .addComponent(btnRuttien)
                .addGap(56, 56, 56))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 25, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>                        

    private void btnRuttienActionPerformed(java.awt.event.ActionEvent evt) {                                           
        // TODO add your handling code here:
        Float amount01 = Float.parseFloat(txtAmount.getText());
        String account = txtAccountID.getText();
        Connection connection =  null ;
        Statement statement   = null ;
        
        try {
            connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/amount?serverTimezone=UTC", "root", "");
            
            String sql = " select amount from account where accountID = '" + account + "' ";
            
            statement = connection.createStatement();
            
            ResultSet resultSet = statement.executeQuery(sql);
            
            if ( amount01 >= resultSet.getFloat("amount"))
            {
                JOptionPane.showMessageDialog(rootPane, " Successfully");
            }
            else
            {
                JOptionPane.showMessageDialog(rootPane, " Failed ");
            }
        } catch (SQLException ex) {
            Logger.getLogger(Ruttien.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        
    }                                          

    private void txtAccountIDActionPerformed(java.awt.event.ActionEvent evt) {                                             
        // TODO add your handling code here:
    }                                            

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* 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(Ruttien.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Ruttien.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Ruttien.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Ruttien.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
        //</editor-fold>

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

    // Variables declaration - do not modify                     
    private javax.swing.JButton btnRuttien;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField txtAccountID;
    private javax.swing.JTextField txtAmount;
    // End of variables declaration                   
}



avatar
Đường Thanh Bình [T1907A]
2020-05-08 10:29:37



phân tích dự án ATM
- đối với khách hàng , người dùng :
  +rút tiền: khách hàng đăng nhập tài khoản  sau đó ấn rút tiền hiện ra 6 mệnh giá theo quy định của hệ thống
khách hàng chọn và thực hiện chức năng rút tiền hệ thống sẽ xử lý và thông báo kết quả giao dịch
  + gửi tiền: đăng nhập vào tài khoản và sử dụng chức năng gửi tiền khách hàng nhập số tiền muốn gửi và thực hiện chức năng rút tiền
hệ thống sẽ xử lý và gửi thông báo kết quả giao dịch 
  + chuyển tiền : vào tài khoản  và sử dụng chức năng chuyển tiền, nhập mã tài khoản cần chuyển và số tiền muốn chuyển sau đó ấn hoàn thành hệ thống sẽ xử lý và gửi thông kết quả giao dịch
  + đổi mã pin : ng dùng thực hiện chức năng đổi mã pin , hệ thống hiện nhập mã pin cũ và nhập mã pin ng dùng muốn đổi và xác nhận lại  hệ thống sec thông báo kết quả 
  + xem thông tin ng dùng : tài khoản sử dụng chức năng xem thông tin , hệ thống sẽ hiện lịch sử giao dịch và số dư tài khoản 
ng dùng có thể xem thông tin giao dịch và số dư tài khoản hiện có 
  + in sao kê : sau mỗi lần giao dịch rút tiền hay gửi tiền hệ thống tự lưu lịch sử giao dịch dưới hình dạng như một hóa đơn
ng dùng có thể in 
- đối với ng quản trị 
 + chức năng quản lý tài khoản quản trị :thêm xóa hoặc đóng mở tài khoản quản trị có thể thay đổi thông tin tài khoản quản trị
thay đổi mật khẩu tài khoản quản trị chức năng tìm kiếm theo họ tên
 + Người quản trị sẽ có quyền thêm, sửa, đóng hoặc mở lại tài khoản đã đăng kí. Người quản trị cũng có quyền quản lý giao dịch của các khách hàng đã đăng kí tài khoản. Chức năng quản lý giao dịch bao gồm gửi tiền, rút tiền và chuyển khoản. Ngoài ra người quản trị còn có chức năng tìm kiếm theo số tài khoản hoặc tên chủ tài khoản, và xem chi tiết giao dịch của từng khách hàng
 + chức năng thống kê các giao dịch có thể xem lịch sử các giao dịch của khách hàng tìm theo số tài khoản và tên chủ tài khoản


avatar
Đường Thanh Bình [T1907A]
2020-05-08 10:29:07

nhóm: Đường Thanh Bình, Phan Bạch Tùng Dương, Phạm Ngọc Minh, Trần Anh Quân, Đỗ Tuấn Anh.

/*
 * 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 testAtm;

import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class Main {
    public static void main(String[] args) {
        System.out.println("Welcome to ATM Application");
        Scanner sc = new Scanner(System.in);
        Account acc1 = newAccount(1, "123abc", 1000000, "Unknown Account 1");
        

        String choice = "y";
        while (choice.equalsIgnoreCase("y")) {
            System.out.println("Select your action: ");
            System.out.println("1-Login");
            System.out.println("2-View Account information");
            System.out.println("3-Withdraw");
            System.out.println("4-Transfer");

            int action = sc.nextInt();
            switch (action) {
                case 1:
                    if (login(acc1)) {
                        System.out.println("Login success");
                    } else {
                        System.out.println("Login fail");
                    }
                    break;
                case 2:
                    viewAccount(acc1);
                    break;
                case 3:
                    if (withdraw(acc1)) {
                        System.out.println("Withdraw success");
                    } else {
                        System.out.println("Login Fail");
                    }
                    break;
                case 4:
                    Account acc2 = newAccount(2, "12345", 50, "Unknown Account 21"
                            + "");
                    if (transfer(acc1, acc2)) {
                        System.out.println("Transfer success");
                    } else {
                        System.out.println("Transfer fail");
                    }
                    break;
                default:
                    System.out.println("Invalid operation");
                    break;
            }
            System.out.println("Continue? (Y/N)");
            choice = sc.next();
            System.out.println();

        }
    }

    public static boolean transfer(Account acc1, Account acc2) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Please enter your amount to transfer:");
        double amount = sc.nextDouble();
        return acc1.withdraw(amount) && acc2.depost(amount);
    }

    public static void viewAccount(Account acc) {
        System.out.println("Account Number: " + acc.getAccountNo());
        System.out.println("Account Name: " + acc.getCustomerName());
        System.out.println("Amount: " + acc.getAmount());
    }

    public static boolean withdraw(Account acc) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Please enter your amount to withdraw:");
        double amount = sc.nextDouble();
        return acc.withdraw(amount);
    }

    public static boolean login(Account acc) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter your account number:");
        int accNo = sc.nextInt();
        System.out.print("Enter your password:");
        String pass = sc.next();
        return acc.checkLogin(accNo, pass);
    }

    public static Account newAccount(int accNo, String pass, double amount, String custName) {
        Account acc = new Account();
        acc.setAccountNo(accNo);
        acc.setPassword(pass);
        acc.setAmount(amount);
        acc.setCustomerName(custName);
        return acc;
    }
    
}



/*
 * 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 testAtm;

/**
 *
 * @author Administrator
 */
public class Account {
    private int accountNo;
    private String password;
    private double amount;
    private String customerName;

    public Account() {
        accountNo = 0;
        password = "";
        amount = 0;
        customerName = "";
    }

    public void setAccountNo(int accNo) {
        this.accountNo = accNo;
    }

    public int getAccountNo() {
        return this.accountNo;
    }

    public void setPassword(String pass) {
        this.password = pass;
    }

    public String getPassword() {
        return this.password;
    }

    public void setAmount(double amount) {
        this.amount = amount;
    }

    public double getAmount() {
        return this.amount;
    }

    public void setCustomerName(String custName) {
        this.customerName = custName;
    }

    public String getCustomerName() {
        return this.customerName;
    }

    public boolean checkLogin(int accNo, String pass) {
        return accNo == accountNo && pass.equals(password);
    }

    public boolean withdraw(double amount) {
        if (amount < this.amount) {
            this.amount -= amount;
            return true;
        } else {
            return false;
        }
    }

    public boolean depost(double amount) {
        if (amount > 0) {
            this.amount += amount;
            return true;
        } else {
            return false;
        }
    }
    
}


avatar
Trần Mạnh Dũng [T1907A]
2020-05-08 10:06:47

https://docs.google.com/spreadsheets/d/11xwGyy-qPX22hmb9AfJ7OC626TuJ6UNP1x6A8hsU6oE/edit?usp=sharing

#Login.java


/*
 * 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 atmtest;

/**
 *
 * @author admin
 */
public class Login {
    String acc,pass;
    int sodu;

    public int getSodu() {
        return sodu;
    }

    public void setSodu(int sodu) {
        this.sodu = sodu;
    }

    public Login(String acc, String pass, int sodu) {
        this.acc = acc;
        this.pass = pass;
        this.sodu = sodu;
    }
    public Login(String acc, String pass) {
        this.acc = acc;
        this.pass = pass;
    }

    public String getAcc() {
        return acc;
    }

    public void setAcc(String acc) {
        this.acc = acc;
    }

    public String getPass() {
        return pass;
    }

    public void setPass(String pass) {
        this.pass = pass;
    }

    public Login() {
    }
    
}


#Atmtest.java


/*
 * 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 atmtest;

import java.util.List;
import java.util.Scanner;

/**
 *
 * @author admin
 */
public class Atmtest {

    static List<Login> list = loginATMModify.findAll();
    static Scanner s = new Scanner(System.in);
    static int sodu ;
    public static void main(String args[]) {
        int  sotienrut, sotienchuyen;
        
        login();
         
        while (true) {
            System.out.println("K-ATM");
            System.out.println("1. Rút tiền");
            System.out.println("2. Chuyển tiền");
            System.out.println("3. Kiểm tra số dư");
            System.out.println("4. Thoát");
            System.out.print("Chọn: ");
            int n = s.nextInt();
            switch (n) {
                case 1:
                    System.out.print("Nhập số tiền cần rút:");
                    sotienrut = s.nextInt();
                    if (sodu >= sotienrut) {
                        sodu = sodu - sotienrut;
                        System.out.println("Rút tiền thành công!");
                        System.out.println("Số tiền còn lại trong tài khoản: " + sodu);
                    } else {
                        System.out.println("Số dư trong tài khoản không đủ");
                    }
                    System.out.println("");
                    break;

                case 2:
                    System.out.print("Nhập số tiền cần chuyển:");
                    sotienchuyen = s.nextInt();
                    sodu = sodu + sotienchuyen;
                    System.out.println("Chuyển tiền thành công");
                    System.out.println("");
                    break;

                case 3:
                    System.out.println("Số dư trong tài khoản : " + sodu);
                    System.out.println("");
                    break;

                case 4:
                    System.exit(0);
                    System.out.println("Cám ơn đã giao dịch!");
            }
        }
    }

    public static void login() {
        System.out.println("Đăng Nhập");
        for (Login login : list) {
            while (true) {
                System.out.print("Số tài khoản: ");
                String stk = s.nextLine();
                if (!login.getAcc().contains(stk)) {
                    System.err.println("Số tài khoản không tồn tại");
                } else {

                    while (true) {
                        System.out.print("Mật khẩu: ");
                        String mk = s.nextLine();
                        if (login.getPass().equals(mk)) {
                            System.out.println("");
                            break;
                        } else {
                            System.err.println("Sai mật khẩu");
                        }

                    }
                    break;
                }

            }
           sodu = login.getSodu();
        }

    }
}


#loginATMModify.java


/*
 * 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 atmtest;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;



/**
 *
 * @author admin
 */
public class loginATMModify {
    public static List<Login> findAll(){
        List<Login> list = new ArrayList<>();
        Connection conn  = null;
        Statement statement = null;
        try {
            conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/atm?serverTimezone=UTC", "root", "");
            
            String sql = "select * from acc";
            
            statement = conn.createStatement();
            ResultSet resultSet = statement.executeQuery(sql);
            while (resultSet.next()) {                
                Login login = new Login(resultSet.getString("acc"), resultSet.getString("pass"), resultSet.getInt("sodu"));
                list.add(login);
            }
        } catch (SQLException ex) {
            Logger.getLogger(loginATMModify.class.getName()).log(Level.SEVERE, null, ex);
        }finally{
            if (statement != null) {
                try {
                    statement.close();
                } catch (SQLException ex) {
                    Logger.getLogger(loginATMModify.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
            if (conn != null) {
                try {
                    conn.close();
                } catch (SQLException ex) {
                    Logger.getLogger(loginATMModify.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
        
        
        return list;
    }
}


create table acc (
acc varchar(20) primary key,
pass varchar(20),
sodu int
)


avatar
hoangduyminh [T1907A]
2020-05-08 09:14:50



/*
 * 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 lesson7;

import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Scanner;

/**
 *
 * @author Minh
 */
public class ATM {
    public static void main(String[] args) {
      Account checking = new Account();
		checking.setType("Kiem Tra");
		checking.setBalance(0.00);
		checking.setRate(0.00);

		Account savings = new Account();
		savings.setType("Tien Tiet Kiem");
		savings.setBalance(0.00);
		savings.setRate(2.00);

		NumberFormat formatter = NumberFormat.getCurrencyInstance();
		Scanner sc = new Scanner(System.in); 

		boolean session = true; 

		while (session) {

			System.out.print("\nATM Menu: \n \n"
							 + "1. Gui Tien \n"
							 + "2. Rut Tien \n"
							 + "3. Chuyen Tien \n"
							 + "4. Kiem Tra So du trong tai khoan\n"
							 + "5. Kiet Thuc\n \n"
							 + "Lua chon: ");

			int selection = sc.nextInt();

			switch (selection) {


				case 1:
					System.out.print("Nhập (1) Kiem Tra (2) để Gửi Tiền: ");
					int depAccount = sc.nextInt(); 

					if (depAccount == 1) {

						System.out.println("\nSố dư Tiết kiệm hiện tại của bạn là: " + formatter.format(savings.getBalance()) + "\n");

						System.out.println("Bạn muốn gửi bao nhiêu tiền?");
						double deposit = sc.nextDouble();

						savings.deposit(deposit);

						System.out.println("\n Số dư Tiết kiệm của bạn hiện là: " + formatter.format(savings.getBalance()) + "\n");
						

					}

					else if (depAccount == 2) {
						
						System.out.println("\nSố dư kiểm tra hiện tại của bạn là: " + formatter.format(checking.getBalance()) + "\n");

						System.out.println("Bạn muốn gửi bao nhiêu tiền?");
						double deposit = sc.nextDouble();

						checking.deposit(deposit);

						System.out.println("\nKiểm tra số dư hiện tại: " + formatter.format(checking.getBalance()) + "\n");

					}

					break;

				case 2:
					System.out.print("\nNhập (1) Kiểm Tra hoặc (2) để Gửi TIền: ");
					int witAccount = sc.nextInt(); 

					if (witAccount == 1) {

						System.out.println("\nSố dư tiết kiệm hiện tại của bạn là: " + formatter.format(savings.getBalance()) + "\n");

						System.out.println("Bạn muốn rút bao nhiêu tiền?");
						double withdraw = sc.nextDouble();

						savings.withdraw(withdraw);

						System.out.println("\nSố dư tiết kiệm của bạn hiện đang: " + formatter.format(savings.getBalance()) + "\n");
						

					}

					else if (witAccount == 2) {
						
						System.out.println("\nSố dư Kiểm tra hiện tại của bạn là: " + formatter.format(checking.getBalance()) + "\n");

						System.out.println("Bạn muốn rút bao nhiêu tiền?");
						double withdraw = sc.nextDouble();

						checking.withdraw(withdraw);

						System.out.println("\nBạn muốn rút bao nhiêu tiền? " + formatter.format(checking.getBalance()) + "\n");

					}

					break;

				// case 3 handles the transfer of funds	

				case 3:
					System.out.print("\nBạn muốn chuyển tiền từ tài khoản nào?, (1) cho Kiem Tra hoặc (2) để Chuyển Tiền: ");
					int tranAccount = sc.nextInt();

					if (tranAccount == 1) {

						System.out.println("\nSố dư tiết kiệm hiện tại của bạn là: " + formatter.format(savings.getBalance()) + "\n");

						System.out.print("Bạn muốn chuyển bao nhiêu tiền từ Tiết kiệm sang Kiểm tra?: ");
						double tranAmount = sc.nextDouble();

						savings.withdraw(tranAmount);
						checking.deposit(tranAmount);

						System.out.println("\nBạn đã chuyển thành công " + formatter.format(tranAmount) + " từ tiết kiệm đến kiểm tra");

						System.out.println("\nKiểm tra số dư: " + formatter.format(checking.getBalance()));
						System.out.println("Số dư tiết kiệm: " + formatter.format(savings.getBalance()) + "\n");

					}

					else if (tranAccount == 2) {

						System.out.println("\nSố dư kiểm tra hiện tại của bạn là: " + formatter.format(checking.getBalance()) + "\n");

						System.out.print("Bạn muốn chuyển bao nhiêu tiền từ Số Dư sang Tiết kiệm?: ");
						double tranAmount = sc.nextDouble();

						checking.withdraw(tranAmount);
						savings.deposit(tranAmount);

						System.out.println("\nBạn đã chuyển thành công " + formatter.format(tranAmount) + " từ kiểm tra đến tiết kiệm");

						System.out.println("\nKiem Tra so du : " + formatter.format(checking.getBalance()));
						System.out.println("kiem tra tien tiet kiem: " + formatter.format(savings.getBalance()) + "\n");
						
					}

					break;	
				
				case 4:
					System.out.println("\nKiem Tra So Du: " + formatter.format(checking.getBalance()));
					System.out.println("Kiem Tra Tien Tiet Kiem: " + formatter.format(savings.getBalance()) + "\n");
					
					break;

				case 5:
					session = false;
					
					break;

			}				 	
			

		}

		System.out.println("\nCảm ơn bạn đã giao dịch với chúng tôi!\n");

	}

}



/*
 * 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 lesson7;

/**
 *
 * @author Minh
 */
public class Account {

	String type;
	double balance;
	double rate;

	void setType(String accType) {
		
		type = accType;
	}

	void setBalance(double accBal) {
		
		balance = accBal;
	}

	void setRate(double accRate) {
		
		rate = accRate;
	}

	void deposit(double dep) {
		
		balance += dep; 
	}

	void withdraw(double wit) {
		
		balance -= wit;
	}


	String getType() {
		
		return type;
	}

	double getBalance() {
		
		return balance;
	}

	double getRate() {
		
		return rate;
	}

   }




Người Dùng :
            + Xem Được Lịch Sử Giao Dich.
            + Số Dư Còn Lại Trong tài khoản
            + Dịch Vụ (Chuyển Tiền Nội Bộ,Lien Ngân Hàng,Rút Tiền,Dat ve may bay .....);
            + Lịch Sử Rút tiền;
Quản Lý Tài Khoản : 
              + Xem Được Lịch Sử Giao Dịch Của Người Dùng;
              + Cung Cấp Mã Pin Giao Dịch
              + Xem Thống kê giao dich của từng khách hàng
 Chức Năng 
     Người Dùng : 
                 +Đăng Nhập (Tai Khoản, Mật khẩu);
                 + Đăng Xuât
                 + Rut Tien tu tai khoan(Lựa Chon Mệnh Gía Giao Dich):Nhập số tiền cần rút;
                 + Chuyển Khoản(Chuyển nội bộ , liên ngân hàng,rút tiền....):Nhập số tiền cần chuyển khoản;
                 + Đổi Mật Khẩu
                 + In Sao Kê;
                 + Tim Kiếm lịch sử giao dich( Theo ngày tháng năm);

     Quan Ly Tai Khoản :
                 + Thêm, Sửa, Xóa, Đóng ,Mở tài khoản ngân hàng
                 + Quản Lý Giao Dịch Của Khách Hàng:(Gửi Tiền,Rút Tiền và chuyển khoản)
                 + Tìm Kiếm (Số tài khoản,tên chủ tài khoản) và xem chi tiết giao dịch của từng khách hàng
                 + Thống kê (Toàn Bộ giao dịch của khách hàng): Gửi tiền vào tài khảon
                                                                + Rút tiền từ tài khoản
                                                                + Chuyển Tiền (Nội Bộ , Liên Ngân Hàng);