Exemplo n.º 1
0
        public int GetNumberOflotteryThatDidNotPassedTheMaximum(int num)
        {
            int count = 0;

            for (int i = 0; i < m_list.Count; i++)
            {
                LotoNumbers l = m_list[i];
                if (l.numbers[5] < num)
                {
                    count++;
                }
            }
            return(count);
        }
Exemplo n.º 2
0
        public int GetNumberOflotteryBetweenMinimumToMaximum(int min, int max)
        {
            int count = 0;

            for (int i = 0; i < m_list.Count; i++)
            {
                LotoNumbers l = m_list[i];
                if ((l.numbers[5] <= max) && (l.numbers[0] >= min))
                {
                    count++;
                }
            }
            return(count);
        }
Exemplo n.º 3
0
        public int GetNumberOflotteryGreaterThanMinimum(int min)
        {
            int count = 0;

            for (int i = 0; i < m_list.Count; i++)
            {
                LotoNumbers l = m_list[i];
                if (l.numbers[0] > min)
                {
                    count++;
                }
            }
            return(count);
        }
Exemplo n.º 4
0
        public void readFile(string fileName, out int numOfRepeat)
        {
            m_list          = new List <LotoNumbers>();
            m_dicLotoString = new Dictionary <string, Tuple <int, DateTime> >();
            numOfRepeat     = 0;
            StreamReader sr;
            LotoNumbers  l = new LotoNumbers();

            try
            {
                sr = new StreamReader(fileName);
                sr.ReadLine();
                while (true)
                {
                    string line = sr.ReadLine();
                    if (line == null)
                    {
                        sr.Close();
                        numOfRepeat = 0;
                        return;
                    }
                    string[] lData = line.Split(new Char[] { ',' });
                    l         = new LotoNumbers();
                    l.numbers = new byte[6];

                    l.lotoNumber = int.Parse(lData[0]);


                    string[] dTemp    = lData[1].Split(new Char[] { '-' });
                    string   goodDate = int.Parse(dTemp[1]).ToString("00") + "/" + int.Parse(dTemp[0]).ToString("00") + "/" + getYear(dTemp[2]);

                    l.date       = DateTime.ParseExact(goodDate, "MM/dd/yyyy", CultureInfo.InvariantCulture);
                    l.numbers[0] = byte.Parse(lData[2]);
                    l.numbers[1] = byte.Parse(lData[3]);
                    l.numbers[2] = byte.Parse(lData[4]);
                    l.numbers[3] = byte.Parse(lData[5]);
                    l.numbers[4] = byte.Parse(lData[6]);
                    l.numbers[5] = byte.Parse(lData[7]);

                    if (l.numbers[3] > 37)
                    {
                        Console.WriteLine(line);
                        continue;
                    }
                    if (l.numbers[4] > 37)
                    {
                        Console.WriteLine(line);
                        continue;
                    }
                    if (l.numbers[5] > 37)
                    {
                        Console.WriteLine(line);
                        continue;
                    }


                    string str = string.Empty;
                    for (int i = 0; i < 6; i++)
                    {
                        str += l.numbers[i].ToString();
                        if (i < 5)
                        {
                            str += ",";
                        }
                    }
                    try
                    {
                        m_dicLotoString.Add(str, new Tuple <int, DateTime>(l.lotoNumber, l.date));
                    }
                    catch (Exception err)
                    {
                        numOfRepeat++;
                    }

                    l.strongNum = byte.Parse(lData[8]);
                    m_list.Add(l);
                }
            }
            catch (Exception err)
            {
                throw (new SystemException("Loto number error:" + l.lotoNumber + Environment.NewLine + err.Message));
            }
        }