Guest User

Untitled

a guest
May 25th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.33 KB | None | 0 0
  1.     public class Publikacja : IComparable<Publikacja>
  2.     {
  3.         protected int id; //0 -publikacja 1-artykul 2-ksiazka
  4.         protected string tytul;
  5.         protected string autorzy;
  6.         protected int rokwydania;
  7.  
  8.         public int CompareTo(Publikacja p)
  9.         {
  10.             if (p != null)
  11.             {
  12.                 int i = 0;
  13.                 if (!this.Autorzy.Contains(p.Autorzy) && !p.Autorzy.Contains(this.Autorzy))
  14.                     i++;
  15.                 if (!this.Tytul.Contains(p.Tytul) && !p.Tytul.Contains(this.Tytul))
  16.                     i++;
  17.                 if (this.RokWydania != p.RokWydania && p.RokWydania != 0 && this.RokWydania!=0)
  18.                     i++;
  19.                 return i;
  20.             }
  21.             return -1;
  22.         }
  23. }
  24.     public class Artykuł : Publikacja
  25.     {
  26.  
  27.         private string wydawnictwo;
  28.         private string tagi;
  29.  
  30.         public int CompareTo(Artykuł p)
  31.         {
  32.             if (p != null)
  33.             {
  34.                 int i = base.CompareTo(p);
  35.                 if (!this.Wydawnictwo.Contains(p.Wydawnictwo) && !p.Wydawnictwo.Contains(this.Wydawnictwo))
  36.                     i++;
  37.                 if (!this.Tagi.Contains(p.Tagi) && !p.Tagi.Contains(this.Tagi))
  38.                     i++;
  39.                 return i;
  40.             }
  41.             return -1;
  42.         }
  43. }
Add Comment
Please, Sign In to add comment