Advertisement
Danielos168

Untitled

Jun 24th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 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 Zad4
  8. {
  9. interface IOdleglosc<T>
  10. {
  11. int Odleglosc(T a, T b);
  12. }
  13.  
  14. class Dystans : IOdleglosc<int>
  15. {
  16. public int Odleglosc(int a, int b)
  17. {
  18. return b - a;
  19. }
  20. }
  21.  
  22. class Osoba
  23. {
  24. public string nazwisko;
  25. public int waga;
  26.  
  27. public Osoba(string nazwisko, int waga)
  28. {
  29. this.nazwisko = nazwisko;
  30. this.waga = waga;
  31. }
  32. }
  33.  
  34. class Roznica : IOdleglosc<Osoba>
  35. {
  36. public int Odleglosc(Osoba a, Osoba b)
  37. {
  38. return b.nazwisko.Length - a.nazwisko.Length;
  39. }
  40. }
  41.  
  42. class Program
  43. {
  44. static List<T> Filtruj<T>(List<T> list,IOdleglosc<T> odleglosc, T t, int promien)
  45. {
  46. list.Sort(odleglosc);
  47. }
  48. static void Main(string[] args)
  49. {
  50. }
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement