Projektdateien hinzufügen.
This commit is contained in:
parent
5b08b3da13
commit
606791e3d6
9
App.xaml
Normal file
9
App.xaml
Normal file
@ -0,0 +1,9 @@
|
||||
<Application x:Class="Lotto1.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Lotto1"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
14
App.xaml.cs
Normal file
14
App.xaml.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Windows;
|
||||
|
||||
namespace Lotto1
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
|
||||
}
|
10
AssemblyInfo.cs
Normal file
10
AssemblyInfo.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System.Windows;
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
11
Lotto1.csproj
Normal file
11
Lotto1.csproj
Normal file
@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UseWPF>true</UseWPF>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
25
Lotto1.sln
Normal file
25
Lotto1.sln
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.13.35931.197 d17.13
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lotto1", "Lotto1.csproj", "{942F020D-B84B-470F-A50B-A8A5B00E0F83}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{942F020D-B84B-470F-A50B-A8A5B00E0F83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{942F020D-B84B-470F-A50B-A8A5B00E0F83}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{942F020D-B84B-470F-A50B-A8A5B00E0F83}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{942F020D-B84B-470F-A50B-A8A5B00E0F83}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {0BA3A6EA-C1B0-4A86-A8F6-7D56CA80A335}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
31
MainWindow.xaml
Normal file
31
MainWindow.xaml
Normal file
@ -0,0 +1,31 @@
|
||||
<Window x:Class="Lotto_Test.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="Lotto" Height="500" Width="600">
|
||||
<Grid Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<!-- Überschrift -->
|
||||
<RowDefinition Height="*"/>
|
||||
<!-- Spielfeld -->
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="3*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Text="Lotto – Wähle 6 Zahlen"
|
||||
FontSize="18" FontWeight="Bold"
|
||||
HorizontalAlignment="Center"
|
||||
Grid.ColumnSpan="2" Grid.Row="0" Margin="0,0,0,10"/>
|
||||
|
||||
<WrapPanel x:Name="Feld" Grid.Column="0" Grid.Row="1"/>
|
||||
|
||||
<StackPanel Grid.Column="1" Grid.Row="1" Margin="10,0,0,0">
|
||||
<TextBlock x:Name="GeldText" FontSize="14" Margin="0,0,0,20"/>
|
||||
<Button Content="Ziehung" Click="Ziehung_Click" Margin="0,0,0,10"/>
|
||||
<Button Content="Reset" Click="Reset_Click"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
236
MainWindow.xaml.cs
Normal file
236
MainWindow.xaml.cs
Normal file
@ -0,0 +1,236 @@
|
||||
using System;
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
using System.Windows;
|
||||
|
||||
using System.Windows.Controls;
|
||||
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Lotto_Test
|
||||
|
||||
{
|
||||
|
||||
public partial class MainWindow : Window
|
||||
|
||||
{
|
||||
|
||||
List<int> auswahl = new List<int>();
|
||||
|
||||
List<Button> knöpfe = new List<Button>();
|
||||
|
||||
List<int> gezogen = new List<int>();
|
||||
|
||||
double geld = 2000;
|
||||
|
||||
public MainWindow()
|
||||
|
||||
{
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
for (int i = 1; i <= 49; i++)
|
||||
|
||||
{
|
||||
|
||||
Button b = new Button();
|
||||
|
||||
b.Content = i.ToString();
|
||||
|
||||
b.Tag = i;
|
||||
|
||||
b.Width = 35;
|
||||
|
||||
b.Height = 35;
|
||||
|
||||
b.Margin = new Thickness(3);
|
||||
|
||||
b.Background = Brushes.LightGray;
|
||||
|
||||
b.Click += Zahl_Click;
|
||||
|
||||
Feld.Children.Add(b);
|
||||
|
||||
knöpfe.Add(b);
|
||||
|
||||
}
|
||||
|
||||
GeldAktualisieren();
|
||||
|
||||
}
|
||||
|
||||
void Zahl_Click(object sender, RoutedEventArgs e)
|
||||
|
||||
{
|
||||
|
||||
if (gezogen.Count > 0) return;
|
||||
|
||||
Button b = (Button)sender;
|
||||
|
||||
int n = (int)b.Tag;
|
||||
|
||||
if (auswahl.Contains(n))
|
||||
|
||||
{
|
||||
|
||||
auswahl.Remove(n);
|
||||
|
||||
b.Background = Brushes.LightGray;
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
{
|
||||
|
||||
if (auswahl.Count >= 6)
|
||||
|
||||
{
|
||||
|
||||
MessageBox.Show("Nur 6 Zahlen erlaubt");
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
auswahl.Add(n);
|
||||
|
||||
b.Background = Brushes.LightGreen;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Ziehung_Click(object sender, RoutedEventArgs e)
|
||||
|
||||
{
|
||||
|
||||
if (auswahl.Count != 6)
|
||||
|
||||
{
|
||||
|
||||
MessageBox.Show("Wähle genau 6 Zahlen");
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (geld < 5)
|
||||
|
||||
{
|
||||
|
||||
MessageBox.Show("Nicht genug Geld");
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
geld -= 5;
|
||||
|
||||
gezogen.Clear();
|
||||
|
||||
List<int> zahlen = new List<int>();
|
||||
|
||||
for (int i = 1; i <= 49; i++) zahlen.Add(i);
|
||||
|
||||
Random r = new Random();
|
||||
|
||||
while (gezogen.Count < 6)
|
||||
|
||||
{
|
||||
|
||||
int z = r.Next(zahlen.Count);
|
||||
|
||||
gezogen.Add(zahlen[z]);
|
||||
|
||||
zahlen.RemoveAt(z);
|
||||
|
||||
}
|
||||
|
||||
int treffer = 0;
|
||||
|
||||
foreach (Button b in knöpfe)
|
||||
|
||||
{
|
||||
|
||||
int z = (int)b.Tag;
|
||||
|
||||
if (auswahl.Contains(z))
|
||||
|
||||
{
|
||||
|
||||
if (gezogen.Contains(z))
|
||||
|
||||
{
|
||||
|
||||
b.Background = Brushes.LightGreen;
|
||||
|
||||
treffer++;
|
||||
|
||||
}
|
||||
|
||||
else b.Background = Brushes.Red;
|
||||
|
||||
}
|
||||
|
||||
else b.Background = Brushes.LightGray;
|
||||
|
||||
}
|
||||
|
||||
double gewinn = 0;
|
||||
|
||||
if (treffer == 1) gewinn = 1;
|
||||
|
||||
if (treffer == 2) gewinn = 5;
|
||||
|
||||
if (treffer == 3) gewinn = 100;
|
||||
|
||||
if (treffer == 4) gewinn = 1000;
|
||||
|
||||
if (treffer == 5) gewinn = 1500;
|
||||
|
||||
if (treffer == 6) gewinn = 2000;
|
||||
|
||||
geld += gewinn;
|
||||
|
||||
GeldAktualisieren();
|
||||
|
||||
MessageBox.Show("Gezogen: " + string.Join(" ", gezogen) +
|
||||
|
||||
"\nDeine: " + string.Join(" ", auswahl) +
|
||||
|
||||
"\nTreffer: " + treffer +
|
||||
|
||||
"\nGewinn: " + gewinn + " €");
|
||||
|
||||
}
|
||||
|
||||
void Reset_Click(object sender, RoutedEventArgs e)
|
||||
|
||||
{
|
||||
|
||||
auswahl.Clear();
|
||||
|
||||
gezogen.Clear();
|
||||
|
||||
foreach (Button b in knöpfe)
|
||||
|
||||
b.Background = Brushes.LightGray;
|
||||
|
||||
GeldAktualisieren();
|
||||
|
||||
}
|
||||
|
||||
void GeldAktualisieren()
|
||||
|
||||
{
|
||||
|
||||
GeldText.Text = "Geld: " + geld.ToString("0.00") + " €";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user