Esempio n. 1
0
        static void Main(string[] args)
        {
            List <string> Command = new List <string>();
            List <int>    XList   = new List <int>();

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("Enter First polynomial number :");
            Console.ForegroundColor = ConsoleColor.White;
            string Pol1 = Console.ReadLine();


            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("Enter Second polynomial number :");
            Console.ForegroundColor = ConsoleColor.White;
            string Pol2 = Console.ReadLine();

            Polynomial polymer = new Polynomial(Pol1, Pol2);

            // take command from user ;   + for sum
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("Enter Commands :  (+ for sum    - for subtraction   . to set X     ; to finish");
            Console.ForegroundColor = ConsoleColor.White;

            int com = 0;

            string commend;

            commend = Console.ReadLine();
            Command.Add(commend);
            while (Command[com] != ";")
            {
                if (Command[com] == ".")
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.Write("Enter X >> ");
                    Console.ForegroundColor = ConsoleColor.White;
                    int xvalue = int.Parse(Console.ReadLine());
                    XList.Add(xvalue);
                }
                commend = Console.ReadLine();
                Command.Add(commend);
                com++;
            }
            int XIndex = 0;

            for (int i = 0; i < Command.Count; i++)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                if (Command[i] == "+")
                {
                    polymer.Sum();
                }
                else if (Command[i] == "-")
                {
                    polymer.Subtraction();
                }
                else if (Command[i] == ".")
                {
                    polymer.SetX(XList[XIndex]);
                    XIndex++;
                }
            }



            Console.ForegroundColor = ConsoleColor.White;

            Console.Write("\n\n\n\n <<Finish>>   -------------> Developed By :");
            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.Write(" <Aryana.Bkh>");
            Console.ForegroundColor = ConsoleColor.White;

            Console.Write("\n\t\t\t     My Github   : ");
            Console.ForegroundColor = ConsoleColor.Magenta;

            Console.Write("https://github.com/AryanaBakhshandeh ");
            Console.ReadKey();
        }