public static TriggerJK operator *(TriggerJK x, double y) { TriggerJK ans = new TriggerJK(); ans.a = x.a * y; ans.b = x.b * y; return(ans); }
public static TriggerJK operator -(TriggerJK x, TriggerJK y) { TriggerJK ans = new TriggerJK(); ans.a = x.a - y.a; ans.b = x.b - y.b; return(ans); }
public static TriggerJK operator /(TriggerJK x, double y) { if (y == 0.0) { throw new DivideByZeroException(); } TriggerJK ans = new TriggerJK(); ans.a = x.a / y; ans.b = x.b / y; return(ans); }
public override bool Equals(object x) { TriggerJK obj = (TriggerJK)x; if (a == obj.a && b == obj.b) { return(true); } else { return(false); } }
static void Main() { try { Console.WriteLine("Starting test . .\n");//тестуєм . . Register register = new Register("Test register"); register.AddTrigger(new TriggerRS()); register.AddTrigger(new TriggerJK()); register.AddTrigger(new TriggerRS()); register.GetTriggersState(); foreach (Trigger t in register) { if (t is TriggerRS) { TriggerRS temp = (TriggerRS)t; temp.GiveSignaltoSinput(); } if (t is TriggerJK) { TriggerJK temp = (TriggerJK)t; temp.GiveSignaltoJinput(); } } register.GetTriggersState(); register.DeleteTrigger(2);//витерли останній тригер try { register.DeleteTrigger(10); } catch (IndexOutOfRangeException) { Console.WriteLine("IndexOutOfRangeException"); } } catch (Exception e) { Console.WriteLine(e.Message); Console.ReadLine(); return; } Console.WriteLine("Test has been succesfully finished . ."); Console.ReadLine(); }