public override void Add(Ring obj) { if (CheckEquality(obj)) { String[] param = obj.GetParameters(); real += Double.Parse(param[0]); imag += Double.Parse(param[1]); } else { throw new Exception(message: "Objects are different"); } }
public override void Multiply(Ring obj) { if (CheckEquality(obj)) { String[] param = obj.GetParameters(); double pReal = Double.Parse(param[0]); double pImag = Double.Parse(param[1]); double newReal = (real * pReal - imag * pImag); double newImag = (real * pImag + pReal * imag); real = newReal; imag = newImag; } else { throw new Exception(message: "Objects are different"); } }