示例#1
0
        static void ComplexNumberArithmetics(IComplexNumber channel, Complex z1, Complex z2, IMessenger messenger)
        {
            try
            {
                var builder = new StringBuilder();

                builder.AppendFormat("\n*** Complex Number Arithmetics ***\n\n");
                builder.AppendFormat("{0} + {1} = {2}\n", f(z1), f(z2), f(channel.Add(z1, z2)));
                builder.AppendFormat("{0} - {1} = {2}\n", f(z1), f(z2), f(channel.Subtract(z1, z2)));
                builder.AppendFormat("{0} * {1} = {2}\n", f(z1), f(z2), f(channel.Multiply(z1, z2)));
                builder.AppendFormat("{0} / {1} = {2}\n", f(z1), f(z2), f(channel.Divide(z1, z2)));
                builder.AppendFormat("Conjugate[{0}] = {1}\n", f(z1), f(channel.Conjugate(z1)));
                builder.AppendFormat("Conjugate[{0}] = {1}\n", f(z2), f(channel.Conjugate(z2)));
                builder.AppendFormat("Recipocal[{0}] = {1}\n", f(z1), f(channel.Recipocal(z1)));
                builder.AppendFormat("Recipocal[{0}] = {1}\n", f(z2), f(channel.Recipocal(z2)));
                builder.AppendFormat("Modulus[{0}] = {1}\n", f(z1), channel.Modulus(z1));
                builder.AppendFormat("Modulus[{0}] = {1}\n", f(z2), channel.Modulus(z2));
                builder.AppendFormat("Argument[{0}] = {1} Radians\n", f(z1), channel.Argument(z1));
                builder.AppendFormat("Argument[{0}] = {1} Radians\n", f(z2), channel.Argument(z2));

                var msg = builder.ToString();
                Console.WriteLine(msg);
                messenger.SendMessage(msg);
            }
            catch (Exception fx)
            {
                Console.WriteLine(fx.Message);
            }
        }
示例#2
0
 static void ComplexNumberArithmetics(IComplexNumber channel, Complex z1, Complex z2)
 {
     try
     {
         Console.WriteLine("{0} + {1} = {2}", f(z1), f(z2), f(channel.Add(z1, z2)));
         Console.WriteLine("{0} - {1} = {2}", f(z1), f(z2), f(channel.Subtract(z1, z2)));
         Console.WriteLine("{0} * {1} = {2}", f(z1), f(z2), f(channel.Multiply(z1, z2)));
         Console.WriteLine("{0} / {1} = {2}", f(z1), f(z2), f(channel.Divide(z1, z2)));
         Console.WriteLine("Conjugate[{0}] = {1}", f(z1), f(channel.Conjugate(z1)));
         Console.WriteLine("Conjugate[{0}] = {1}", f(z2), f(channel.Conjugate(z2)));
         Console.WriteLine("Recipocal[{0}] = {1}", f(z1), f(channel.Reciprocal(z1)));
         Console.WriteLine("Recipocal[{0}] = {1}", f(z2), f(channel.Reciprocal(z2)));
         Console.WriteLine("Modulus[{0}] = {1}", f(z1), channel.Modulus(z1));
         Console.WriteLine("Modulus[{0}] = {1}", f(z2), channel.Modulus(z2));
         Console.WriteLine("Argument[{0}] = {1} Radians", f(z1), channel.Argument(z1));
         Console.WriteLine("Argument[{0}] = {1} Radians", f(z2), channel.Argument(z2));
     }
     catch (Exception fx)
     {
         Console.WriteLine(fx.Message);
     }
 }