Esempio n. 1
0
        static void Main(string[] args)
        {
            Introduction Intro = new Introduction("PolynomialWcf solver (Client Application)");

            Intro.Greeting();

            ConsoleKeyInfo keyInfo;
            bool           next = true;

            IPolynomialReader          reader = new ConsolePolynomialReader();
            BaseStringPolynomialFormer former = new BaseStringPolynomialFormer();

            PolynomialClient client = new PolynomialClient();

            do
            {
                Console.Write("Press any key to solve polinomial(q to quit): ");
                keyInfo = Console.ReadKey(true);
                Console.Clear();
                if (keyInfo.KeyChar == 'q')
                {
                    next = false;
                }
                else
                {
                    int      power   = reader.ReadPower();
                    double[] factors = reader.ReadFactors(power);

                    try
                    {
                        Console.WriteLine(
                            $"Solution: {client.GetPolynomialSolution(former.Form(new PolynomialItem(power, factors, null, 0)))}");
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Host is not launched!");
                        next = false;
                        Console.ReadLine();
                    }
                }
            } while (next);

            Intro.Parting();
        }
Esempio n. 2
0
        protected void Find()
        {
            int index;
            IPolynomialReader reader = new ConsolePolynomialReader();

            if (0 == service.Solutions.Count)
            {
                Console.WriteLine("No solutions found!\n");
                return;
            }
            do
            {
                index = reader.ReadInteger("index of the solution");
                if (index < 1 || index > service.Solutions.Count)
                {
                    Console.WriteLine("No such index found!\n");
                }
            } while (index < 1 || index > service.Solutions.Count);

            Console.WriteLine("\n" + service.FullStringFormer.Form(service.Solutions[service.Solutions.Count - 1]) + "\n");
        }