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;
- using System.Threading;
- namespace Ksiazka_telefoniczna
- {
- class Program
- {
- public static void Sleep(int milisekundy)
- {
- }
- static int Menu_glowne_wybor()
- {
- Console.Clear();
- Console.WriteLine("Witaj w programie: Książka telefoniczna!");
- Console.WriteLine("[1] Otwórz książke.");
- Console.WriteLine("[2] Załóż nową książke.");
- Console.WriteLine("[3] Dodaj nową osobe.");
- Console.WriteLine("[4] Wyjdź z programu.");
- Console.Write("Wybierz: ");
- return int.Parse(Console.ReadLine());
- }
- static void Main(string[] args)
- {
- List<string> lista = new List<string>();
- bool koniec=true;
- bool czyKsiazkaUtworzona=false;
- string nazwaKsiazki="ksiazka";
- while (koniec)
- {
- int wybor = Menu_glowne_wybor();
- switch (wybor)
- {
- case 1:
- {
- Console.Clear();
- if (czyKsiazkaUtworzona == true) {
- int numer=0;
- Console.Write(nazwaKsiazki);
- Console.WriteLine(":");
- Console.WriteLine();
- string pole = string.Empty;
- foreach (string tekst in lista)
- {
- if(numer==3)
- {
- Console.WriteLine();
- numer = 0;
- }
- numer++;
- Console.Write(numer);
- Console.Write(".");
- Console.WriteLine(tekst);
- }
- Console.Write("Wciśnij dowolny klawisz aby kontynuować...");
- Console.ReadKey();
- break;
- }
- else {
- Console.WriteLine("Nie utworzyłeś jeszcze książki!");
- Console.WriteLine("Zostaniesz przekierowany do menu głównego.");
- Thread.Sleep(2000);
- break;
- }
- }
- case 2:
- {
- Console.Clear();
- if (czyKsiazkaUtworzona == true)
- {
- Console.WriteLine("Utworzyles już wcześniej książke, czy chcesz ją utworzyć jeszcze raz?");
- Console.Write("Wybierz 1(tak) lub 2(nie): ");
- int CzyTworzycJeszczeRaz = int.Parse(Console.ReadLine());
- switch(CzyTworzycJeszczeRaz)
- {
- case 1:
- {
- Console.Clear();
- lista = new List<string>(); // reset starej ksiazki
- Console.Write("Podaj nazwę książki: ");
- nazwaKsiazki = Console.ReadLine();
- czyKsiazkaUtworzona = true;
- Console.WriteLine("Pomyślnie utworzono książke telefoniczną.");
- Thread.Sleep(2000);
- break;
- }
- case 2:
- {
- Console.Clear();
- break;
- }
- default:
- {
- Console.Clear();
- Console.WriteLine("Zła odpowiedź!");
- Console.WriteLine("Zostaniesz przekierowany do menu głównego.");
- Thread.Sleep(2000);
- break;
- }
- }
- }
- else
- {
- Console.Clear();
- Console.Write("Podaj nazwę książki: ");
- nazwaKsiazki = Console.ReadLine();
- czyKsiazkaUtworzona = true;
- Console.WriteLine("Pomyślnie utworzono książke telefoniczną.");
- Thread.Sleep(2000);
- break;
- }
- break;
- }
- case 3:
- {
- string imie;
- string nazwisko;
- string numer_telefonu;
- Console.Clear();
- if (czyKsiazkaUtworzona == true)
- {
- Console.Write("Podaj imie: ");
- imie = Console.ReadLine();
- lista.Add(imie);
- Console.Write("Podaj nazwisko: ");
- nazwisko = Console.ReadLine();
- lista.Add(nazwisko);
- do
- {
- Console.Write("Podaj numer: ");
- numer_telefonu = Console.ReadLine();
- if (numer_telefonu.Length != 9)
- {
- Console.WriteLine();
- Console.WriteLine("Wprowadź prawidłowy numer telefonu!");
- Thread.Sleep(2000);
- Console.Clear();
- }
- } while (numer_telefonu.Length != 9);
- lista.Add(numer_telefonu);
- Console.WriteLine("Pomyslnie zapisano osobe");
- Thread.Sleep(2000);
- }
- else
- {
- Console.WriteLine("Nie utworzyłeś jeszcze książki!");
- Console.WriteLine("Zostaniesz przekierowany do menu głównego.");
- Thread.Sleep(2000);
- break;
- }
- break;
- }
- case 4:
- {
- koniec = false;
- break;
- }
- default:
- {
- Console.Clear();
- Console.WriteLine("Zła odpowiedź!");
- Console.WriteLine("Zostaniesz przekierowany do menu głównego.");
- Thread.Sleep(2000);
- break;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement