Advertisement
DiaxPlayer

Untitled

Feb 7th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.59 KB | None | 0 0
  1. class Czas
  2.     {
  3.         private int _sekundy;
  4.         private int _minuty;
  5.         public Czas(int min, int sec)
  6.         {
  7.             _sekundy = sec;
  8.             _minuty = min;
  9.         }
  10.         public static Czas operator +(Czas a, Czas b)
  11.         {
  12.             int sekundy = (a._sekundy + b._sekundy) % 60;
  13.             int minuty = a._minuty + b._minuty + (a._sekundy + b._sekundy) / 60;
  14.             return new Czas(minuty, sekundy);
  15.         }
  16.  
  17.         public static bool operator <(Czas a, Czas b)
  18.         {
  19.             if (a._sekundy + a._minuty * 60 < b._sekundy + b._minuty * 60)
  20.                 return true;
  21.             else
  22.                 return false;
  23.         }
  24.         public static bool operator >(Czas a, Czas b)
  25.         {
  26.             if (a._sekundy + a._minuty * 60 > b._sekundy + b._minuty * 60)
  27.                 return true;
  28.             else
  29.                 return false;
  30.         }
  31.         public void Pokaz()
  32.         {
  33.             Console.WriteLine("Minut: " + _minuty + ", sekund: " + _sekundy);
  34.         }
  35.         public static Czas operator *(Czas a, int b)
  36.         {
  37.             int sekundy = (a._sekundy * b) % 60;
  38.             int minuty = a._minuty * b + (a._sekundy * b) / 60;
  39.             return new Czas(minuty, sekundy);
  40.         }
  41.               public static Czas operator *(int a, Czas b)
  42.         {
  43.             int sekundy = (a * b._sekundy) % 60;
  44.             int minuty = a * b._minuty + (a * b._sekundy) / 60;
  45.             return new Czas(minuty, sekundy);
  46.         }
  47.         public static Czas operator /(Czas a, int b)
  48.         {
  49.             int sekundy = ((a._minuty * 60 + a._sekundy) / 5) % 60;
  50.             int minuty = ((a._minuty * 60 + a._sekundy) / 5) / 60;
  51.             return new Czas(minuty, sekundy);
  52.         }
  53.         public static bool operator <=(Czas a, int b)
  54.         {
  55.             if (a._sekundy + a._minuty * 60 <= b * 60)
  56.                 return true;
  57.             else
  58.                 return false;
  59.         }
  60.         public static bool operator >=(Czas a, int b)
  61.         {
  62.             if (a._sekundy + a._minuty * 60 >= b * 60)
  63.                 return true;
  64.             else
  65.                 return false;
  66.         }
  67.         public static bool operator ==(Czas a, int b)
  68.         {
  69.             if (a._sekundy + a._minuty * 60 == b * 60)
  70.                 return true;
  71.             else
  72.                 return false;
  73.         }
  74.         public static bool operator !=(Czas a, int b)
  75.         {
  76.             if (a._sekundy + a._minuty * 60 != b * 60)
  77.                 return true;
  78.             else
  79.                 return false;
  80.         }
  81.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement