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 Opdracht_2
- {
- public class allMethods
- {
- public static string User() {
- Console.WriteLine("Voer uw naam in: ");
- string user = Console.ReadLine();
- return user;
- }
- public static string Pass()
- {
- Console.WriteLine("Voer uw wachtwoord in : ");
- string pass = Console.ReadLine();
- return pass;
- }
- public static void ShowMenu()
- {
- 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"};
- Console.WriteLine("Menu");
- foreach (string item in menuItems) {
- Console.WriteLine(item);
- }
- ConsoleKeyInfo userChoice = Console.ReadKey();
- if (userChoice.Key == ConsoleKey.D1) {
- Console.WriteLine("- Gekozen optie: " + menuItems[0]);
- ShowMenu();
- } else if (userChoice.Key == ConsoleKey.D2)
- {
- Console.WriteLine("- Gekozen optie: " + menuItems[1]);
- ShowMenu();
- }
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- int attempts = 0;
- while (attempts <= 3) {
- var user = allMethods.User();
- if (user == "Joost")
- {
- var pass = allMethods.Pass();
- if (pass == "123")
- {
- Console.WriteLine("Ingelogd bij C#");
- allMethods.ShowMenu();
- break;
- }
- else {
- attempts++;
- Console.WriteLine("Wrong user, " + (3 - attempts) + " attempts remaining");
- }
- }
- else {
- attempts++;
- Console.WriteLine("Wrong user, " + (3 - attempts) + " attempts remaining");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement