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 kartoteka.impl;
- namespace kartoteka
- {
- class Osoba
- {
- string imie = "Gall";
- string nazwisko = "Anonim";
- public Osoba(string im, string na)
- {
- imie = im;
- nazwisko = na;
- }
- public Osoba() { }
- public string getImie()
- {
- return this.imie;
- }
- public string getNazwisko()
- {
- return this.nazwisko;
- }
- }
- namespace mockup
- {
- class Kartoteka
- {
- List<Osoba> lista = new List<Osoba>();
- //dodaje osoby do listy
- public static void dodaj(kartoteka.Osoba o)
- {
- }
- //usuwa osoby z listy
- public static void usun(kartoteka.Osoba o)
- {
- }
- //pobiera rozmiar kartoteki
- public static int rozmiar()
- {
- return 1;
- }
- //zwraca prawde jezeli osoba jest w liscie
- public static bool czyZawiera(Osoba o)
- {
- return true;
- }
- //pobiera n-ta osobe
- public static Osoba pobierz(int n)
- {
- Console.WriteLine("Gall Anonim");
- return new Osoba();
- }
- }
- }
- namespace impl
- {
- class Kartoteka
- {
- public static List<Osoba> lista = new List<Osoba>();
- //dodaje osoby do listy
- public static void dodaj(Osoba o)
- {
- lista.Add(o);
- }
- //usuwa osoby z listy
- public static void usun(Osoba o)
- {
- lista.Remove(o);
- }
- //pobiera rozmiar kartoteki
- public static int rozmiar()
- {
- return lista.Count;
- }
- //zwraca prawde jezeli osoba jest w liscie
- public static bool czyZawiera(Osoba o)
- {
- return lista.Contains(o);
- }
- //pobiera n-ta osobe
- public static Osoba pobierz(int n)
- {
- Console.WriteLine(lista[n - 1].getImie() + " " + lista[n - 1].getNazwisko());
- return new Osoba(lista[n - 1].getImie(), lista[n - 1].getNazwisko());
- }
- }
- }
- }
- namespace Z5
- {
- class Program
- {
- static void Main(string[] args)
- {
- int wybor=10;
- System.Console.WriteLine("MENU:");
- System.Console.WriteLine("0. Wyjście!");
- System.Console.WriteLine("1. Dodaj osobę.");
- System.Console.WriteLine("2. Usuń osobę.");
- System.Console.WriteLine("3. Sprawdź rozmiar kartoteki.");
- System.Console.WriteLine("4. Sprawdź czy zawiera osobę.");
- System.Console.WriteLine("5. Pobierz osobę.");
- System.Console.WriteLine("");
- while (wybor!=0) {
- System.Console.WriteLine("Którą opcję wybierasz?(0-5)");
- wybor = int.Parse(Console.ReadLine());
- switch (wybor)
- {
- case 0:
- break;
- case 1:
- Console.WriteLine("Podaj imię i nazwisko osoby, którą chcesz dodać (oddziel je enterem): ");
- string ii = Console.ReadLine();
- string nn = Console.ReadLine();
- kartoteka.Osoba t = new kartoteka.Osoba(ii, nn);
- Kartoteka.dodaj(t);
- break;
- case 2:
- Console.WriteLine("Podaj imię i nazwisko osoby, którą chcesz usunąć (oddziel je enterem): ");
- string _imie = Console.ReadLine();
- string _nazwisko = Console.ReadLine();
- kartoteka.Osoba y = new kartoteka.Osoba(_imie, _nazwisko);
- Kartoteka.usun(y);
- break;
- case 3:
- int nr = Kartoteka.rozmiar();
- Console.WriteLine("Rozmiar kartoteki: "+nr);
- break;
- case 4:
- Console.WriteLine("Podaj imię i nazwisko osoby, którą chcesz sprawdzić (oddziel je enterem): ");
- string name = Console.ReadLine();
- string surname = Console.ReadLine();
- kartoteka.Osoba u = new kartoteka.Osoba(name, surname);
- if (Kartoteka.czyZawiera(u)) Console.WriteLine("Kartoteka zawiera tę osobę!");
- else Console.WriteLine("Kartoteka nie zawiera tej osoby!");
- break;
- case 5:
- Console.WriteLine("Ktorą z kolei osobę chcesz wypisać?");
- int kolej = int.Parse(Console.ReadLine());
- int max = Kartoteka.rozmiar();
- if (kolej <= max)
- {
- Kartoteka.pobierz(kolej);
- }
- else Console.WriteLine("Nie ma tyle osób w kartotece!");
- break;
- default:
- System.Console.WriteLine("Błąd danych!");
- break;
- }
- }
- System.Console.WriteLine("Koniec programu! :(");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment