private void Play(Lotto game, int times) { for (int i = 0; i < times; i++) { this.lstbxDraws.Items.Add(game.GetName() + ": " + game.Draw()); } }
private void drawClick(object sender, RoutedEventArgs e) { Tehtava2.Lotto lotto = new Lotto(); try { lotto.Times = int.Parse(textBox_number.Text); } catch { MessageBox.Show("Invalid input in Number of drawns textbox"); } if (comboBox.SelectedIndex == 0) { listBox.Items.Add(lotto.DrawLottoNumbers()); } if (comboBox.SelectedIndex == 1) { listBox.Items.Add(lotto.DrawVikingNumbers()); } if (comboBox.SelectedIndex == 2) { listBox.Items.Add(lotto.DrawEuroNumbers()); } }
private void init() { // Create instance of Lotto lotto = new Lotto(); // Create instance of business logic business = new BusinessLogic(); }
private void drawbutton_Click(object sender, RoutedEventArgs e) { int arvontojenmaara; Lotto lotto = new Lotto(); if (maara.Text == "") arvontojenmaara = 1; else arvontojenmaara = int.Parse(maara.Text); for (int i = 0; i < arvontojenmaara; i++) { int[] rivi = lotto.ArvoRivi(comboBox.SelectedIndex); string srivi = string.Join(" ", rivi); listBox.Items.Add(srivi); } }
private void bttDraw_Click(object sender, RoutedEventArgs e) { try { // Arvottavien rivien lukumäärä. int count = int.Parse(txtCount.Text); Tehtava2.Lotto[] lotto = new Tehtava2.Lotto[count]; for (int i = 0; i < count; ++i) { lotto[i] = new Lotto(); // Pelin valinta if (this.comboBox.SelectedIndex == 0) { lotto[i].Lenght = 7; lotto[i].Max = 39; lotto[i].Ext = false; } else if (this.comboBox.SelectedIndex == 1) { lotto[i].Lenght = 6; lotto[i].Max = 48; lotto[i].Ext = false; } else if (this.comboBox.SelectedIndex == 2) { lotto[i].Lenght = 5; lotto[i].Max = 50; lotto[i].Ext = true; } } // Tee rivit for(int i = 0; i < count; ++i) { txtContainer.Text += lotto[i].CreateLotto() + "\n"; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button_Click(object sender, RoutedEventArgs e) { string tulos = ""; int drawns = int.Parse(textBox.Text), laskuri; Random rnd = new Random(); try { if (comboBox.SelectedItem == "Suomi") { for (laskuri = 0; laskuri < drawns; laskuri++) { tulos += Lotto.Luvut(7, 39, rnd); } } else if (comboBox.SelectedItem == "VikingLotto") { for (laskuri = 0; laskuri < drawns; laskuri++) { tulos += Lotto.Luvut(6, 48, rnd); } } else if (comboBox.SelectedItem == "EuroJackpot") { for (laskuri = 0; laskuri < drawns; laskuri++) { tulos += Lotto.Luvut(5, 50, rnd) + " : " + Lotto.Luvut(2, 8, rnd); } } /*switch (comboBox.SelectedItem) * { * case "Suomi": break; * case "VikingLotto": break; * }*/ textBlock2.Text = tulos; } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { //yield to an user that everything okay } }
private void bttDraw_Click(object sender, RoutedEventArgs e) { try { // Arvottavien rivien lukumäärä. int count = int.Parse(txtCount.Text); Tehtava2.Lotto[] lotto = new Tehtava2.Lotto[count]; for (int i = 0; i < count; ++i) { lotto[i] = new Lotto(); // Pelin valinta if (this.comboBox.SelectedIndex == 0) { lotto[i].Lenght = 7; lotto[i].Max = 39; lotto[i].Ext = false; } else if (this.comboBox.SelectedIndex == 1) { lotto[i].Lenght = 6; lotto[i].Max = 48; lotto[i].Ext = false; } else if (this.comboBox.SelectedIndex == 2) { lotto[i].Lenght = 5; lotto[i].Max = 50; lotto[i].Ext = true; } } // Tee rivit for (int i = 0; i < count; ++i) { txtContainer.Text += lotto[i].CreateLotto() + "\n"; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button_Copy_Click(object sender, RoutedEventArgs e) { Lotto lotto = new Lotto((Lotto.Tyyppi)boxTypes.SelectedIndex); for (int j = 0; j < int.Parse(txtDraws.Text); j++) { List<int> rivi = lotto.ArvoRivi(); String strRivi = ""; for (int i = 0; i < rivi.Count; i++) { strRivi += rivi[i]; if (i < rivi.Count - 1) strRivi += ", "; } listBox.Items.Add(strRivi); } }
private void drawClick(object sender, RoutedEventArgs e) { Tehtava2.Lotto lotto = new Lotto(); try { lotto.Times = int.Parse(textBox_number.Text); } catch { MessageBox.Show("Invalid input in Number of drawns textbox"); } if(comboBox.SelectedIndex == 0) { listBox.Items.Add(lotto.DrawLottoNumbers()); } if(comboBox.SelectedIndex == 1) { listBox.Items.Add(lotto.DrawVikingNumbers()); } if (comboBox.SelectedIndex == 2) { listBox.Items.Add(lotto.DrawEuroNumbers()); } }
/// <summary> /// Happens when the game selection combo box selection changes. Sets the current lotto to the new Lotto object /// based on the value got from the selection. /// </summary> /// <param name="sender">The combo boc element which fired the event.</param> /// <param name="e"></param> private void cmbbxChooseGame_SelectionChanged(object sender, SelectionChangedEventArgs e) { ComboBoxItem item = (ComboBoxItem)((ComboBox)sender).SelectedItem; string value = item.Content.ToString().ToLower().Replace(" ", ""); this.ClearResult(); if (value == "suomi") { this.currentLotto = new Lotto("suomi", 37, 7); } else if(value == "vikinglotto") { this.currentLotto = new Lotto("vikinglotto", 48, 6); } else if (value == "eurojackpot") { this.currentLotto = new Lotto("eurojackpot", 50, 7); } }
public MainWindow() { InitializeComponent(); this.currentLotto = new Lotto("suomi", 39, 7); this.cmbbxChooseGame.Text = "Suomi"; }
private void btnDraw_Click(object sender, RoutedEventArgs e) { Lotto lotto = new Lotto(); int draws = int.Parse(txtDraws.Text); int[] numbers; try { if (cboGames.Text == "Suomi") { for (int i = 0; i < draws; i++) { numbers = new int[7]; numbers = lotto.DrawLotto(); foreach (int j in numbers) { txtResults.Text += j + " "; } txtResults.Text += "\r\n"; } } else if (cboGames.Text == "Viking Lotto") { for (int i = 0; i < draws; i++) { numbers = new int[6]; numbers = lotto.DrawVikingLotto(); foreach (int j in numbers) { txtResults.Text += j + " "; } txtResults.Text += "\r\n"; } } else if (cboGames.Text == "Eurojackpot") { for (int i = 0; i < draws; i++) { numbers = new int[5]; numbers = lotto.DrawEurojackpotMain(); foreach (int j in numbers) { txtResults.Text += j + " "; } txtResults.Text += "+ "; numbers = new int[2]; numbers = lotto.DrawEurojackpotStar(); foreach (int j in numbers) { txtResults.Text += j + " "; } txtResults.Text += "\r\n"; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { } }