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"> +