Lotto_WPf/Lotto_Wpf/Lotto_Wpf/LottoProject.cs
2025-06-16 21:59:20 +02:00

40 lines
897 B
C#

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);
}
}
}