From e054e6c31bcea0614bb228d37f44cf10b128c4de Mon Sep 17 00:00:00 2001 From: PBT3H24ASC Date: Mon, 16 Jun 2025 21:26:18 +0200 Subject: [PATCH] fast fertig --- Lotto_Wpf/Lotto_Wpf/LottoProject.cs | 38 +++++++++ Lotto_Wpf/Lotto_Wpf/MainWindow.xaml | 69 ++-------------- Lotto_Wpf/Lotto_Wpf/MainWindow.xaml.cs | 109 +++++++++++++++++++++++-- 3 files changed, 148 insertions(+), 68 deletions(-) create mode 100644 Lotto_Wpf/Lotto_Wpf/LottoProject.cs diff --git a/Lotto_Wpf/Lotto_Wpf/LottoProject.cs b/Lotto_Wpf/Lotto_Wpf/LottoProject.cs new file mode 100644 index 0000000..32c23be --- /dev/null +++ b/Lotto_Wpf/Lotto_Wpf/LottoProject.cs @@ -0,0 +1,38 @@ +using System; +using System.Linq; + +namespace LottoProject +{ + public class Lotto + { + public int[] GezogeneZahlen { get; private set; } = new int[6]; + public int TrefferAnzahl { get; private set; } = 0; + + public Lotto(int[] userZahlen) + { + Ziehen(); + TrefferAnzahl = Treffer(userZahlen, GezogeneZahlen); + } + + private void Ziehen() + { + Random rnd = new(); + for (int i = 0; i < GezogeneZahlen.Length; i++) + { + int zahl; + do + { + zahl = rnd.Next(1, 50); + } + while (GezogeneZahlen.Contains(zahl)); + GezogeneZahlen[i] = zahl; + } + } + + public int Treffer(int[] user, int[] gezogen) + { + return user.Count(gezogen.Contains); + } + } +} + diff --git a/Lotto_Wpf/Lotto_Wpf/MainWindow.xaml b/Lotto_Wpf/Lotto_Wpf/MainWindow.xaml index 30857e7..8748e6d 100644 --- a/Lotto_Wpf/Lotto_Wpf/MainWindow.xaml +++ b/Lotto_Wpf/Lotto_Wpf/MainWindow.xaml @@ -1,76 +1,21 @@ - - + Title="Lotto Number Board" Height="600" Width="400"> +