Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Czas
- {
- private int _sekundy;
- private int _minuty;
- public Czas(int min, int sec)
- {
- _sekundy = sec;
- _minuty = min;
- }
- public static Czas operator +(Czas a, Czas b)
- {
- int sekundy = (a._sekundy + b._sekundy) % 60;
- int minuty = a._minuty + b._minuty + (a._sekundy + b._sekundy) / 60;
- return new Czas(minuty, sekundy);
- }
- public static bool operator <(Czas a, Czas b)
- {
- if (a._sekundy + a._minuty * 60 < b._sekundy + b._minuty * 60)
- return true;
- else
- return false;
- }
- public static bool operator >(Czas a, Czas b)
- {
- if (a._sekundy + a._minuty * 60 > b._sekundy + b._minuty * 60)
- return true;
- else
- return false;
- }
- public void Pokaz()
- {
- Console.WriteLine("Minut: " + _minuty + ", sekund: " + _sekundy);
- }
- public static Czas operator *(Czas a, int b)
- {
- int sekundy = (a._sekundy * b) % 60;
- int minuty = a._minuty * b + (a._sekundy * b) / 60;
- return new Czas(minuty, sekundy);
- }
- public static Czas operator *(int a, Czas b)
- {
- int sekundy = (a * b._sekundy) % 60;
- int minuty = a * b._minuty + (a * b._sekundy) / 60;
- return new Czas(minuty, sekundy);
- }
- public static Czas operator /(Czas a, int b)
- {
- int sekundy = ((a._minuty * 60 + a._sekundy) / 5) % 60;
- int minuty = ((a._minuty * 60 + a._sekundy) / 5) / 60;
- return new Czas(minuty, sekundy);
- }
- public static bool operator <=(Czas a, int b)
- {
- if (a._sekundy + a._minuty * 60 <= b * 60)
- return true;
- else
- return false;
- }
- public static bool operator >=(Czas a, int b)
- {
- if (a._sekundy + a._minuty * 60 >= b * 60)
- return true;
- else
- return false;
- }
- public static bool operator ==(Czas a, int b)
- {
- if (a._sekundy + a._minuty * 60 == b * 60)
- return true;
- else
- return false;
- }
- public static bool operator !=(Czas a, int b)
- {
- if (a._sekundy + a._minuty * 60 != b * 60)
- return true;
- else
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement