Gleave's Profile User Rating: -----

Reputation: 6 Worker
Group:
Members
Active Posts:
46 (0.04 per day)
Joined:
06-December 10
Profile Views:
1,251
Last Active:
User is offline Sep 26 2012 06:56 PM
Currently:
Offline

Previous Fields

Country:
Who Cares
OS Preference:
Who Cares
Favorite Browser:
Who Cares
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:
0
Icon   Gleave lottery number hunting

Posts I've Made

  1. In Topic: Solving the lottery with C#, this should be fun!

    Posted 26 Sep 2012

    Ok I took out goto's and replaced them with whiles. The program stopped freezing!!! Now the only problem is when I try to remove duplicates its not seeming to get them all. Here is updated code.
    
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.IO;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    namespace OhioRollingCash5App
    {
        public partial class frmMain : Form
        {
            private TextBox tbmain = new TextBox();
    
            private Button bgen = new Button();
            private Button bclear = new Button();
    
            private Label lblpickone = new Label();
            private Label lblpicktwo = new Label();
            private Label lblpickthree = new Label();
            private Label lblpickfour = new Label();
            private Label lblpickfive = new Label();
    
            private Label lblone = new Label();
            private Label lbltwo = new Label();
            private Label lblthree = new Label();
            private Label lblfour = new Label();
            private Label lblfive = new Label();
    
            private RadioButton rMon = new RadioButton();
            private RadioButton rTue = new RadioButton();
            private RadioButton rWed = new RadioButton();
            private RadioButton rThu = new RadioButton();
            private RadioButton rFri = new RadioButton();
            private RadioButton rSat = new RadioButton();
            private RadioButton rSun = new RadioButton();
    
            //vars for each actual number
            //these are used to hold the numbers
            //actual value and other data about 
            //the number
            List<Number> allnumobjs = new List<Number>();
    
            //number priority lists
            List<int> hotnums = new List<int>();
            List<int> midnum = new List<int>();
            List<int> coldnums = new List<int>();
    
            //list to hold the picks
            List<int> allpicks = new List<int>();
    
            //List<int> poolone = new List<int>();
            //List<int> pooltwo = new List<int>();
    
            public frmMain()
            {
                #region properties
    
                //size of the form
                Size = new Size(638, 645);
                //form title
                this.Text = "Rolling Cash 5";
    
                //button properties
                bgen.Location = new Point(262, 45);
                bgen.Width = 88;
                bgen.Height = 41;
                bgen.Text = "Generate";
    
                bclear.Location = new Point(382, 45);
                bclear.Width = 88;
                bclear.Height = 41;
                bclear.Text = "Clear";
    
                //textbox properties
                tbmain.Width = 202;
                tbmain.Height = 513;
                tbmain.Location = new Point(29, 45);
                tbmain.Multiline = true;
                tbmain.ReadOnly = true;
                tbmain.ScrollBars = ScrollBars.Vertical;
                tbmain.BackColor = Color.White;
    
                //label locations
                //label sizes, generic
                Size lblSize = new Size(61, 21);
    
                lblone. Location = new Point(258, 113);
                lblone.Size = lblSize;
                lblone.Font = new Font("Times New Roman", 10.8f, FontStyle.Regular);
                lblone.Text = "Pick 1:";
    
                lbltwo.Location = new Point(258, 163);
                lbltwo.Size = lblSize;
                lbltwo.Font = new Font("Times New Roman", 10.8f, FontStyle.Regular);
                lbltwo.Text = "Pick 2:";
    
                lblthree.Location = new Point(258, 213);
                lblthree.Size = lblSize;
                lblthree.Font = new Font("Times New Roman", 10.8f, FontStyle.Regular);
                lblthree.Text = "Pick 3:";
    
                lblfour.Location = new Point(258, 263);
                lblfour.Size = lblSize;
                lblfour.Font = new Font("Times New Roman", 10.8f, FontStyle.Regular);
                lblfour.Text = "Pick 4:";
    
                lblfive.Location = new Point(258, 313);
                lblfive.Size = lblSize;
                lblfive.Font = new Font("Times New Roman", 10.8f, FontStyle.Regular);
                lblfive.Text = "Pick 5:";
    
                //display labels
                lblpickone.Location = new Point(350, 113);
                lblpickone.Size = lblSize;
                lblpickone.Font = new Font("Times New Roman", 10.8f, FontStyle.Regular);
    
                lblpicktwo.Location = new Point(350, 163);
                lblpicktwo.Size = lblSize;
                lblpicktwo.Font = new Font("Times New Roman", 10.8f, FontStyle.Regular);
    
                lblpickthree.Location = new Point(350, 213);
                lblpickthree.Size = lblSize;
                lblpickthree.Font = new Font("Times New Roman", 10.8f, FontStyle.Regular);
    
                lblpickfour.Location = new Point(350, 263);
                lblpickfour.Size = lblSize;
                lblpickfour.Font = new Font("Times New Roman", 10.8f, FontStyle.Regular);
    
                lblpickfive.Location = new Point(350, 313);
                lblpickfive.Size = lblSize;
                lblpickfive.Font = new Font("Times New Roman", 10.8f, FontStyle.Regular);
    
                //radio button size generic
                Size rsize = new Size(120, 26);
    
                //radio button properties
                rMon.Location = new Point(252, 403);
                rMon.Size = rsize;
                rMon.Font = new Font("Times New Roman", 10.8f, FontStyle.Regular);
                rMon.Text = "Monday";
    
                rTue.Location = new Point(373, 403);
                rTue.Size = rsize;
                rTue.Font = new Font("Times New Roman", 10.8f, FontStyle.Regular);
                rTue.Text = "Tuesday";
    
                rWed.Location = new Point(494, 403);
                rWed.Size = rsize;
                rWed.Font = new Font("Times New Roman", 10.8f, FontStyle.Regular);
                rWed.Text = "Wednesday";
    
                rThu.Location = new Point(252, 469);
                rThu.Size = rsize;
                rThu.Font = new Font("Times New Roman", 10.8f, FontStyle.Regular);
                rThu.Text = "Thursday";
    
                rFri.Location = new Point(373, 469);
                rFri.Size = rsize;
                rFri.Font = new Font("Times New Roman", 10.8f, FontStyle.Regular);
                rFri.Text = "Friday";
    
                rSat.Location = new Point(494, 469);
                rSat.Size = rsize;
                rSat.Font = new Font("Times New Roman", 10.8f, FontStyle.Regular);
                rSat.Text = "Saturday";
    
                rSun.Location = new Point(373, 535);
                rSun.Size = rsize;
                rSun.Font = new Font("Times New Roman", 10.8f, FontStyle.Regular);
                rSun.Text = "Sunday";
                #endregion
    
                #region events
                //register event handles
                bgen.Click += new EventHandler(bgen_Click);
                bclear.Click += new EventHandler(bclear_Click);
                #endregion
    
                #region numobjs
     
                for (int i = 1; i <= 39; i++)
                {
                    allnumobjs.Add(new Number()
                    {
                        A_Val = i,
                        Is_Even = (i % 2 == 0),
                        Is_Odd = (i % 2 !=0)
                    });
                }
                #endregion
    
                #region readintext
    
                //reading in the file
                int counter = 0;
                string line;
    
                //list to add the results to
                List<string> ipicks = new List<string>();
    
                //read in results
                StreamReader sr = new StreamReader(@"C:\Users\Technology\Desktop\cashfivelotto.txt");
    
                //iterate through the text file, until we reach the end
                while ((line = sr.ReadLine()) != null)
                {
                    //remove the comma's from the file and store the numbers in numset 
                    char[] delimiters = new char[] { ',' };
                    string[] numset = line.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
    
                    for (int i = 0; i < numset.Length; i++)
                    {
                        //counter for line numbers and formatting 
                        counter++;
    
                        if (counter % 6 == 0)
                        {
                            //add the text 
                            tbmain.Text += line + System.Environment.NewLine;
    
                            //enumerate values for each number
                            //based on netvalues and day values
                            for (int j = 1; j < numset.Length; j++)
                            {
                                foreach(Number n in allnumobjs)
                                {
                                    if(n.A_Val == int.Parse(numset[j]))
                                    {
                                        n.Net_Val += 1;
    
                                        if (numset[0] == "MON")
                                        {
                                            n.Monday += 1;
                                        }
                                        else if (numset[0] == "TUE")
                                        {
                                            n.Tuesday += 1;
                                        }
                                        else if (numset[0] == "WED")
                                        {
                                            n.Wednesday += 1;
                                        }
                                        else if (numset[0] == "THU")
                                        {
                                            n.Thursday += 1;
                                        }
                                        else if (numset[0] == "FRI")
                                        {
                                            n.Friday += 1;
                                        }
                                        else if (numset[0] == "SAT")
                                        {
                                            n.Saturday += 1;
                                        }
                                        else
                                        {
                                            n.Sunday += 1;
                                        }
                                    }
                                }
                            }
                        }
                        ipicks.Add(numset[i]);
                    }
                    //sr.Close();
                }
                //close streamreader
                sr.Close();
                #endregion
    
                #region lists
    
                int average = 0;
    
                foreach (Number n in allnumobjs)
                {
                    average += n.A_Val;
                    if (n.Net_Val >= 23)
                    {
                        hotnums.Add(n.A_Val);
                    }
                    else if (n.Net_Val <= 22)
                    {
                        coldnums.Add(n.A_Val);
                    }
    
                }
    
                average = average / allnumobjs.Count;
    
                //eliminate doubles from the lists
                foreach (int i in coldnums)
                {
                    for (int x = 0; x < hotnums.Count; x++)
                    {
                        if (i == hotnums[x])
                        {
                            hotnums.Remove(x);
                        }
                    }
                }
    
               // lblpickone.Text = hotnums.Count.ToString();
               // lblpickfive.Text = coldnums.Count.ToString();
         
                #endregion
    
                #region addcontrols
                //add the controls to the form
                Controls.Add(tbmain);
    
                Controls.Add(bgen);
                Controls.Add(bclear);
    
                Controls.Add(lblone);
                Controls.Add(lbltwo);
                Controls.Add(lblthree);
                Controls.Add(lblfour);
                Controls.Add(lblfive);
    
                Controls.Add(lblpickone);
                Controls.Add(lblpicktwo);
                Controls.Add(lblpickthree);
                Controls.Add(lblpickfour);
                Controls.Add(lblpickfive);
    
                Controls.Add(rMon);
                Controls.Add(rTue);
                Controls.Add(rWed);
                Controls.Add(rThu);
                Controls.Add(rFri);
                Controls.Add(rSat);
                Controls.Add(rSun);
    
                #endregion
    
                //InitializeComponent();
            }
    
            private void Calculate()
            {
                #region movecalculation
                //day lists for common numbers for the day
                List<int> mon = new List<int>();
                List<int> tue = new List<int>();
                List<int> wed = new List<int>();
                List<int> thu = new List<int>();
                List<int> fri = new List<int>();
                List<int> sat = new List<int>();
                List<int> sun = new List<int>();
    
                bool check = true;
    
                int pick1 = 0, pick2 = 0, pick3 = 0, pick4 = 0, pick5 = 0;
    
                while (check == true)
                {
                    if (rMon.Checked)
                    {
                        foreach (Number n in this.allnumobjs)
                        {
                            if (n.Monday > 3)
                            {
                                mon.Add(n.A_Val);
                            }
                        }
    
                        foreach (int i in mon)
                        {
                            if (hotnums.Contains(i))
                            {
                                hotnums.Remove(i);
                            }
                            if (coldnums.Contains(i))
                            {
                                coldnums.Remove(i);
                            }
                        }
    
                        Random r = new Random();
    
                        pick1 = hotnums[r.Next(0, hotnums.Count)];
    
                        pick2 = hotnums[r.Next(0, hotnums.Count)];
    
                        if (pick1 == pick2)
                        {
                            check = false;
                        }
    
                        pick3 = mon[r.Next(0, mon.Count)];
    
                        pick4 = coldnums[r.Next(0, coldnums.Count)];
    
                        pick5 = coldnums[r.Next(0, coldnums.Count)];
    
                        if (pick4 == pick5)
                        {
                            check = false;
                        }
    
    
                        int picktot = pick1 + pick2 + pick3 + pick4 + pick5;
    
                        if ((picktot <= 80) || (picktot >= 125))
                        {
                            check = false;
                        }
    
                        allpicks.Add(pick1);
                        allpicks.Add(pick2);
                        allpicks.Add(pick3);
                        allpicks.Add(pick4);
                        allpicks.Add(pick5);
    
                        allpicks.Sort();
    
                        int even = 0;
                        int odd = 0;
    
                        foreach (int i in allpicks)
                        {
                            foreach (Number n in allnumobjs)
                            {
                                if (i == n.A_Val)
                                {
                                    if (n.Is_Even)
                                    {
                                        even++;
                                    }
                                    else
                                    {
                                        odd++;
                                    }
                                }
                            }
                        }
    
                        //make sure we keep 4/1, 3/2 split on odds and evens
                        if ((even > 4) || (odd > 4))
                        {
                            check = false;
                        }
                        //first pick shouldnt be more than 14
                        if (allpicks[0] >= 14)
                        {
                            check = false;
                        }
    
                        //the picks are good, display them
                        lblpickone.Text = allpicks[0].ToString();
                        lblpicktwo.Text = allpicks[1].ToString();
                        lblpickthree.Text = allpicks[2].ToString();
                        lblpickfour.Text = allpicks[3].ToString();
                        lblpickfive.Text = allpicks[4].ToString();
    
                        allpicks.Clear();
                        mon.Clear();
                    }
                    else if (rTue.Checked)
                    {
                        foreach (Number n in this.allnumobjs)
                        {
                            if (n.Tuesday > 3)
                            {
                                tue.Add(n.A_Val);
                            }
                        }
    
                        foreach (int i in tue)
                        {
                            if (hotnums.Contains(i))
                            {
                                hotnums.Remove(i);
                            }
                            if (coldnums.Contains(i))
                            {
                                coldnums.Remove(i);
                            }
                        }
    
                        Random r = new Random();
    
                        pick1 = hotnums[r.Next(0, hotnums.Count)];
    
                        pick2 = hotnums[r.Next(0, hotnums.Count)];
    
                        if (pick1 == pick2)
                        {
                            check = false;
                        }
    
                        pick3 = tue[r.Next(0, tue.Count)];
    
                        pick4 = coldnums[r.Next(0, coldnums.Count)];
    
                        pick5 = coldnums[r.Next(0, coldnums.Count)];
    
                        if (pick4 == pick5)
                        {
                            check = false;
                        }
    
                        int picktot = pick1 + pick2 + pick3 + pick4 + pick5;
    
                        if ((picktot <= 80) || (picktot >= 125))
                        {
                            check = false;
                        }
    
                        allpicks.Add(pick1);
                        allpicks.Add(pick2);
                        allpicks.Add(pick3);
                        allpicks.Add(pick4);
                        allpicks.Add(pick5);
    
                        allpicks.Sort();
    
                        int even = 0;
                        int odd = 0;
    
                        foreach (int i in allpicks)
                        {
                            foreach (Number n in allnumobjs)
                            {
                                if (i == n.A_Val)
                                {
                                    if (n.Is_Even)
                                    {
                                        even++;
                                    }
                                    else
                                    {
                                        odd++;
                                    }
                                }
                            }
                        }
    
                        //make sure we keep 4/1, 3/2 split on odds and evens
                        if ((even > 4) || (odd > 4))
                        {
                            check = false;
                        }
                        //first pick shouldnt be more than 14
                        if (allpicks[0] >= 14)
                        {
                            check = false;
                        }
    
                        //the picks are good, display them
                        lblpickone.Text = allpicks[0].ToString();
                        lblpicktwo.Text = allpicks[1].ToString();
                        lblpickthree.Text = allpicks[2].ToString();
                        lblpickfour.Text = allpicks[3].ToString();
                        lblpickfive.Text = allpicks[4].ToString();
    
                        allpicks.Clear();
                        tue.Clear();
                    }
                    else if (rWed.Checked)
                    {
                        foreach (Number n in this.allnumobjs)
                        {
                            if (n.Wednesday > 3)
                            {
                                wed.Add(n.A_Val);
                            }
                        }
    
                        foreach (int i in wed)
                        {
                            if (hotnums.Contains(i))
                            {
                                hotnums.Remove(i);
                            }
                            if (coldnums.Contains(i))
                            {
                                coldnums.Remove(i);
                            }
                        }
    
                        Random r = new Random();
    
                        pick1 = hotnums[r.Next(0, hotnums.Count)];
    
                        pick2 = hotnums[r.Next(0, hotnums.Count)];
    
                        if (pick1 == pick2)
                        {
                            check = false;
                        }
    
                        pick3 = wed[r.Next(0, wed.Count)];
    
                        pick4 = coldnums[r.Next(0, coldnums.Count)];
    
                        pick5 = coldnums[r.Next(0, coldnums.Count)];
    
                        if (pick4 == pick5)
                        {
                            check = false;
                        }
    
                        int picktot = pick1 + pick2 + pick3 + pick4 + pick5;
    
                        if ((picktot <= 80) || (picktot >= 125))
                        {
                            check = false;
                        }
    
                        allpicks.Add(pick1);
                        allpicks.Add(pick2);
                        allpicks.Add(pick3);
                        allpicks.Add(pick4);
                        allpicks.Add(pick5);
    
                        allpicks.Sort();
    
                        int even = 0;
                        int odd = 0;
    
                        foreach (int i in allpicks)
                        {
                            foreach (Number n in allnumobjs)
                            {
                                if (i == n.A_Val)
                                {
                                    if (n.Is_Even)
                                    {
                                        even++;
                                    }
                                    else
                                    {
                                        odd++;
                                    }
                                }
                            }
                        }
    
                        //make sure we keep 4/1, 3/2 split on odds and evens
                        if ((even > 4) || (odd > 4))
                        {
                            check = false;
                        }
                        //first pick shouldnt be more than 14
                        if (allpicks[0] >= 14)
                        {
                            check = false;
                        }
    
                        //the picks are good, display them
                        lblpickone.Text = allpicks[0].ToString();
                        lblpicktwo.Text = allpicks[1].ToString();
                        lblpickthree.Text = allpicks[2].ToString();
                        lblpickfour.Text = allpicks[3].ToString();
                        lblpickfive.Text = allpicks[4].ToString();
    
                        allpicks.Clear();
                        wed.Clear();
                    }
                    else if (rThu.Checked)
                    {
                        foreach (Number n in this.allnumobjs)
                        {
                            if (n.Thursday > 3)
                            {
                                thu.Add(n.A_Val);
                            }
                        }
    
                        foreach (int i in thu)
                        {
                            if (hotnums.Contains(i))
                            {
                                hotnums.Remove(i);
                            }
                            if (coldnums.Contains(i))
                            {
                                coldnums.Remove(i);
                            }
                        }
    
                        Random r = new Random();
    
                        pick1 = hotnums[r.Next(0, hotnums.Count)];
    
                        pick2 = hotnums[r.Next(0, hotnums.Count)];
    
                        if (pick1 == pick2)
                        {
                            check = false;
                        }
    
                        pick3 = thu[r.Next(0, thu.Count)];
    
                        pick4 = coldnums[r.Next(0, coldnums.Count)];
    
                        pick5 = coldnums[r.Next(0, coldnums.Count)];
    
                        if (pick4 == pick5)
                        {
                            check = false;
                        }
    
    
                        int picktot = pick1 + pick2 + pick3 + pick4 + pick5;
    
                        if ((picktot <= 80) || (picktot >= 125))
                        {
                            check = false;
                        }
    
                        allpicks.Add(pick1);
                        allpicks.Add(pick2);
                        allpicks.Add(pick3);
                        allpicks.Add(pick4);
                        allpicks.Add(pick5);
    
                        allpicks.Sort();
    
                        int even = 0;
                        int odd = 0;
    
                        foreach (int i in allpicks)
                        {
                            foreach (Number n in allnumobjs)
                            {
                                if (i == n.A_Val)
                                {
                                    if (n.Is_Even)
                                    {
                                        even++;
                                    }
                                    else
                                    {
                                        odd++;
                                    }
                                }
                            }
                        }
    
                        //make sure we keep 4/1, 3/2 split on odds and evens
                        if ((even > 4) || (odd > 4))
                        {
                            check = false;
                        }
                        //first pick shouldnt be more than 14
                        if (allpicks[0] >= 14)
                        {
                            check = false;
                        }
    
                        //the picks are good, display them
                        lblpickone.Text = allpicks[0].ToString();
                        lblpicktwo.Text = allpicks[1].ToString();
                        lblpickthree.Text = allpicks[2].ToString();
                        lblpickfour.Text = allpicks[3].ToString();
                        lblpickfive.Text = allpicks[4].ToString();
    
                        allpicks.Clear();
                        thu.Clear();
                    }
                    else if (rFri.Checked)
                    {
                        foreach (Number n in this.allnumobjs)
                        {
                            if (n.Friday > 3)
                            {
                                fri.Add(n.A_Val);
                            }
                        }
    
                        foreach (int i in fri)
                        {
                            if (hotnums.Contains(i))
                            {
                                hotnums.Remove(i);
                            }
                            if (coldnums.Contains(i))
                            {
                                coldnums.Remove(i);
                            }
                        }
    
                        Random r = new Random();
    
                        pick1 = hotnums[r.Next(0, hotnums.Count)];
    
                        pick2 = hotnums[r.Next(0, hotnums.Count)];
    
                        if (pick1 == pick2)
                        {
                            check = false;
                        }
    
                        pick3 = fri[r.Next(0, fri.Count)];
    
                        pick4 = coldnums[r.Next(0, coldnums.Count)];
    
                        pick5 = coldnums[r.Next(0, coldnums.Count)];
    
                        if (pick4 == pick5)
                        {
                            check = false;
                        }
    
                        int picktot = pick1 + pick2 + pick3 + pick4 + pick5;
    
                        if ((picktot <= 80) || (picktot >= 125))
                        {
                            check = false;
                        }
    
                        allpicks.Add(pick1);
                        allpicks.Add(pick2);
                        allpicks.Add(pick3);
                        allpicks.Add(pick4);
                        allpicks.Add(pick5);
    
                        allpicks.Sort();
    
                        int even = 0;
                        int odd = 0;
    
                        foreach (int i in allpicks)
                        {
                            foreach (Number n in allnumobjs)
                            {
                                if (i == n.A_Val)
                                {
                                    if (n.Is_Even)
                                    {
                                        even++;
                                    }
                                    else
                                    {
                                        odd++;
                                    }
                                }
                            }
                        }
    
                        //make sure we keep 4/1, 3/2 split on odds and evens
                        if ((even > 4) || (odd > 4))
                        {
                            check = false;
                        }
                        //first pick shouldnt be more than 14
                        if (allpicks[0] >= 14)
                        {
                            check = false;
                        }
    
                        //the picks are good, display them
                        lblpickone.Text = allpicks[0].ToString();
                        lblpicktwo.Text = allpicks[1].ToString();
                        lblpickthree.Text = allpicks[2].ToString();
                        lblpickfour.Text = allpicks[3].ToString();
                        lblpickfive.Text = allpicks[4].ToString();
    
                        allpicks.Clear();
                        fri.Clear();
                    }
                    else if (rSat.Checked)
                    {
                        foreach (Number n in this.allnumobjs)
                        {
                            if (n.Saturday > 3)
                            {
                                sat.Add(n.A_Val);
                            }
                        }
    
                        foreach (int i in sat)
                        {
                            if (hotnums.Contains(i))
                            {
                                hotnums.Remove(i);
                            }
                            if (coldnums.Contains(i))
                            {
                                coldnums.Remove(i);
                            }
                        }
    
                        Random r = new Random();
    
                        pick1 = hotnums[r.Next(0, hotnums.Count)];
    
                        pick2 = hotnums[r.Next(0, hotnums.Count)];
    
                        if (pick1 == pick2)
                        {
                            check = false;
                        }
    
                        pick3 = sat[r.Next(0, sat.Count)];
    
                        pick4 = coldnums[r.Next(0, coldnums.Count)];
    
                        pick5 = coldnums[r.Next(0, coldnums.Count)];
    
                        if (pick4 == pick5)
                        {
                            check = false;
                        }
    
                        int picktot = pick1 + pick2 + pick3 + pick4 + pick5;
    
                        if ((picktot <= 80) || (picktot >= 125))
                        {
                            check = false;
                        }
    
                        allpicks.Add(pick1);
                        allpicks.Add(pick2);
                        allpicks.Add(pick3);
                        allpicks.Add(pick4);
                        allpicks.Add(pick5);
    
                        allpicks.Sort();
    
                        int even = 0;
                        int odd = 0;
    
                        foreach (int i in allpicks)
                        {
                            foreach (Number n in allnumobjs)
                            {
                                if (i == n.A_Val)
                                {
                                    if (n.Is_Even)
                                    {
                                        even++;
                                    }
                                    else
                                    {
                                        odd++;
                                    }
                                }
                            }
                        }
    
                        //make sure we keep 4/1, 3/2 split on odds and evens
                        if ((even > 4) || (odd > 4))
                        {
                            check = false;
                        }
                        //first pick shouldnt be more than 14
                        if (allpicks[0] >= 14)
                        {
                            check = false;
                        }
    
                        //the picks are good, display them
                        lblpickone.Text = allpicks[0].ToString();
                        lblpicktwo.Text = allpicks[1].ToString();
                        lblpickthree.Text = allpicks[2].ToString();
                        lblpickfour.Text = allpicks[3].ToString();
                        lblpickfive.Text = allpicks[4].ToString();
    
                        allpicks.Clear();
                        sat.Clear();
                    }
                    else if (rSun.Checked)
                    {
                        foreach (Number n in this.allnumobjs)
                        {
                            if (n.Sunday > 3)
                            {
                                sun.Add(n.A_Val);
                            }
                        }
    
                        foreach (int i in sun)
                        {
                            if (hotnums.Contains(i))
                            {
                                hotnums.Remove(i);
                            }
                            if (coldnums.Contains(i))
                            {
                                coldnums.Remove(i);
                            }
                        }
                     
                        Random r = new Random();
    
                        pick1 = hotnums[r.Next(0, hotnums.Count)];
    
                        pick2 = hotnums[r.Next(0, hotnums.Count)];
    
                        if (pick1 == pick2)
                        {
                            check = false;
                        }
    
                        pick3 = sun[r.Next(0, sun.Count)];
    
                        pick4 = coldnums[r.Next(0, coldnums.Count)];
    
                        pick5 = coldnums[r.Next(0, coldnums.Count)];
    
                        if (pick4 == pick5)
                        {
                            check = false;
                        }
    
                        int picktot = pick1 + pick2 + pick3 + pick4 + pick5;
    
                        if ((picktot <= 80) || (picktot >= 125))
                        {
                            check = false;
                        }
    
                        allpicks.Add(pick1);
                        allpicks.Add(pick2);
                        allpicks.Add(pick3);
                        allpicks.Add(pick4);
                        allpicks.Add(pick5);
    
                        allpicks.Sort();
    
                        int even = 0;
                        int odd = 0;
    
                        foreach (int i in allpicks)
                        {
                            foreach (Number n in allnumobjs)
                            {
                                if (i == n.A_Val)
                                {
                                    if (n.Is_Even)
                                    {
                                        even++;
                                    }
                                    else
                                    {
                                        odd++;
                                    }
                                }
                            }
                        }
    
                        //make sure we keep 4/1, 3/2 split on odds and evens
                        if ((even > 4) || (odd > 4))
                        {
                            check = false;
                        }
                        //first pick shouldnt be more than 14
                        if (allpicks[0] >= 14)
                        {
                            check = false;
                        }
    
                        //the picks are good, display them
                        lblpickone.Text = allpicks[0].ToString();
                        lblpicktwo.Text = allpicks[1].ToString();
                        lblpickthree.Text = allpicks[2].ToString();
                        lblpickfour.Text = allpicks[3].ToString();
                        lblpickfive.Text = allpicks[4].ToString();
    
                        allpicks.Clear();
                        sun.Clear();
                    }
                    else
                    {
                        MessageBox.Show("Please select a day");
                    }
                }
    
                #endregion
            }
    
            private void bgen_Click(object sender, EventArgs e)
            {
                Calculate();
            }
            private void bclear_Click(object sender, EventArgs e)
            {
                lblpickone.Text = "";
                lblpicktwo.Text = "";
                lblpickthree.Text = "";
                lblpickfour.Text = "";
                lblpickfive.Text = "";
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
    
            }
        }
    
        public class Number
        {
            public Number()
            {
            }
    
            #region properties
    
            public int Monday
            {
                get { return this.monday; }
                set
                {
                    this.monday = value;
                }
            }
            private int monday;
    
            public int Tuesday
            {
                get { return this.tuesday; }
                set
                {
                    this.tuesday = value;
                }
            }
            private int tuesday;
            
    
            public int Wednesday
            {
                get { return this.wednesday; }
                set
                {
                    this.wednesday = value;
                }
            }
            private int wednesday;
    
            public int Thursday
            {
                get { return this.thursday; }
                set
                {
                    this.thursday = value;
                }
            }
            private int thursday;
    
            public int Friday
            {
                get { return this.friday; }
                set
                {
                    this.friday = value;
                }
            }
            private int friday;
    
            public int Saturday
            {
                get { return this.saturday; }
                set
                {
                    this.saturday = value;
                }
            }
            private int saturday;
    
            public int Sunday
            {
                get { return this.sunday; }
                set
                {
                    this.sunday = value;
                }
            }
            private int sunday;
    
            public bool Is_Even
            {
                get { return this.is_even; }
    
                set
                {
                    this.is_even = value;
                }
            }
            private bool is_even;
    
            public bool Is_Odd
            {
                get { return this.is_odd; }
    
                set
                {
                    this.is_odd = value;
                }
            }
            private bool is_odd;
    
            public bool Is_Hot
            {
                get { return this.is_hot; }
    
                set
                {
                    this.is_hot = value;
                }
            }
            private bool is_hot;
    
            public bool Is_Cold
            {
                get { return this.is_cold; }
    
                set
                {
                    this.is_cold = value;
                }
            }
            private bool is_cold;
    
            public int A_Val
            {
                get { return this.a_val; }
    
                set
                {
                    this.a_val = value;
                }
            }
            private int a_val;
    
            public int Net_Val
            {
                get { return this.net_val; }
    
                set
                {
                    this.net_val = value;
                }
            }
            private int net_val;
    
            #endregion
        }
    }
    
    
    
  2. In Topic: Solving the lottery with C#, this should be fun!

    Posted 26 Sep 2012

    Thank you for your responses. Wow I didn't know you could instantiate a new number from a method call that is awesome. Now when you say don't let the button event handle all the calculations you mean putting them in methods and calling them in the button press instead of all being coded into the button?
    Also is the code being in the button causing it to crash? this is what I thought in the first place but when I debug it gives no such sign of crashing. Thank you again.
  3. In Topic: error

    Posted 24 Sep 2012

    Well, if your not getting the first error, then what I would try is to create a variable AFTER you start the foreach loop.
    SO if you have Foreach(char word in english) inside that loop I would make another char value and assign the value of word to it. Then use that variable to remove the char.
    foreach(char word in english)
    {
    char c = word;
    english = firstletter.remove(c);
    }
    
    
    
  4. In Topic: error

    Posted 24 Sep 2012

    First of all you don't ever assign a value to FirstLetter. So when you try to assign english with firstletter.remove(word) it does nothing. I am not even getting the error with word that you describe because its hung up on the assignment call.

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Full Name:
Gleave
Years Programming:
4
Programming Languages:
C#
C++
C
VB
.Net

Contact Information

E-mail:
Private

Friends

Comments

Page 1 of 1
  1. Photo

    Gleave Icon

    18 Dec 2010 - 15:02
    Wo ein Wille, da ein Weg.
Page 1 of 1