Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace BankÖvning
- {
- /// <summary>
- ///
- /// </summary>
- class Bank
- {
- List<Person> personList;
- private Person loggedInUser;
- public void Start() // SKapar en Start metod för att anropa de andra metoderna i programmet för att köra.
- {
- while (!LoggedIn()) // Logged är false så kommer vi till inloggnings menyn
- {
- Welcome();
- Choice();
- }
- BankChoice();
- }
- private void Welcome()
- {
- Console.WriteLine("Welcome to the worlds best bank!\nTo logg in press [A]\nTo create new account press[B]");
- }
- private bool LoggedIn() // Om logged in user inte är null är man inloggad
- {
- if (loggedInUser !=null)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- private void LogIn(String uname, string upass)
- {
- foreach (Person p in personList)
- {
- }
- }
- private void Choice() // Val för att logga in, A är logga in med ett konto B är skapa konto
- {
- char uChoice = char.Parse(Console.ReadLine());
- switch (uChoice)
- {
- case 'A':
- Console.Clear();
- Console.WriteLine("Enter your username\n");
- string uName = Console.ReadLine();
- Console.WriteLine("Enter your password\n");
- string uPass = Console.ReadLine();
- break;
- case 'B':
- Console.Clear();
- Console.WriteLine("Enter username of your choice");
- string nName = Console.ReadLine();
- Console.WriteLine("Enter password of your choice");
- string nPass = Console.ReadLine();
- break;
- }
- }
- private void BankChoice()
- {
- Account acc = new Account(); // User meny för det olika valen
- Console.WriteLine("To check your balance press [B]\n");
- Console.WriteLine("To Deposit money press [D]\n");
- Console.WriteLine("To Withdraw money press [W]\n");
- Console.WriteLine("To quit the application press [Q]\n");
- char bankChoise = char.Parse(Console.ReadLine());
- switch (bankChoise) // Kollar kontots summa +- deposits och withdraws.
- {
- case 'B':
- Console.WriteLine("Your account balance is {0}"+acc.GetBalance());
- break;
- case 'D':
- Console.WriteLine("How much money do you want to deposit?");
- int deposit = int.Parse(Console.ReadLine());
- Console.WriteLine("Your new balance is"+ acc.GetBalance(), + deposit);
- break;
- case 'W':
- Console.WriteLine("How much do you want to withdraw?");
- int withdraw = int.Parse(Console.ReadLine());
- Console.WriteLine("Your new balance is"+ acc.GetBalance(),- withdraw);
- break;
- case 'Q':
- System.Environment.Exit(0);
- break;
- }
- }
- public Bank()
- {
- personList = new List<Person>();
- loggedInUser = null;
- personList.Add(new Person("sture", "1234")); // Lägger till en användare som redan ska finnas i banksystemet!
- for (int i = 0; i < 100; i++) // lägger till 100 personer i listan för att testköra att listan fungerar.
- {
- personList.Add(new Person("Person" + i, "" + i));
- }
- }
- private void AddPerson()
- {
- Console.WriteLine("Enter username\n"); // Låter användaren skriva in sitt username och password.
- string name = Console.ReadLine();
- Console.WriteLine("Enter password\n");
- string pass = Console.ReadLine();
- Person p = new Person(name, pass); // lägger till den nya personen i listan.
- personList.Add(p);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement