Advertisement
Guest User

Untitled

a guest
Feb 10th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.26 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 Opdracht_2
  8. {
  9.     public class allMethods
  10.     {
  11.         public static string User() {
  12.             Console.WriteLine("Voer uw naam in: ");
  13.             string user = Console.ReadLine();
  14.             return user;
  15.         }
  16.         public static string Pass()
  17.         {
  18.             Console.WriteLine("Voer uw wachtwoord in : ");
  19.             string pass = Console.ReadLine();
  20.             return pass;
  21.         }
  22.         public static void ShowMenu()
  23.         {
  24.             string[] menuItems = new string[] { "1. Add a book.", "2. Delete book.", "3. Borrow a book.", "4. Return book.", "5. See list of available books.", "6. See list of all books.", "7. Exit"};
  25.             Console.WriteLine("Menu");
  26.             foreach (string item in menuItems) {
  27.                 Console.WriteLine(item);
  28.             }
  29.             ConsoleKeyInfo userChoice = Console.ReadKey();
  30.             if (userChoice.Key == ConsoleKey.D1) {
  31.                 Console.WriteLine("- Gekozen optie: " + menuItems[0]);
  32.                 ShowMenu();
  33.             } else if (userChoice.Key == ConsoleKey.D2)
  34.             {
  35.                 Console.WriteLine("- Gekozen optie: " + menuItems[1]);
  36.                 ShowMenu();
  37.             }
  38.         }
  39.     }
  40.     class Program
  41.     {
  42.         static void Main(string[] args)
  43.         {
  44.             int attempts = 0;
  45.             while (attempts <= 3) {
  46.                 var user = allMethods.User();
  47.                 if (user == "Joost")
  48.                 {
  49.                     var pass = allMethods.Pass();
  50.                     if (pass == "123")
  51.                     {
  52.                         Console.WriteLine("Ingelogd bij C#");
  53.                         allMethods.ShowMenu();
  54.                         break;
  55.                     }
  56.                     else {
  57.                         attempts++;
  58.                         Console.WriteLine("Wrong user, " + (3 - attempts) + " attempts remaining");
  59.                     }
  60.                 }
  61.                 else {
  62.                     attempts++;
  63.                     Console.WriteLine("Wrong user, " + (3 - attempts) + " attempts remaining");
  64.                 }
  65.             }
  66.         }
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement