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;
- namespace qwertyuiqew
- {
- class TKontakty
- {
- String Imie;
- String Nazwisko;
- String Telefon;
- String Adres;
- public TKontakty()
- {
- }
- public TKontakty(String Im, String Na, String Tel, String Ad)
- {
- Imie = Im;
- Nazwisko = Na;
- Telefon = Tel;
- Adres = Ad;
- }
- public static TKontakty Nowy()
- {
- bool xd = true;
- int cos;
- String im, na, tel, ad;
- TKontakty Kontakt;
- Console.WriteLine("Podaj imie, nazwisko, numer, adres\n");
- im = Console.ReadLine();
- im = im.Trim();
- na = Console.ReadLine();
- do
- {
- tel = Console.ReadLine();
- if (xd == Int32.TryParse(tel,out cos) ) break;
- Console.WriteLine("Podaj numer!");
- } while (true);
- tel = tel.Trim();
- ad = Console.ReadLine();
- Kontakt = new TKontakty(im, na, tel, ad);
- return Kontakt;
- }
- public String ZwrocImie { get { return Imie; } }
- public String ZwrocNazwisko { get { return Nazwisko; } }
- public String ZwrocTelefon { get { return Telefon; } }
- public String ZwrocAdres { get { return Adres; } }
- };
- class Program
- {
- static void Main(string[] args)
- {
- String ktory;
- bool pl=true;
- int l;
- bool wyjdz =false;
- TKontakty[] tab;
- tab = new TKontakty[10];
- for (int i = 0; i < tab.Length; i++)
- {
- tab[i] = new TKontakty();
- }
- do
- {
- Console.WriteLine("Co chcesz zrobic?\nf1- dodaj kontakt\nf2 - usun kontakt\nf3 - zobacz kontakty\nf4 - usun wszystkie kontakty\nf5 - wyjdz z programu\n");
- ConsoleKey k;
- k = Console.ReadKey().Key;
- switch (k)
- {
- case ConsoleKey.F1:
- {
- for (int i = 0; i < tab.Length; i++)
- {
- if (tab[i].ZwrocTelefon == null)
- {
- tab[i] = TKontakty.Nowy();
- break;
- }
- if (tab[i].ZwrocTelefon == null && i==9) Console.WriteLine("Brak miejsca\n");
- }
- break;
- }
- case ConsoleKey.F2:
- {
- Console.WriteLine("Ktory kontakt usunac?\n");
- do
- {
- ktory = Console.ReadLine();
- if (pl == int.TryParse(ktory, out l) ) break;
- } while (true);
- tab[l - 1] = new TKontakty();
- break;
- }
- case ConsoleKey.F3:
- {
- for (int i = 0; i < tab.Length; i++)
- {
- if (tab[i].ZwrocTelefon == null) Console.WriteLine("[{0}] - puste", i + 1);
- else
- {
- Console.Write("[{0}] -", i+1);
- Console.WriteLine (tab[i].ZwrocImie + " " + tab[i].ZwrocNazwisko + " " + tab[i].ZwrocTelefon + " " + tab[i].ZwrocAdres);
- }
- }
- break;
- }
- case ConsoleKey.F4:
- {
- for (int i = 0; i < tab.Length; i++) tab[i] = new TKontakty();
- break;
- }
- case ConsoleKey.F5:
- {
- wyjdz = true;
- break;
- }
- }
- } while (wyjdz == false);
- }
- }
- }
Advertisement