The bank in the book, we Struggle together C #, just because of the fun ~

Source: Internet
Author: User

Dream Back C #, only because the heart still has so a little clinging, I believe we should also have these feelings!! So? I want to share some of my study, but also hope that you can give me more suggestions, let us progress together and grow together!!!

So let's look at how to use C # to construct a banking system project !

First of all:

We get to divide the big class to be clear: {Bank class ,Card, finally is the system class that starts up }, after finished should use some code :

steps:1First, create an array: Code as follows: card[] Cards=Newcard[ -]; 2: Initialize Card class: Public voidInitialdata () {//01. Prepare a Card Object Card1=new card ();Card1. Cardno="025"; Card1. Cardowner ="Xiao Ying"; card1. Cardpwd=" -";8Card1. Balance =0.0; //02. Assign the Card object to the array first item cards[0] = Card1;//Create a 2nd card objectCard Card2=NewCard (); Card2. Cardno ="205"; Card2. Cardowner ="Xiao Ying"; Card2. Cardpwd=" $"; Card2. Balance =500000000; cards[1] = Card2;

So let's find out what the specific features are like!

For example: account opening , access payment , Inquiry amount , real money transfer , etc.

 3. Account Console.WriteLine ("Please enter the card number:"); stringCardno =Console.ReadLine (); Console.WriteLine ("Please enter your password:"); stringCardpwd =Console.ReadLine (); Console.WriteLine ("Please enter user name:"); stringCardowner =Console.ReadLine (); Console.WriteLine ("Please enter the account amount:"); DoubleBalance =Double. Parse (Console.ReadLine ()); //first, four scattered attributes are assembled into a card object card card=new card ();card. Cardno= Cardno; Card.  Cardpwd = cardpwd; Card. Cardowner =Cardowner; Card. Balance= Balance;//01. Assigning a Card object to the first null item in the array for(inti =0; I < cards. Length; i++) {if(cards[i]==NULL)  { //I will assign the card to Cards[i] cards[i] = card;Console.WriteLine ("Successful account opening"); Break; }} Console.WriteLine ("===================");   Welcome (); }  //output The cardholder for all accounts, and the balance public void Printcustomerinfo () {foreach (Card item in cards) {//A single item is a card if (item!=null) {Console.WriteLine ("user Name {0}\t balance {1}", item. Cardowner, item.  Balance); }  4. Deposit Console.WriteLine ("Please enter the card number:");stringCardno =console.readline ();BOOLFlag =false;//How to determine the presence of a card numberforeach(Card Iteminchcards) {if(item!=NULL) { if(item. Cardno.equals (Cardno))//Card number exists{ //Please enter the amount Console.WriteLine ("Please enter the deposit amount:");intMoney =int. Parse (Console.ReadLine ()); Item. Balance + =Money ; Console.WriteLine ("Deposit Success"); Console.WriteLine ("balance: {0}", item. Balance); Flag =true; Break; } 5. WithdrawalsBOOLFlag =false;//The card is not the default       foreach(Card Iteminchcards) {       if(item!=NULL) { if(item. Cardno.equals (account))//Proof Card exists 003 001 {  //Prompt user to enter passwordConsole.WriteLine ("Please enter your password:"); stringPWD =Console.ReadLine (); if(item. Cardpwd.equals (pwd)) {//The code executes here, proving that the user name and password are correctConsole.WriteLine ("Please enter the withdrawal amount:"); intMoney =int. Parse (Console.ReadLine ()); if(Money <item. Balance) {Item. Balance= Item. Balance-Money ; Console.WriteLine ("The account balance for the user name {0} is {1} if the withdrawal was successful", item. Cardowner, item.           Balance); }   Else{Console.WriteLine ("Insufficient Balance"); }         }  Else {   6. TransferBOOLOutcardflag =false;//Default transfer card does not exist           intType =0; foreach(Cardinchcards) {     if(card!=NULL)               { if(Card.) Cardno.equals (Outcardno))//Card number Consistent{flag=true; //determine if passwords are consistent       if(Card.) Cardpwd.equals (OUTCARDPWD))//Password Consistent                       {    //The user name password is correct, can carry on the subsequent contentConsole.WriteLine ("Please enter the card number"); stringIncardno =Console.ReadLine (); #regionInner Loop, transfer cardforeach(Card Card1inchcards) {      if(Card1! =NULL)        {    if(Card1. Cardno.equals (Incardno))//Transfer Card Presence{type=1; //exists, you may be prompted to enter the transfer amountConsole.WriteLine ("Please enter the amount of the transfer"); intMoney =Convert.ToInt32 (Console.ReadLine ()); if(Money <= card.) Balance)//Legal  {         while(Money% -!=0)//not a par 100.{Console.WriteLine ("The illegal entry you entered"); Money=Convert.ToInt32 (Console.ReadLine ()); }

Well, after watching, there is not so little harvest ! If not, please give us a lot of advice , pay attention to it !!

I will be here waiting for everyone to share the joy of learning,

The bank in the book, we Struggle together C #, just because of the fun ~

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.