Advertisement
Guest User

Untitled

a guest
Sep 13th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.15 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 ConsoleApplication41
  8. {
  9.     class Adres {
  10.         private string kod, miasto, ulica;
  11.         public Adres(string kod, string miasto, string ulica)
  12.         {
  13.             this.kod = kod;
  14.             this.miasto = miasto;
  15.             this.ulica = ulica;
  16.         }
  17.         public string get_kod() { return kod;}
  18.         public string get_miasto() { return miasto;}
  19.         public string get_ulica() { return ulica; }
  20.     }
  21.  
  22.     class Osoba
  23.     {
  24.         private Adres a;
  25.         private string imie, nazwisko, PESEL;
  26.         public Osoba(Adres a,string imie, string nazwisko, string PESEL)
  27.         {
  28.             this.a = a;
  29.             this.imie = imie;
  30.             this.nazwisko = nazwisko;
  31.             this.PESEL = PESEL;
  32.         }
  33.         public string get_imie() { return imie; }
  34.         public string get_nazwisko() { return nazwisko; }
  35.         public string get_PESEL() { return PESEL; }
  36.         public string get_kod() { return a.get_kod(); }
  37.         public string get_miasto() { return a.get_miasto(); }
  38.        
  39.  
  40.     }
  41.  
  42.     class Kartoteka
  43.     {
  44.         private List<Osoba> l;
  45.         public Kartoteka() { l = new List<Osoba>(); }
  46.         public void dodaj(Osoba o) { l.Add(o); }
  47.         public bool usun(Osoba o) { return l.Remove(o); }
  48.         public void wyszukaj(Osoba o)
  49.         {
  50.             Console.WriteLine("Podaj Kod");
  51.             string p = Console.ReadLine();
  52.             Console.WriteLine("Podaj PESEL");
  53.             string pes = Console.ReadLine();
  54.             if (p == o.get_kod() && pes==o.get_PESEL()) Console.WriteLine("ZAWIERA");
  55.             else  Console.WriteLine("Nie zawiera");
  56.         }
  57.     }
  58.  
  59.     class Program
  60.     {
  61.         static void Main(string[] args)
  62.         {
  63.             Kartoteka k = new Kartoteka();
  64.             Adres a = new Adres("16100", "Sokółka", "Polna");
  65.             Osoba o = new Osoba(a,"Łukasz", "Bagan", "PESEL");
  66.             k.dodaj(o);
  67.             k.wyszukaj(o);
  68.             Console.ReadKey();
  69.            
  70.            
  71.            
  72.         }
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement