static void Main() { ComplexNumber number1 = new ComplexNumber(1, 2); ComplexNumber number2 = new ComplexNumber(1, 2); ComplexNumber number3 = new ComplexNumber(1, 3); System.Console.WriteLine(number1.CompareTo(number2)); System.Console.WriteLine(number1.CompareTo(number3)); }
static void Main() { ComplexNumber referenceA = new ComplexNumber(1, 2); ComplexNumber referenceB = new ComplexNumber(1, 2); ComplexNumber referenceC = new ComplexNumber(1, 3); System.Console.WriteLine("Result of referenceA.CompareTo(referenceB) is {0}", referenceA.CompareTo(referenceB)); System.Console.WriteLine("Result of referenceA.CompareTo(referenceC) is {0}", referenceA.CompareTo(referenceC)); }
public void CompareToTest() { var testVar2 = new ComplexNumber(1, 1); _testVar = new ComplexNumber(2, 2); Assert.Equal(1, _testVar.CompareTo(testVar2)); _testVar = new ComplexNumber(1, 1); Assert.Equal(0, _testVar.CompareTo(testVar2)); _testVar = new ComplexNumber(); Assert.Equal(-1, _testVar.CompareTo(testVar2)); testVar2 = new ComplexNumber(); Assert.Equal(0, _testVar.CompareTo(testVar2)); }
public void TestCompareToOnSameComplexNumbers() { ComplexNumber firstComplexNumber = new ComplexNumber(-2, 6); ComplexNumber secondComplexNumber = new ComplexNumber(-2, 6); Assert.IsTrue(firstComplexNumber.CompareTo(secondComplexNumber) == 0); }
public void TestCompareToOnDifferentInCorrectOrderComplexNumbers() { ComplexNumber firstComplexNumber = new ComplexNumber(-2, 1); ComplexNumber secondComplexNumber = new ComplexNumber(1, 3); Assert.IsTrue(firstComplexNumber.CompareTo(secondComplexNumber) < 0); }
public void TestComplexNumberClone() { ComplexNumber a = new ComplexNumber(5, 1); ComplexNumber b = a.Clone() as ComplexNumber; Assert.True(b.CompareTo(a) == 0); }
public void TestComplexNumberSubstract() { ComplexNumber a = new ComplexNumber(5, 2); ComplexNumber b = new ComplexNumber(15, 3); ComplexNumber c = new ComplexNumber(10, 1); b = b.Subtract(a) as ComplexNumber; Assert.True(b.CompareTo(c) == 0); }
public void TestComplexNumberMultiply() { ComplexNumber a = new ComplexNumber(5, 2); ComplexNumber b = new ComplexNumber(15, 3); ComplexNumber c = new ComplexNumber(69, 45); a = a.Multiply(b) as ComplexNumber; Assert.True(a.CompareTo(c) == 0); }
public void TestComplexNumberAdd() { ComplexNumber a = new ComplexNumber(5, 2); ComplexNumber b = new ComplexNumber(15, 3); ComplexNumber c = new ComplexNumber(20, 5); a = a.Add(b) as ComplexNumber; Assert.True(a.CompareTo(c) == 0); }
static void Main() { ComplexNumber num1 = new ComplexNumber(1, 3); ComplexNumber num2 = new ComplexNumber(1, 2); int result = num1.CompareTo(num2); // Now, try the type-generic version result = ((IComparable)num1).CompareTo(num2); }
public override void RunExample() { List <ComplexNumber> numbers = new List <ComplexNumber>() { new ComplexNumber(0, 1), new ComplexNumber(0, 2), new ComplexNumber(1, 0), new ComplexNumber(1, 2), new ComplexNumber(0, 4), new ComplexNumber(-1, 0) }; SortingExample(numbers); var number1 = new ComplexNumber(0, 1); var number2 = new ComplexNumber(1, 0); Console.WriteLine(number1.CompareTo(number2)); Console.WriteLine(number2.CompareTo(number1)); Console.WriteLine(number2.CompareTo(number2)); //Console.WriteLine(number1.CompareTo(10)); }