Advertisement
Guest User

Untitled

a guest
Jan 25th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.59 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace BankÖvning
  8. {
  9.     /// <summary>
  10.     ///
  11.     /// </summary>
  12.     class Bank
  13.     {
  14.         List<Person> personList;
  15.         private Person loggedInUser;
  16.        
  17.         public void Start() // SKapar en Start metod för att anropa de andra metoderna i programmet för att köra.
  18.         {
  19.            
  20.            
  21.            
  22.             while (!LoggedIn()) // Logged är false så kommer vi till inloggnings menyn
  23.             {
  24.                 Welcome();
  25.                 Choice();
  26.             }
  27.               BankChoice();
  28.         }
  29.        
  30.       private void Welcome()
  31.         {
  32.             Console.WriteLine("Welcome to the worlds best bank!\nTo logg in press [A]\nTo create new account press[B]");
  33.            
  34.            
  35.         }
  36.  
  37.         private bool LoggedIn() // Om logged in user inte är null är man inloggad
  38.         {
  39.             if (loggedInUser !=null)
  40.             {
  41.                 return true;
  42.             }
  43.             else
  44.             {
  45.                 return false;
  46.             }      
  47.         }
  48.         private void LogIn(String uname, string upass)
  49.         {
  50.             foreach (Person p in personList)
  51.             {
  52.                
  53.             }
  54.         }
  55.  
  56.          private void Choice()  // Val för att logga in, A är logga in med ett konto B är skapa konto
  57.         {
  58.             char uChoice = char.Parse(Console.ReadLine());
  59.             switch (uChoice)
  60.             {
  61.                 case 'A':
  62.                     Console.Clear();
  63.                     Console.WriteLine("Enter your username\n");
  64.                     string uName = Console.ReadLine();
  65.                     Console.WriteLine("Enter your password\n");
  66.                     string uPass = Console.ReadLine();
  67.  
  68.                     break;
  69.  
  70.                 case 'B':
  71.                     Console.Clear();
  72.                     Console.WriteLine("Enter username of your choice");
  73.                     string nName = Console.ReadLine();
  74.                     Console.WriteLine("Enter password of your choice");
  75.                     string nPass = Console.ReadLine();
  76.  
  77.  
  78.                     break;
  79.  
  80.             }
  81.         }
  82.         private void BankChoice()
  83.         {
  84.             Account acc = new Account();                               // User meny för det olika valen
  85.             Console.WriteLine("To check your balance press [B]\n");
  86.             Console.WriteLine("To Deposit money press [D]\n");
  87.             Console.WriteLine("To Withdraw money press [W]\n");
  88.             Console.WriteLine("To quit the application press [Q]\n");
  89.             char bankChoise = char.Parse(Console.ReadLine());
  90.  
  91.             switch (bankChoise) // Kollar kontots summa +- deposits och withdraws.
  92.             {
  93.                 case 'B':
  94.                     Console.WriteLine("Your account balance is {0}"+acc.GetBalance());
  95.                     break;
  96.                 case 'D':
  97.                     Console.WriteLine("How much money do you want to deposit?");
  98.                     int deposit = int.Parse(Console.ReadLine());
  99.                     Console.WriteLine("Your new balance is"+ acc.GetBalance(), + deposit);
  100.                     break;
  101.                 case 'W':
  102.                     Console.WriteLine("How much do you want to withdraw?");
  103.                     int withdraw = int.Parse(Console.ReadLine());
  104.                     Console.WriteLine("Your new balance is"+ acc.GetBalance(),- withdraw);
  105.                     break;
  106.  
  107.                 case 'Q':
  108.                     System.Environment.Exit(0);
  109.                     break;
  110.             }
  111.         }
  112.         public Bank()
  113.         {
  114.             personList = new List<Person>();
  115.             loggedInUser = null;
  116.  
  117.  
  118.             personList.Add(new Person("sture", "1234")); // Lägger till en användare som redan ska finnas i banksystemet!
  119.             for (int i = 0; i < 100; i++) // lägger till 100 personer i listan för att testköra att listan fungerar.
  120.             {
  121.                 personList.Add(new Person("Person" + i, "" + i));
  122.             }
  123.            
  124.         }
  125.         private void AddPerson()
  126.         {
  127.             Console.WriteLine("Enter username\n"); // Låter användaren skriva in sitt username och password.
  128.             string name = Console.ReadLine();
  129.             Console.WriteLine("Enter password\n");
  130.             string pass = Console.ReadLine();
  131.  
  132.             Person p = new Person(name, pass); // lägger till den nya personen i listan.
  133.             personList.Add(p);
  134.         }
  135.        
  136.     }
  137. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement