Fresh_bank, fresh_bank

Source: Internet
Author: User

Fresh_bank, fresh_bank

I recently learned a new bank system to share with you. The new guy asks for a cover!

 

Cable breaking_ Chain gun _

This topic is straightforward.

If we want to write the bank systemFirst considerThis question: how many classes are required?

Since it is a banking system, it is essential for banks. Here we need1. Banking

We all know that there is a card of your own to go to the bank for business processing, so here we need a 2. Card class

With these classes, we can call these classes in the main method. Next I will bring everyone together to implement a bank!

 

First, let's start with a card class, because the topic will call their initial assignment from here;

1 class Card 2 {3 private string cardNo; // Card number 4 private string cardOwner; // cardholder 5 private string cardPwd; // password 6 private double balance; // Balance 7 8 public double balance 9 {10 get {return balance;} 11 set {Balance = value;} 12} 13 public string CardPwd14 {15 get {return cardPwd ;} 16 set {cardPwd = value;} 17} 18 19 public string CardOwner20 {21 get {return cardOwner;} 22 set {cardOwner = value ;} 23} 24 25 public string CardNo26 {27 get {return cardNo;} 28 set {cardNo = value;} 29} 30 31}

 

OK! Does it seem simple to everyone? In fact, the next step is simpler ~

Next we will go to our bank module. We all know that banks generally have many functions, right?

So how are these things actually implemented? Let's come to the bank together!

 

So what are the well-known bank functions? These are the following!

1. Account Opening 2. Deposit 3. Withdrawal 4. query the balance 5. Transfer 6. Change the password 7. Withdraw 8. output the cardholder and balance of all accounts

Right, then we will follow the steps to implement each function in the bank step by step >>>>>>>>>

 

// Account opening Module

1 Console. writeLine ("welcome to the account opening module"); 2 Console. writeLine ("Enter the card number"); 3 string cardNo = Console. readLine (); 4 Console. writeLine ("Enter Password"); 5 string cardPwd = Console. readLine (); 6 Console. writeLine ("Enter the user name"); 7 string cardOwner = Console. readLine (); 8 Console. writeLine ("Enter the amount to store after opening an account"); 9 double balance = double. parse (Console. readLine (); 10 // assign the value in the bank to 11 Card = new Card (); 12 card. cardNo = cardN O; 13 card. cardPwd = cardPwd; 14 card. cardOwner = cardOwner; 15 card. balance = balance; 16 17 // assign the card object to the first null item in the array 18 for (int I = 0; I <cards. length; I ++) 19 {20 if (cards [I] = null) 21 {22 cards [I] = card; 23 Console. writeLine ("account opened successfully! "); 24 break; 25} 26}

 

// Deposit Module

 

1 Console. writeLine ("enter your account"); 2 string cardno = Console. readLine (); 3 for (int I = 0; I <cards. length; I ++) 4 {5 if (cards [I]! = Null & cards [I]. cardNo = cardno) 6 {7 flag = true; 8 Console. writeLine ("Enter Password"); 9 string pwd = Console. readLine (); 10 if (cards [I]. cardPwd = pwd) 11 {12 Console. writeLine ("Congratulations, you have logged on! Enter the deposit amount: "); 13 double GiveMoney = double. parse (Console. readLine (); 14 cards [I]. balance = cards [I]. balance + GiveMoney; 15 Console. writeLine ("Congratulations, your deposit is successful, your current balance is: {0}", cards [I]. balance); 16 break; 17} 18 else19 {20 Console. writeLine ("the password you entered is incorrect! "); 21 break; 22} 23} 24}

 

// Withdrawal Module

1 Console. writeLine ("enter your account"); 2 string cardno = Console. readLine (); 3 for (int I = 0; I <cards. length; I ++) 4 {5 if (cards [I]! = Null & cards [I]. cardNo = cardno) 6 {7 flag1 = true; 8 Console. writeLine ("Enter Password"); 9 string pwd = Console. readLine (); 10 if (cards [I]. cardPwd = pwd) 11 {12 Console. writeLine ("Congratulations, you have logged on! Enter the amount you want to withdraw: "); 13 double TakeMoney = double. parse (Console. readLine (); 14 cards [I]. balance = cards [I]. balance-TakeMoney; 15 Console. writeLine ("Congratulations, your deposit is successful, your current balance is: {0}", cards [I]. balance); 16 break; 17} 18 else19 {20 Console. writeLine ("the password you entered is incorrect! "); 21 break; 22} 23} 24}

 

// Transfer module

Note! Note!

The above is basically a transfer for everyone ~ So what I want to talk about next is the real Tibetan temple in this article!

I believe that it is also dizzy for beginners like me to transfer funds?

Next, let's join him!

 

1 Console. writeLine ("enter your account"); 2 string cardno = Console. readLine (); 3 for (int I = 0; I <cards. length; I ++) 4 {5 if (cards [I]! = Null & cards [I]. cardNo = cardno) 6 {7 flag2 = true; 8 Console. writeLine ("Enter Password"); 9 string pwd = Console. readLine (); 10 if (cards [I]. cardPwd = pwd & cards [I]. balance! = 0) 11 {12 if (cards [I]. Balance! = 0) 13 {14 Console. WriteLine ("Congratulations, you have logged on! Enter the object account you want to transfer: "); 15 string Target = Console. readLine (); 16 for (int j = 0; j <cards. length; j ++) 17 {18 if (cards [j]. cardNo. equals (Target) | cards [j]. cardNo! = Null) 19 {20 Console. writeLine ("Enter your operation amount:"); 21 double Transform = double. parse (Console. readLine (); 22 if (Transform <cards [I]. balance & Transform! = 0) 23 {24 cards [I]. Balance-= Transform; 25 cards [j]. Balance + = Transform; 26 Console. WriteLine ("Congratulations! Your current balance is: {0} ", cards [I]. balance); 27 break; 28} 29 else 30 {31 Console. writeLine ("enter the correct operation amount:"); 32} 33} 34 break; 35} 36 break; 37} 38 else39 {40 Console. writeLine ("your current balance is insufficient! Transfer is not allowed! "); 41} 42} 43 else44 {45 Console. WriteLine (" the password you entered is incorrect! "); 46 break; 47} 48} 49} 50 return flag2; 51} 52 53 // query balance 54 public bool SelectMoney () 55 {56 bool flag3 = false; 57 Console. writeLine ("========================"); 58 Console. writeLine ("here is the balance query module"); 59 Console. writeLine ("========================"); 60 61 Console. writeLine ("enter your account"); 62 string cardno = Console. readLine (); 63 for (int I = 0; I <cards. length; I ++) 64 {65 if (cards [I]! = Null & cards [I]. cardNo = cardno) 66 {67 flag3 = true; 68 Console. writeLine ("Enter Password"); 69 string pwd = Console. readLine (); 70 if (cards [I]. cardPwd = pwd) 71 {72 Console. writeLine ("Congratulations, you have logged on! Your current balance is: {0}: ", cards [I]. balance); 73 Welcome (); 74 break; 75} 76 else77 {78 Console. writeLine ("the password you entered is incorrect! "); 79 break; 80} 81} 82}

 

How is it? I was a little surprised to see that the transfer was clearly presented to everyone? 

 

// Change the password

1 Console. writeLine ("enter your account"); 2 string cardno = Console. readLine (); 3 for (int I = 0; I <cards. length; I ++) 4 {5 if (cards [I]! = Null & cards [I]. cardNo = cardno) 6 {7 flag4 = true; 8 Console. writeLine ("enter your password"); 9 string pwd = Console. readLine (); 10 if (cards [I]. cardPwd = pwd) 11 {12 Console. writeLine ("Enter your new password:"); 13 string pwd3 = Console. readLine (); 14 Console. writeLine ("Enter your new password again:"); 15 string pwd2 = Console. readLine (); 16 if (pwd2 = pwd3) 17 {18 cards [I]. cardPwd = pwd3; 19} 20 Console. writeLine ("Congratulations! Your password has been modified! Your new password is {0} ", cards [I]. cardPwd); 21 Welcome (); 22 break; 23} 24 else25 {26 Console. writeLine ("the password you entered is incorrect! "); 27 break; 28} 29} 30}

 

// Refund ....

 

 

In fact, when writing such a project, I will summarize a method and share it with you here: Every time I get a project, I don't want to feel too big. First of all, I will overwrite the content,

Sort out the ideas, so that the next programming will feel endless ~~!

Thank you for your patience! Follow me and give you the best presentation ~

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.