one. This system simulates bank users using ATM machines to open an account, query, deposit and withdraw money, and requires programming to be implemented using Java language.
illustrate:
1. For data input exceptions, you can use the java exception handling mechanism to handle it.
2. The score will be evaluated in a way that combines functional implementation with code normativeness.
3. If you have any questions about project requirements, you can contact me at any time by leaving a QQ message for consultation.
4. During the National Day holiday, teachers are on duty at the company every day. I am on duty at the company on October 4th and I go to work normally on October 7th. Everyone is welcome to come to the company to do projects.
two. Project functional requirements:
The project starts running and displays the main menu as:
Bank self-service terminal system
************************************
0.------Open an account
1.----------------------------------------------------------------------------------------------------------------------------
2.------Deposit
3.------ Withdrawal
4.-------Exit
************************************
Please select the function you want to perform:
At this time, the user can select the function he wants to implement through keyboard input. If the input is not 0, 1, 2, 3, 4, the system prompts:
The menu you selected does not exist!
Please reselect:
Ask the user to re-enter the data for menu selection!
When the user enters 0, the query function will be entered: System prompt:
************************************
You chose the account opening function
Please enter your name:
At this time, the user needs to enter his name. After the input is completed, the system prompts:
Please enter your ID number:
At this time, the user needs to enter the 18-digit ID number. If the verification fails and requires continued input, the system prompts:
Please enter your password:
At this time, the user needs to enter a 6-digit pure digital password. If the verification fails and requires continued input, the system prompts after the verification is passed:
The account opening was successful, thank you for using it!
Bank self-service terminal system
************************************
0.------Open an account
1.----------------------------
2.------Deposit
3.------ Withdrawal
4.-------Exit
************************************
Please select the function you want to perform:
When the user enters 1, the query function will be entered: System prompt:
************************************
You chose the query function
Please enter the card number you want to query:
At this time, the user needs to enter the query card number, and the system will check the card number. If the card number does not exist, it will prompt: The card number you entered does not exist, please re-enter:
Please enter the card number you want to query:
Re-enter the card number. When the user enters the correct card number, the prompt is:
Please enter your password:
At this time, the user needs to enter a 6-digit pure digital password. If the verification fails and requires continued input (up to 3 times), the system will display the current user account information and enter the main menu after the verification is passed:
The account information you are querying is:
************************************
Name ID card number card number amount
Zhang Sanfeng420106198410112062 111111 12800.0
Bank self-service terminal system
************************************
0.------Open an account
1.----------------------------------------------------------------------------------------------------------------------------
2.------Deposit
3.------ Withdrawal
4.-------Exit
************************************
Please select the function you want to perform:
When the user enters 2, the deposit function will be entered: System prompt:
************************************
Your choice is the deposit function
Please enter the card number you want to deposit:
At this time, the user needs to enter the card number of the deposit, and the system will check the card number. If the card number does not exist, the prompt is:
The card number you entered does not exist, please re-enter:
Please enter the card number you want to deposit:
Re-enter the card number. When the user enters the correct card number, the prompt is:
Please enter your password:
At this time, the user needs to enter a 6-digit pure digital password. If the verification fails and requires continued input (up to 3 times), the system will display the current user account information and enter the main menu after the verification is passed:
The account information you want to deposit is:
************************************
Name ID card number card number amount
Zhang Sanfeng420106198410112062 111111 12800.0
Please enter the amount you want to deposit:
At this time, the user is required to enter the deposit amount, and the system will judge the amount. If the input data is less than or equal to 0, it will be prompted:
The data you entered is invalid and the system will automatically exit! Thanks for using
Bank self-service terminal system
************************************
0.------Open an account
1.----------------------------------------------------------------------------------------------------------------------------
2.------Deposit
3.------ Withdrawal
4.-------Exit
************************************
Please select the function you want to perform:
If the user enters data legally, the system prompts that the deposit is successful and returns to the main menu:
The deposit was successful, thank you for using it!
Bank self-service terminal system
************************************
0.------Open an account
1.----------------------------------------------------------------------------------------------------------------------------
2.------Deposit
3.------ Withdrawal
4.-------Exit
************************************
Please select the function you want to perform:
The data will be deposited into the user account. If the user searches the data again, he can see the changed account amount. (Note: This system uses files for data storage, so if the user restarts the program, the data will be read from the file and re-initialized to memory! This function is optional, you can refer to the serialization and deserialization of objects or JSON)
When the user enters 3, the withdrawal function will be entered: System prompt:
************************************
Please enter the card number you want to withdraw as the withdrawal function:
At this time, the user needs to enter the card number for withdrawal. The system will check the card number. If the card number does not exist, it will be prompted:
The card number you entered does not exist, please re-enter:
Please enter the card number you want to withdraw:
Re-enter the card number. When the user enters the correct card number, the prompt is:
Please enter your password:
At this time, the user needs to enter a 6-digit pure digital password. If the verification fails and requires continued input (up to 3 times), the system will display the current user account information and enter the main menu after the verification is passed:
The account information you want to withdraw is:
************************************
Name ID card number card number amount
Zhang Sanfeng420106198410112062 111111 12800.0
Please enter the amount you want to withdraw:
At this time, the user is required to enter the withdrawal amount, and the system will judge the amount. If the input data is less than 0 or greater than the total amount of the account, the prompt is:
The data you entered is invalid and the system will automatically exit! Thanks for using
Bank self-service terminal system
************************************
0.------Open an account
1.----------------------------
2.------Deposit
3.------ Withdrawal
4.-------Exit
************************************
Please select the function you want to perform:
If the user enters data legally, the system prompts that the withdrawal is successful and returns to the main menu:
The withdrawal was successful, thank you for using it!
Bank self-service terminal system
************************************
0.------Open an account
1.----------------------------------------------------------------------------------------------------------------------------
2.------Deposit
3.------ Withdrawal
4.-------Exit
************************************
Please select the function you want to perform:
The data will be deducted from the user's account. If the user searches the data again, he can see the changed account amount.
When the user enters 4, the system will exit.
three. Design requirements
(1) Package One: com.bank.unionpay means UnionPay, add it under this package:
It represents the interface to a bank card, including abstract methods such as querying balance, deposit, withdrawal, etc.
It represents an abstract class that represents the ATM machine, uses bank card type objects as attributes or parameters, implements instance methods such as query balances, deposits, withdrawals, etc., and adds account opening as an abstract method.
It represents the enumeration types of the four major banks: including ABC, ICBC, CCB, and BOC; it represents Agricultural Bank of China, Industrial and Commercial Bank of China, CCB, and Bank of China respectively.
(2) Package 2: com.bank.abc represents the Agricultural Bank of China, add it under this package:
Define the bank class in a singleton pattern, including attributes: bank type (enumeration type, constant = ABC), bank name (String), bank card list (set), etc.
Define the implementation class of the bank card - a savings card, including attributes: bank type (enumeration type = ABC), name, ID number, card number, password, balance; implement methods for querying balance, deposit, withdrawal, etc.
Define the subclass of the ATM machine, including attributes: bank type (enumeration type, constant = ABC), implementing the account opening method, among which: only a savings card can be opened, the card number is a 6-digit random number, which is automatically generated. The newly opened bank card is added to the bank's bank card list.
Define the subclass of savings card - credit card, add attributes: overdraft limit, rewrite withdrawal method, and control the maximum withdrawal amount cannot be greater than the sum of the balance + overdraft limit.
(3) Package 3: com.bank.test represents testing, add a test class with main method under this package to realize the function of simulated ATM machines required by the project.
Choose the following functions:
Implement ICBC in single-state mode, add multiple bank cards to the test class by default, and implement cross-bank query and deposit and withdrawal functions on the ATM machine of the Agricultural Bank.
Package 1: com.bank.unionpay
1. Bank card abstract class
package com.bank.unionpay;public interface Yinhangka {public void cun();public void qu();public void getyu();}2. Enumerate bank types
package com.bank.unionpay;public enum Yinhang {ABC("Agricultural Bank"),ICBC("Industrial and Commercial"),CCB("CCB"),BOC("Bank of China");private final String yinhang;//Private construction method private Yinhang(String yinhang){this.yinhang=yinhang;}public String getname(){return this.yinhang;}}3. ATM class
package com.bank.unionpay;import com.bank.abc.Yinhanglei;public abstract class ATM {private Yinhanglei yhl; //bank class attribute private double yue; //variable yuepublic double getYue() {return yue;}public void setYue(double yue) {this.yue = yue;}//Query method public void yue(){System.out.println("The balance on the card is: " +this.yue);}//Default method public void cun(double cun){if(cun<0){System.out.println("Input is incorrect");}else{this.yue+=cun;System.out.println("Balance on the card is: "+this.yue);}}// Withdrawal method public void qu(double qu){if(qu>this.yue){System.out.println("Balance is insufficient");}else {this.yue-=qu;System.out.println("Balance on the card is: "+this.yue);}}//Define the abstract method of account opening public abstract void kaihu();}4. Main interface class
package com.bank.unionpay;import java.util.ArrayList;import java.util.List;import java.util.Scanner;public class Zujiemian {public void zhujiemian(){System.out.println("Bank Self-Service Terminal System");System.out.println();System.out.println("******************************");System.out.println();List<String> li=new ArrayList<String>();li.add("Account Opening");li.add("Query");li.add("Deposit");li.add("Exit");li.add("Invoice");li.add("Exit");for(int i=0;i<5;i++){System.out.println(i+"------"+li.get(i));}System.out.println();System.out.println("***************************");System.out.println();System.out.println();System.out.println("Please select the function you want to perform: ");}}Package 2: com.bank.abc
1. ATM2 account opening category
package com.bank.abc;import java.util.Random;import java.util.Scanner;import com.bank.unionpay.ATM;import com.bank.unionpay.Yinhang;public class ATM2 extends ATM{private Yinhang yhl=Yinhang.ABC; @Overridepublic void kaihu() {// Account opening method// Enter the name Cuxuka cxk=new Cuxuka();try{Scanner sc1=new Scanner(System.in);System.out.println("Please enter your name: ");String st=sc1.nextLine();cxk.setName(st);//Enter ID card System.out.println("Please enter your ID card number: ");for(int ig=0;ig>=0;ig++){Scanner sc2=new Scanner(System.in);String str=sc2.nextLine();String st1="//d{15}|//d{17}[//dxX]";if(str.matches(st1)){cxk.setShenfen(str);break;}else{System.out.println("The entered ID number is not the 18-digit ID number");}}//Set the account password System.out.println("Please enter your password:");for(int ig=0;ig>=0;ig++){Scanner sc3=new Scanner(System.in);String pass=sc3.nextLine();String mm="//d{6}";if(pass.matches(mm)){cxk.setPassword(pass);break;}else{System.out.println("Please enter the correct 6-digit password");}}//Generate a 6-digit savings card number Random a=new Random();int[] ch=new int[6];StringBuilder str=new StringBuilder();String s;for(int i=0;i<6;i++){ch[i]=a.nextInt(9);}for(Integer c:ch){str.append(c);}s=str.toString();cxk.setCard(s);//Import the generated data into the bank card list Yinhanglei.getYinhangLei().list.add(cxk.getCard());//Import the generated data into the bank card Map list Yinhanglei.getYinhangLei().map.put(cxk.getCard(), cxk);System.out.println("Your new card number is: "+cxk.getCard());System.out.println("The account opening is successful, thank you for using");}catch (Exception e) {System.out.println("Input is incorrect");}}}2. Savings card category
package com.bank.abc;import java.util.Scanner;import com.bank.unionpay.Yinhang;import com.bank.unionpay.Yinhangka;public class Cuxuka implements Yinhangka {//Save card attribute private Yinhang yinhang;private String name;private String shenfen;private String card;private String password;private double balance;//Generate toString ();@Overridepublic String toString() {return "name=" + name + "/t/n"+ "ID card=" + shenfen + "/t/n"+" card number=" + card + "/t/n"+" Account amount=" + balance;}//Get set for the attribute public Yinhang getYinhang() {return yinhang=Yinhang.ABC;}public String getName() {return name;}public void setName(String name) {this.name = name;}public String getShenfen() {return shenfen;}public void setShenfen(String shenfen) {this.shenfen = shenfen;}public String getCard() {return card;}public void setCard(String card) {this.card = card;}public String getPassword() {return password;}public void setPassword(String password) {this.password = password;}public double getBalance() {return balance;}public void setBalance(double balance) {this.balance = balance;}//Deposit method @Overridepublic void cun() {Cuxuka cu1=new Cuxuka();cu1.chaxun();Scanner sc2=new Scanner(System.in);System.out.println("Please enter the amount you want to deposit:");double cun=sc2.nextDouble();// Implement the deposit method if(cun<0){System.out.println("The data you entered is invalid, the system will automatically exit! Thank you for using ");}else{this.balance+=cun;Yinhanglei.getYinhangLei().map.get(cu1.card).setBalance(balance);System.out.println("Disclaimer succeeds, remaining amount"+Yinhanglei.getYinhangLei().map.get(cu1.card).getBalance());}}//Query method public void chaxun(){while(true){try{Scanner sc=new Scanner(System.in);System.out.println("Please enter the card number you want to query:");String s=sc.nextLine();//Transf the Map collection of Yinhanglei for(String temp:Yinhanglei.getYinhangLei().map.keySet()){if(s.equals(temp)){this.card=s;}}if(s.equals(card)) //Verify card number{int i=0;System.out.println("Please enter your password:"); while(true){Scanner sc1=new Scanner(System.in);String st1=sc1.nextLine();if(st1.equals(Yinhanglei.getYinhangLei().map.get(s).getPassword())){System.out.println("The account information you are querying is:");System.out.println();System.out.println("************************************");System.out.println();System.out.println("Name ID number card number amount");System.out.println();System.out.println(Yinhanglei.getYinhangLei().map.get(s));break;}else{i++;if(i==3){System.out.println("Password input error more than 3 times");break;}else{System.out.println("Password input error");}}}}else{System.out.println("Please confirm if the card number is entered incorrectly");}}} catch (Exception e) {System.out.println("Input is incorrect");}break;}}// Withdrawal method operation @Overridepublic void qu() {Cuxuka cu=new Cuxuka();cu.chaxun();Scanner sc1=new Scanner(System.in);System.out.println("Please enter the amount you want to withdraw:");double qu=sc1.nextDouble();// Implement the withdrawal method if(qu<balance){this.balance-=qu;Yinhanglei.getYinhangLei().map.get(cu.card).setBalance(balance);System.out.println("The withdrawal is successful, the remaining amount is: "+ Yinhanglei.getYinhangLei().map.get(cu.card).getBalance());}else if(qu<0) {System.out.println("The data you entered is invalid, the system will automatically exit! Thanks for using ");;}else{System.out.println("Insufficient balance");}}@Overridepublic void getyu() {// Balance calculation Cuxuka cu=new Cuxuka();System.out.println("Remaining amount"+cu.getBalance());}}3. Singleton model banking category
package com.bank.abc;import java.util.ArrayList;import java.util.HashMap;import java.util.List;import java.util.Map;import com.bank.unionpay.Yinhang;public class Yinhanglei {//Bank class attribute private Yinhang yinhang=Yinhang.ABC;private String name;public List<String> list=new ArrayList<>();public Map<String, Cuxuka> map=new HashMap<>();//Private construction method private Yinhanglei() {super();}private static Yinhanglei bank=new Yinhanglei();public static Yinhanglei getYinhangLei(){return bank;}}4. Credit card category
package com.bank.abc;public class Xinyongka extends Cuxuka {//Construct your own attribute private double touzhi;public double getTouzhi() {return touzhi;}public void setTouzhi(double touzhi) {this.touzhi = touzhi;}//Rewrite the withdrawal method public void qu(double qu) {// Implement withdrawal method if((touzhi+getBalance())>=qu){System.out.println("Overdraw amount"+(qu-getBalance()));;}else{System.out.println("Cannot withdraw more than the maximum overdrawal amount");;}}}Package 3: com.bank.test
1. Test class
package com.bank.test;import java.util.ArrayList;import java.util.List;import java.util.Scanner;import com.bank.abc.ATM2;import com.bank.abc.Cuxuka;import com.bank.unionpay.ATM;import com.bank.unionpay.Zujiemian;public class Test1 {public static void main(String[] args) {//Making of main interface Cuxuka cxk=new Cuxuka();//Instantiate the main interface Zujiemian zjm=new Zujiemian();//Top an exception try{//Create a dead loop for(int i=0;i>=0;i++){zjm.zhujiemian();Scanner sc=new Scanner(System.in);int in=sc.nextInt();//Defend whether the input number meets the interface number if(in==0||in==1||in==2||in==3||in==4){//Opening function if(in==0){ATM2 atm2=new ATM2();atm2.kaihu();System.out.println("*********************************");System.out.println("You selected as the account opening function");System.out.println();continue;}//Query function if(in==1){System.out.println("******************************");System.out.println("You selected as the query function");cxk.chaxun();continue;}//Default function if(in ==2){System.out.println("*********************************");System.out.println("Your choice is the deposit function");cxk.cun();continue;}// Withdrawal function if(in==3){System.out.println("***************************");System.out.println("Your choice is the withdrawal function");cxk.qu();continue;}//Exit function if(in==4){System.out.println("Thanks for using! ");break;}}//Print else{System.out.println("The menu you selected does not exist!");}}//Exception throws print}catch (Exception e) {System.out.println("Input is incorrect");} }}result:
The above is the Java simulated bank self-service terminal system introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support to Wulin.com website!