From 4a9624fcc17a6572c26813500cffe36e20717915 Mon Sep 17 00:00:00 2001 From: hofferaron Date: Fri, 10 Feb 2023 18:57:26 +0100 Subject: [PATCH] Add project files. --- TeglalapObjektum.sln | 25 +++++++++++++++++++++ TeglalapObjektum/Program.cs | 28 ++++++++++++++++++++++++ TeglalapObjektum/Teglalap.cs | 25 +++++++++++++++++++++ TeglalapObjektum/TeglalapObjektum.csproj | 8 +++++++ 4 files changed, 86 insertions(+) create mode 100644 TeglalapObjektum.sln create mode 100644 TeglalapObjektum/Program.cs create mode 100644 TeglalapObjektum/Teglalap.cs create mode 100644 TeglalapObjektum/TeglalapObjektum.csproj diff --git a/TeglalapObjektum.sln b/TeglalapObjektum.sln new file mode 100644 index 0000000..2fdc8cc --- /dev/null +++ b/TeglalapObjektum.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.32802.440 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeglalapObjektum", "TeglalapObjektum\TeglalapObjektum.csproj", "{F1DC4F69-7E4F-474D-870E-A1279D188461}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F1DC4F69-7E4F-474D-870E-A1279D188461}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F1DC4F69-7E4F-474D-870E-A1279D188461}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F1DC4F69-7E4F-474D-870E-A1279D188461}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F1DC4F69-7E4F-474D-870E-A1279D188461}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7161D1AB-BE37-41F7-90E8-5DC0F19DDBA3} + EndGlobalSection +EndGlobal diff --git a/TeglalapObjektum/Program.cs b/TeglalapObjektum/Program.cs new file mode 100644 index 0000000..81b4538 --- /dev/null +++ b/TeglalapObjektum/Program.cs @@ -0,0 +1,28 @@ +using System; + +namespace TeglalapObjektum +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Tégalap objektumok létrehozása:"); + Teglalap t1 = new Teglalap(); //Példányosítás t1 + Teglalap t2 = new Teglalap(); //Példányosítás t2 + t1.aoldal = 7.5; + t1.boldal = 20.9; + t2.aoldal = 100; + t2.boldal = 24.7; + Console.WriteLine($"A t1 téglalap a: {t1.aoldal}, b: {t1.boldal} T: {t1.terulet()}"); //fontos, hogy ott legyen a zárójel, mert függvény + Console.WriteLine($"A t2 téglalap a: {t2.aoldal}, b: {t2.boldal} T: {t2.terulet()}"); + + Teglalap t3 = new Teglalap(); + t3.aoldal = 3; + t3.boldal = 120; //nem csakadatokat tudok belerakni egy objektumba + Console.WriteLine("t3 adatai:"); + t3.kiir(); //itt már a téglalap tudja magát kiírni, ennek mintájára már a többiis tudja + Console.WriteLine("t1 adatai:"); + t1.kiir(); //itt már a téglalap tudja magát kiírni, ennek mintájára már a többiis tudja + } + } +} diff --git a/TeglalapObjektum/Teglalap.cs b/TeglalapObjektum/Teglalap.cs new file mode 100644 index 0000000..2fee7b1 --- /dev/null +++ b/TeglalapObjektum/Teglalap.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TeglalapObjektum +{ + class Teglalap + { + public double aoldal; + public double boldal; + + public double terulet() //eljárás metódus, nincs itt a static , ha példányaim vannak nem kell static szó, ez függvény, doublet ad vissza, void szónál nem ad vissza értéket + + { + return aoldal * boldal; + } + + public void kiir() //minden téglalap saját maga írja ki + { + Console.WriteLine($"a: {aoldal}, b: {boldal}, T: {terulet():F3}"); //itt már nincs t.1 mert sajátját írja ki; a terület adatját 3 tizedesre írjam ki; :F3; előny hogy csak itt kell módosítanom + } + } +} diff --git a/TeglalapObjektum/TeglalapObjektum.csproj b/TeglalapObjektum/TeglalapObjektum.csproj new file mode 100644 index 0000000..2082704 --- /dev/null +++ b/TeglalapObjektum/TeglalapObjektum.csproj @@ -0,0 +1,8 @@ + + + + Exe + net5.0 + + +