diff --git a/Lotto.sln b/Lotto.sln new file mode 100644 index 0000000..2b2d562 --- /dev/null +++ b/Lotto.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33213.308 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lotto", "Lotto\Lotto.csproj", "{E5C72B18-4009-440B-AD2E-7DF000598527}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E5C72B18-4009-440B-AD2E-7DF000598527}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E5C72B18-4009-440B-AD2E-7DF000598527}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E5C72B18-4009-440B-AD2E-7DF000598527}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E5C72B18-4009-440B-AD2E-7DF000598527}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {17557986-A746-4E73-B249-D28F2C0BE52B} + EndGlobalSection +EndGlobal diff --git a/Lotto/Form1.Designer.cs b/Lotto/Form1.Designer.cs new file mode 100644 index 0000000..07ab80f --- /dev/null +++ b/Lotto/Form1.Designer.cs @@ -0,0 +1,116 @@ +namespace Lotto +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.SorsolasCimke = new System.Windows.Forms.Label(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(12, 26); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(776, 34); + this.button1.TabIndex = 0; + this.button1.Text = "Sorsolás"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // button2 + // + this.button2.Location = new System.Drawing.Point(12, 268); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(776, 34); + this.button2.TabIndex = 1; + this.button2.Text = "Ellenörzés"; + this.button2.UseVisualStyleBackColor = true; + // + // SorsolasCimke + // + this.SorsolasCimke.Font = new System.Drawing.Font("Microsoft Sans Serif", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.SorsolasCimke.Location = new System.Drawing.Point(12, 72); + this.SorsolasCimke.Name = "SorsolasCimke"; + this.SorsolasCimke.Size = new System.Drawing.Size(776, 118); + this.SorsolasCimke.TabIndex = 1; + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(12, 226); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(776, 23); + this.textBox1.TabIndex = 3; + // + // label2 + // + this.label2.BackColor = System.Drawing.Color.Turquoise; + this.label2.Location = new System.Drawing.Point(12, 323); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(776, 27); + this.label2.TabIndex = 5; + // + // label3 + // + this.label3.Location = new System.Drawing.Point(12, 199); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(128, 24); + this.label3.TabIndex = 5; + this.label3.Text = "Lottószelvény számai:"; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.label3); + this.Controls.Add(this.label2); + this.Controls.Add(this.textBox1); + this.Controls.Add(this.SorsolasCimke); + this.Controls.Add(this.button2); + this.Controls.Add(this.button1); + this.Name = "Form1"; + this.Text = "Form1"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Button button1; + private Button button2; + private Label SorsolasCimke; + private TextBox textBox1; + private Label label2; + private Label label3; + } +} \ No newline at end of file diff --git a/Lotto/Form1.cs b/Lotto/Form1.cs new file mode 100644 index 0000000..94af8e9 --- /dev/null +++ b/Lotto/Form1.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Reflection.Emit; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using static System.Windows.Forms.VisualStyles.VisualStyleElement; + +namespace Lotto +{ + public partial class Form1 : Form + { + int[] sorsoltak = new int[5]; + public Form1() + { + InitializeComponent(); + } + + private void button1_Click(object sender, EventArgs e) + { + + Random rd = new Random(); + for (int i = 0; i < 5; i++) + { + bool marvan; + do + { + sorsoltak[i] = rd.Next(1, 91); + marvan = false; + for (int j = 0; j < i; j++) + { + marvan = marvan || (sorsoltak[j] == sorsoltak[i]); + } + } while (marvan); + } + + Array.Sort(sorsoltak); + + SorsolasCimke.Text = $"{sorsoltak[0]} {sorsoltak[1]} {sorsoltak[2]} {sorsoltak[3]} {sorsoltak[4]}"; + } + + private void button2_Click(object sender, EventArgs e) + { + string beirva = textBox1.Text; + string[] szamok = beirva.Split(';'); + if (szamok.Length != 5) + { + label2.Text = "Nem öt értéket adott meg vagy nem jó a választókarakter!"; + } + else + { + int talalat = 0; + for (int i = 0; i < 5; i++) + { + try + { + int lsz = int.Parse(szamok[i]); + if (lsz < 1 || lsz > 90) + { + label2.Text = $"Az {i + 1}. szám nem 1-90 közötti!"; + talalat = -1; + break; + } + else + { + foreach (int s in sorsoltak) + { + if (s == lsz) talalat++; + } + } + + } + catch (Exception) + { + label2.Text = $"Az {i + 1}. érték nem szám!"; + talalat = -1; + break; + } + } + if (talalat > -1) label2.Text = "Találatok száma: " + talalat; + } + } + + } +} \ No newline at end of file diff --git a/Lotto/Form1.resx b/Lotto/Form1.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/Lotto/Form1.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Lotto/Lotto.csproj b/Lotto/Lotto.csproj new file mode 100644 index 0000000..b57c89e --- /dev/null +++ b/Lotto/Lotto.csproj @@ -0,0 +1,11 @@ + + + + WinExe + net6.0-windows + enable + true + enable + + + \ No newline at end of file diff --git a/Lotto/Program.cs b/Lotto/Program.cs new file mode 100644 index 0000000..45fe695 --- /dev/null +++ b/Lotto/Program.cs @@ -0,0 +1,17 @@ +namespace Lotto +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + Application.Run(new Form1()); + } + } +} \ No newline at end of file