当前位置:网站首页>ATM simulation system
ATM simulation system
2022-06-22 02:46:00 【Programmer ah Hong】
ATM Computer simulation system
Personal home page : Programmer a Hong
Stand by me : Like collection ️ Leaving a message.
Recommended articles : What time is it , You can't frame yet SSM Integrate
One 、 summary
(1) Topic analysis
(2) development environment
development environment , choice IDEA this Java Development software , be based on JDK1.8 edition , In this machine window Shangkaiben ATM Simulation program .
Two 、 Program outline design
(1) Function module design
After the analysis of the topic , Put the book ATM The simulation program is divided into two modules: administrator side and user mode . among , The administrator has the ability to query all accounts 、 Export all account information to file 、 Logout function . The user module has the function of querying the balance 、ATM Transfer accounts 、ATM deposit 、ATM Withdraw money 、 Change Password 、 Look up transactions 、 Export records 、 Card return and other functions .
The total functional module diagram of the system is as follows :

(2) flow chart
The overall process of the system is : The user can select administrator login or user mode login through the main interface , Then enter the account and password set by the system to log in . After successful login , Enter the corresponding main function page to perform relevant operations .
When the administrator logs in to the background , Determine whether the password and account number are correct , Log in if it is correct , Otherwise, the prompt fails . Log in to the background , You can view all user functions , Then the system will query all the set user information and output it to the console panel . Click the export record function , All account information will be output to the current jar Under the same level directory of the program txt file .
When the user logs in , Determine whether the account password is correct , Incorrect , Then the number of account errors +1, When the number reaches 3 when , The account will be locked , Can not login . When the entered account secret is correct , Determine whether the account is locked , Log in without locking , Jump to the main user interface , And perform relevant operation functions .
The flow chart of the administrator module is as follows :

The general flow chart of the user module is as follows :

(3) File structure and class design
Ben ATM The simulator uses idea Edit software development . The project is divided into admin( Administrators )、customer( user )、data(ATM data ) Three bags .
among admin Under the package AdminManage class , Responsible for initializing the administrator interface , At the same time, all functions of the administrator are realized .Customer Under bag customer Class implements the interface of the user module , Relevant operation buttons are defined , And realize their respective monitoring functions , In order to reduce the interface design , The output information panel is used in the middle of the user interface , The result of this function will be printed in the panel , Simulated atm Machine interface information .
Data There are... Under the bag ATMData class 、Card Classes and CustomerAccount class .Card Class is the code embodiment of the user's bank card , Encapsulate the relevant information of the bank card into a basic Java object , accord with Java Object oriented features . among customerAccount yes card Subclasses of classes , stay card On the basis of , Added a lot of user behavior , For example, deposits 、 Withdraw money 、 Check the balance, etc .ATMData Class is a very important class in this program , It encapsulates all the initial account information of the program , And money transfer 、 Get all accounts 、 Login, etc . This design , Data processing can be separated from interface design , Avoid too much code in the user interface .
The file structure is as follows , among resource The picture information required by this program is stored in the folder :

3、 ... and 、 Detailed program design
The functional modules of the system are not detailed here , Several main functions are listed for description :
(1) Withdrawal function
The code of the withdrawal function is designed in customerAccount Class , The input parameter is the withdrawal amount . First determine whether the amount is 100 Multiple , Then judge whether it is greater than 5000( The title requires that a single withdrawal should not be greater than 5000), Then judge whether the balance of the current account is greater than or equal to the amount obtained . When these conditions are met , Recalculate the amount of the current account , And add the withdrawal record to the transaction record of the current account .
The core code logic is as follows :
if (money % 100 != 0) {
return false;
}
if (money > 5000) {
return false;
}
int currentMoney = getMoney();
if (currentMoney < money) {
return false;
}
// Withdraw money
int result = currentMoney - money;
setMoney(result);
// Add transaction
List<String> operationRecod = getOperationRecod();
operationRecod.add("【" + LocalDateTime.now().format(dateTimeFormatter) + "】 ATM Withdraw money [" + money + "] element , Current balance [" + result + "] element ");
(2) Deposit function
The method parameter is the deposited amount , First, judge whether the amount is 100 Multiple , If the verification is passed, the balance of the current account will be recalculated , Then add transactions to the current account .
The core code logic is as follows :
if (money % 100 != 0) {
return false;
}
// balance
int countMoney = getMoney() + money;
setMoney(countMoney);
// Record transactions
List<String> operationRecod = getOperationRecod();
operationRecod.add("【" + LocalDateTime.now().format(dateTimeFormatter) + "】 ATM deposit [" + money + "] element , Current balance [" + countMoney + "] element ");
return true;
(3) User login function
The input parameters of the user login method are account and password , First, determine whether the account exists , Match all accounts set in the participating system , without , The failure . If yes, judge whether the account is locked , Locked and unable to log in , If it is not locked, judge whether the password is correct , If it is not correct, the number of errors in the current account will be +1( If the number of account errors =3, Lock the account ). If the password is correct, log in and jump to the main interface .
The core code is as follows :
// Whether there is an account number
if (allAccount.containsKey(number)) {
CustomerAccount account = allAccount.get(number);
// Determine whether the account is locked
if (account.getErrorCount() >= 3) {
JOptionPane.showMessageDialog(null, " Login failed ! The account is suspected to have been locked ", " Prompt message ", JOptionPane.WARNING_MESSAGE);
return null;
// Is the password consistent
} else if (account.getPassword().equals(pwd)) {
// Number of reset errors
account.setErrorCount(0);
return account;
}
account.setErrorCount(account.getErrorCount() + 1);
if (account.getErrorCount() >= 3) {
// Lock account
account.setStatus(1);
}
} else {
// Prompt error message
JOptionPane.showMessageDialog(null, " Login failed ! Wrong card number or password ", " Prompt message ", JOptionPane.WARNING_MESSAGE);
}
Four 、 Program demonstration
Most functions , Don't record here one by one . Only tests for several main functions are recorded here .
(1) ATM Withdraw money
The test withdrawal function is shown in the figure below . The initial amount is 10000 element . Separate withdrawals 3000、6000、5000. The last two are error data . A single withdrawal cannot exceed 5000 element , The latter is the balance 3000 Withdrawal on time 5000, Test that the withdrawal cannot be overdrawn .
test result :




Thus we can see that , The function is normal , The test results of both legal and illegal data input are consistent with the expectations .
(2) ATM Transfer accounts
Transfer test , The target account must exist , At the same time, the balance should be greater than the amount to be transferred , You can't overdraft . Test data for entering a nonexistent account 、 And the transfer amount greater than the current balance .
Enter the test result of non-existent account as follows :

Enter the normal account and amount test results as follows , Log in to the target account , Query the transaction records to see that the transfer has successfully reached the target account .


Enter incorrect data greater than the current balance , The test results are as follows , The transfer function test is normal .

(3) Change Password
To change the password, you must enter the original password , Same can be modified . The new password must be greater than 6 position , meanwhile 6 The bits cannot be exactly the same . The password entered for the third time is to confirm the new password , It should be the same as the password entered for the second time .
The original passwords are 123456, Input error data 111111, Test the following :


Input less than 6 A data , The test results of correctly inputting normal data are as follows :


🥎🥎🥎《 A private letter that requires the source code 》
End of the flower
What a long long road! , I will go up and down
Writing is not easy to , If you think , Welcome to praise the blogger 、 Collection 、 Comment on 、 Collect a wave ~ Let bloggers have more motivation
边栏推荐
- Zap grammar sugar
- Neo4j 智能供应链应用源代码简析
- 如何选择合适的 Neo4j 版本(2022版)
- FPGA Xilinx 7 Series FPGA DDR3 hardware design rules
- GetEmptyBlcoksPre Info
- [7. high precision division]
- Game jam development cycle
- GraphConnect 2022 大会的产品发布一览
- Dynamically load assetdatabase of assets
- Must the database primary key be self incremented? What scenarios do not suggest self augmentation?
猜你喜欢

EMC輻射發射整改-原理案例分析

Object detection -- how to use labelimg annotation tool

Graphacademy course explanation: Fundamentals of neo4j graph data science

FPGA-Xilinx 7系列FPGA DDR3硬件设计规则

Unicode decodeerror appears: 'ASCII' codec can't decode byte 0xe9 in position 0: ordinal not in range solution

Game jam development cycle
![[5. high precision subtraction]](/img/87/52b154ba5816e1d6541c885b680a1f.png)
[5. high precision subtraction]

ATM机模拟系统

【5. 高精度减法】

Get to know unity3d (project structure, third-party plug-in of probuilder)
随机推荐
[8. One dimensional prefix and]
Neo4j 智能供应链应用源代码简析
Kubernetes code generator use
ATM机模拟系统
EMC輻射發射整改-原理案例分析
Get to know unity3d (project structure, third-party plug-in of probuilder)
Matlab learning notes (5) import and export of MATLAB data
fatal error: png++/png. Hpp: no that file or directory
[6. high precision multiplication]
Vscode custom template, take notes with the template?!
File upload vulnerability shooting range analysis upload_ LABS
Zhixiang Jintai rushes to the scientific innovation board: the annual revenue is 39.19 million, the loss is more than 300million, and the proposed fund-raising is 4billion
Creating and extending XFS file system based on LVM
EMC整改小技巧
GraphAcademy 课程讲解:《Neo4j 图数据科学简介》
June25,2022 PMP Exam clearance manual-3
On Monday, I asked the meaning of the | -leaf attribute?
What is a neural network
MySQL recursively finds the tree structure. This method is very practical!
[pit encountered in docekr learning]