From ac44bb6c2931e0b874aaff1b1f9fb1219fced62a Mon Sep 17 00:00:00 2001 From: pp Date: Tue, 26 Apr 2022 19:27:50 +0200 Subject: [PATCH] Add project files. --- Haromszogek.sln | 25 ++++++ Haromszogek/DHaromszog.cs | 129 +++++++++++++++++++++++++++++ Haromszogek/Form1.Designer.cs | 145 +++++++++++++++++++++++++++++++++ Haromszogek/Form1.cs | 60 ++++++++++++++ Haromszogek/Form1.resx | 60 ++++++++++++++ Haromszogek/Haromszogek.csproj | 9 ++ Haromszogek/Program.cs | 23 ++++++ 7 files changed, 451 insertions(+) create mode 100644 Haromszogek.sln create mode 100644 Haromszogek/DHaromszog.cs create mode 100644 Haromszogek/Form1.Designer.cs create mode 100644 Haromszogek/Form1.cs create mode 100644 Haromszogek/Form1.resx create mode 100644 Haromszogek/Haromszogek.csproj create mode 100644 Haromszogek/Program.cs diff --git a/Haromszogek.sln b/Haromszogek.sln new file mode 100644 index 0000000..c679ba8 --- /dev/null +++ b/Haromszogek.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31624.102 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Haromszogek", "Haromszogek\Haromszogek.csproj", "{9454D6F1-840C-4A42-A93B-B3577071F869}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9454D6F1-840C-4A42-A93B-B3577071F869}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9454D6F1-840C-4A42-A93B-B3577071F869}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9454D6F1-840C-4A42-A93B-B3577071F869}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9454D6F1-840C-4A42-A93B-B3577071F869}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1E99C38F-296D-4CD6-9F71-F8F57E3A3CDB} + EndGlobalSection +EndGlobal diff --git a/Haromszogek/DHaromszog.cs b/Haromszogek/DHaromszog.cs new file mode 100644 index 0000000..315961c --- /dev/null +++ b/Haromszogek/DHaromszog.cs @@ -0,0 +1,129 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Haromszogek +{ + class DHaromszog + { + private double aOldal; + private double bOldal; + private double cOldal; + + public double a + { + get + { + return aOldal; + } + set + { + if(value>0) + { + aOldal = value; + } else + { + throw new Exception("Az a oldal nem lehet nulla vagy negatív!"); + } + + } + } + + public double b + { + get + { + return bOldal; + } + set + { + if (value > 0) + { + bOldal = value; + } + else + { + throw new Exception("A b oldal nem lehet nulla vagy negatív!"); + } + + } + } + + public double c + { + get + { + return cOldal; + } + set + { + if (value > 0) + { + cOldal = value; + } + else + { + throw new Exception("A c oldal nem lehet nulla vagy negatív!"); + } + + } + } + + public int SorSzama { get; set; } + + private bool EllNovekvoSorrend + { + get + { + return (a <= b) && (b <= c); + } + } + + private bool EllMegszerkesztheto + { + get + { + return (a + b) > c; + } + } + + private bool EllDerekszogu + { + get + { + return a*a + b*b == c*c; + } + } + + public double Kerulet + { + get { return a + b + c; } + } + + public double Terulet + { + get { return a * b / 2; } + } + + public DHaromszog(string sor, int sorSzama) + { + this.SorSzama = sorSzama; + string[] t = sor.Split(' '); + double a = double.Parse(t[0]); + double b = double.Parse(t[1]); + double c = double.Parse(t[2]); + this.a = a; + this.b = b; + this.c = c; + if (!EllNovekvoSorrend) throw new Exception("Az adatok nincsenek növekvő rendben!"); + if (!EllMegszerkesztheto) throw new Exception("A háromszöget nem lehet megszerkeszteni!"); + if (!EllDerekszogu) throw new Exception("A háromszög nem derékszögű!"); + + } + + public override string ToString() + { + return $"{SorSzama}.sor a={a} b={b} c={c}"; + } + } +} diff --git a/Haromszogek/Form1.Designer.cs b/Haromszogek/Form1.Designer.cs new file mode 100644 index 0000000..ce210b5 --- /dev/null +++ b/Haromszogek/Form1.Designer.cs @@ -0,0 +1,145 @@ + +namespace Haromszogek +{ + 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.groupBox1 = new System.Windows.Forms.GroupBox(); + this.listBox1 = new System.Windows.Forms.ListBox(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.listBox2 = new System.Windows.Forms.ListBox(); + this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.listBox3 = new System.Windows.Forms.ListBox(); + this.groupBox1.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.groupBox3.SuspendLayout(); + this.SuspendLayout(); + // + // button1 + // + this.button1.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.button1.Location = new System.Drawing.Point(27, 24); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(163, 36); + this.button1.TabIndex = 0; + this.button1.Text = "Adatok betöltése"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.listBox1); + this.groupBox1.Location = new System.Drawing.Point(27, 76); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(628, 157); + this.groupBox1.TabIndex = 1; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Hibák a kiválasztott állományban"; + // + // listBox1 + // + this.listBox1.Dock = System.Windows.Forms.DockStyle.Fill; + this.listBox1.FormattingEnabled = true; + this.listBox1.ItemHeight = 15; + this.listBox1.Location = new System.Drawing.Point(3, 19); + this.listBox1.Name = "listBox1"; + this.listBox1.Size = new System.Drawing.Size(622, 135); + this.listBox1.TabIndex = 0; + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.listBox2); + this.groupBox2.Location = new System.Drawing.Point(24, 239); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(212, 177); + this.groupBox2.TabIndex = 2; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Derékszögű háromszögek"; + // + // listBox2 + // + this.listBox2.Dock = System.Windows.Forms.DockStyle.Fill; + this.listBox2.FormattingEnabled = true; + this.listBox2.ItemHeight = 15; + this.listBox2.Location = new System.Drawing.Point(3, 19); + this.listBox2.Name = "listBox2"; + this.listBox2.Size = new System.Drawing.Size(206, 155); + this.listBox2.TabIndex = 0; + this.listBox2.SelectedIndexChanged += new System.EventHandler(this.listBox2_SelectedIndexChanged); + // + // groupBox3 + // + this.groupBox3.Controls.Add(this.listBox3); + this.groupBox3.Location = new System.Drawing.Point(272, 239); + this.groupBox3.Name = "groupBox3"; + this.groupBox3.Size = new System.Drawing.Size(380, 174); + this.groupBox3.TabIndex = 3; + this.groupBox3.TabStop = false; + this.groupBox3.Text = "A kiválasztott derékszögű háromszög adatai"; + // + // listBox3 + // + this.listBox3.Dock = System.Windows.Forms.DockStyle.Fill; + this.listBox3.FormattingEnabled = true; + this.listBox3.ItemHeight = 15; + this.listBox3.Location = new System.Drawing.Point(3, 19); + this.listBox3.Name = "listBox3"; + this.listBox3.Size = new System.Drawing.Size(374, 152); + this.listBox3.TabIndex = 0; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(685, 450); + this.Controls.Add(this.groupBox3); + this.Controls.Add(this.groupBox2); + this.Controls.Add(this.groupBox1); + this.Controls.Add(this.button1); + this.Name = "Form1"; + this.Text = "Form1"; + this.groupBox1.ResumeLayout(false); + this.groupBox2.ResumeLayout(false); + this.groupBox3.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button button1; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.ListBox listBox1; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.ListBox listBox2; + private System.Windows.Forms.GroupBox groupBox3; + private System.Windows.Forms.ListBox listBox3; + } +} + diff --git a/Haromszogek/Form1.cs b/Haromszogek/Form1.cs new file mode 100644 index 0000000..8dd1136 --- /dev/null +++ b/Haromszogek/Form1.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Haromszogek +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + } + + private void button1_Click(object sender, EventArgs e) + { + OpenFileDialog of = new OpenFileDialog(); + if (of.ShowDialog()==DialogResult.OK) + { + listBox1.Items.Clear(); + listBox2.Items.Clear(); + listBox3.Items.Clear(); + string fajlnev = of.FileName; + string[] sorok = File.ReadAllLines(fajlnev); + for (int i = 0; i < sorok.Length; i++) + { + try + { + DHaromszog dh = new DHaromszog(sorok[i], i + 1); + listBox2.Items.Add(dh); + } + catch (Exception hiba) + { + listBox1.Items.Add($"{i+1}. sor: {hiba.Message}"); + + } + + } + + } + } + + private void listBox2_SelectedIndexChanged(object sender, EventArgs e) + { + if (listBox2.SelectedIndex>=0) + { + DHaromszog dh = (DHaromszog)listBox2.SelectedItem; + listBox3.Items.Clear(); + listBox3.Items.Add("Kerület= " + dh.Kerulet.ToString("F2")); + listBox3.Items.Add("Terület= " + dh.Terulet.ToString("F2")); + } + } + } +} diff --git a/Haromszogek/Form1.resx b/Haromszogek/Form1.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/Haromszogek/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/Haromszogek/Haromszogek.csproj b/Haromszogek/Haromszogek.csproj new file mode 100644 index 0000000..130a486 --- /dev/null +++ b/Haromszogek/Haromszogek.csproj @@ -0,0 +1,9 @@ + + + + WinExe + netcoreapp3.1 + true + + + \ No newline at end of file diff --git a/Haromszogek/Program.cs b/Haromszogek/Program.cs new file mode 100644 index 0000000..28ffc9c --- /dev/null +++ b/Haromszogek/Program.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Haromszogek +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.SetHighDpiMode(HighDpiMode.SystemAware); + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +}