الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

أرجوا المساعدة يا شباب

بدأه jMustafa في 31 مايو 2014 · 3 رد · 469 مشاهدة · في Microsoft Visual C#.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم 
ودي أعمل ألة حسبة لكن من دون أستخدام أزرار تقرأ ما يكتب. عندي مشكلة في قرأة النص مثلا لو أدخلت 4594.654n+74 سيخد 4594.65474

public bool isNumber(String line)        {            bool isIt = false;            bool run = true;            String strNumaricValue ="";            double Value;                        // spilled the line           for(int i = 0 ; i <line.Length; i++)           {                // chech each char in line                for (int j = 0; j < NUMARIC.Length; j++)                {                    // check if it's a unmber                    if (line == NUMARIC[j])                    {                        Console.WriteLine("test");                        strNumaricValue += line.ToString();                    }                    // stop if it's not a number                    else                    {                        run = false;                        break;                    }                }                if (!run)                {                    break;                }            }                        // convert and add number            for (int k = 0; k < NUMARIC.Length ; k++ )            {                if (strNumaricValue.Length >= 0 && strNumaricValue[0] == NUMARIC[k] )                {                    Value = Convert.ToDouble(strNumaricValue);                    numaric.addNumber(Value);                    isIt = true;                }            }            return isIt;        }//end of IsNumber
#2

بعد التطوير #3  

 

أحصل علي خطء Object reference not set to an instance of an object

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Collections;namespace ConsoleApplication32{        class Reader    {        private static Operator operators = new Operator();        private static Numaric numaric = new  Numaric();                        Char[] NUMARIC = {'0','1','2','3','4','5','6','7','8','9','.'};        Char[] OP = {'+','-','*','/'};        Char EQUAL = '=';        Char SPACE = ' ';        static String _line = " ";        String[] strNumaricValue = new String[100];        public Reader()        {         }                public Reader(String line)        {            _line = line;                    }                public bool isNumber(String line)        {            bool isIt = false;            bool run = true;            double Value;            int ii = 0;            // spilled the line           for(int i = 0 ; i <line.Length; i++)           {                 // chech each char in line                for (int j = 0; j < NUMARIC.Length; j++)                {                    // check if it's a number                    if (line == NUMARIC[j])                    {                        Console.WriteLine("test number ii = {0}",ii);                        numberKeeper(line,ii);                    }                                       //                    if (line!= NUMARIC)                    {                        if (line == OP[j % 4] && (j % 4) == j)                        {                            ii++;                            Console.WriteLine("test OP");                        }                    }                }            }                       for (int q = 0; q < strNumaricValue.Length; q++)           {               // convert and add number               for (int k = 0; k < NUMARIC.Length ; k++)               {                   //fixed me                   if (strNumaricValue[q].Length >= 0 && strNumaricValue[q][0] == NUMARIC[k])                   {                       Value = Convert.ToDouble(strNumaricValue[q]);                       Console.WriteLine(Value);                       numaric.addNumber(Value);                       isIt = true;                   }               }           }            return isIt;        }//end of IsNumber        /// <summary>        ///         /// </summary>        /// <param name="num"></param>        void numberKeeper(Char num,int strPostion =0)        {            strNumaricValue[strPostion] += num.ToString();        }            }}

تم تعديل هذه المشاركة بواسطة jMustafa في 31 مايو 2014 في 17:46

#3

لا أزال أحاول 

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Collections;namespace ConsoleApplication32{        class Reader    {        private static Operator operators = new Operator();        private static Numaric numaric = new  Numaric();                        Char[] NUMARIC = {'0','1','2','3','4','5','6','7','8','9','.'};        Char[] OP = {'+','-','*','/'};        Char EQUAL = '=';        Char SPACE = ' ';        static String _line = " ";        static Int64 STR_NUM_VALUE_LEN = _line.Length;        String[] strNumaricValue;        public Reader()        {         }                public Reader(String line)        {            _line = line;                    }                public bool isNumber()        {            bool isIt = false;            bool run = true;            double Value;            int ii = 0;            // spilled the line           for(int i = 0 ; i <_line.Length; i++)           {                 // chech each char in line                for (int j = 0; j < NUMARIC.Length; j++)                {                    // check if it's a number                    if (_line == NUMARIC[j])                    {                        Console.WriteLine("test number ii = {0}",ii);                        numberKeeper(_line,ii);                    }                                       //                    if (_line!= NUMARIC)                    {                        if (_line == OP[j % 4] && (j % 4) == j)                        {                            ii++;                            Console.WriteLine("test OP");                        }                    }                }            }            //FIXED ME           for (int kk = 0; kk < strNumaricValue.Length; kk++)           {                   // convert and add number                for (int k = 0; k < NUMARIC.Length; k++)                   {                       //fixed me                   if (strNumaricValue[kk].Length >= 0 && strNumaricValue[kk][0] == NUMARIC[k])                    {                           Value = Convert.ToDouble(strNumaricValue[kk]);                           Console.WriteLine( "v ={0}",Value);                           numaric.addNumber(Value);                           isIt = true;                   }                   }           }            return isIt;        }//end of IsNumber        /// <summary>        ///         /// </summary>        /// <param name="num"></param>        void numberKeeper(Char num,int strPostion =0)        {            int setlenght = strPostion;            if (strPostion <= 0 || strPostion == 1)            {                setlenght = _line.Length * _line.Length;            }            else if (strPostion > 1)            {                setlenght = ((int)Math.Ceiling(Math.Pow(strPostion, strPostion))) + _line.Length;            }                     strNumaricValue = new String[_line.Length + strPostion];            strNumaricValue[strPostion] += num.ToString();        }            }}
#4

محاولة لتعديل لم أصل إلى نتيجة

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Collections;namespace ConsoleApplication32{        class Reader    {        //        private static Operator operators = new Operator();        private static Numaric numaric = new  Numaric();                //        Char[] NUMARIC = {'0','1','2','3','4','5','6','7','8','9','.'};        Char[] OP = {'+','-','*','/'};        Char EQUAL = '=';        Char SPACE = ' ';                //        String line;        String[] strNumaricValue;        /// <summary>        ///         /// </summary>        public Reader()        {         }                /// <summary>        ///         /// </summary>        /// <param name="line"></param>        public Reader(String line)        {            this.line = line;                    }                /// <summary>        ///         /// </summary>        /// <returns></returns>        public bool isNumber()        {            bool isIt = false;            int ii = 0;            // spilled the line           for(int i = 0 ; i <line.Length; i++)           {                 // chech each char in line                for (int j = 0; j < NUMARIC.Length; j++)                {                    // check if it's a number                    if (line == NUMARIC[j])                    {                        Console.WriteLine("test number ii = {0}",ii);                        numberKeeper(line,ii);                    }                                       //                    if (line!= NUMARIC)                    {                        if (line == OP[j % 4] && (j % 4) == j)                        {                            ii++;                            Console.WriteLine("test OP");                        }                    }                }            }            return isIt;        }//end of IsNumber        /// <summary>        ///         /// </summary>        /// <param name="num"></param>        void numberKeeper(Char num,int strPostion =0)        {            double Value = 0.00;            int revPostion = 0 ;            if (strPostion>0)            {                revPostion = strPostion - 1;            }            strNumaricValue = new String[strPostion + 1];            strNumaricValue[strPostion] += num.ToString();            if (revPostion>= 0)            {                Console.WriteLine("revPostion = {0}  strPostion = {1}", revPostion, strPostion);                if (revPostion == strPostion - 1)                {                    Value = Convert.ToDouble(strNumaricValue[revPostion]);                    Console.WriteLine("value = {0}",Value);                    numaric.addNumber(Value);                }            }        }            }}

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…