diff --git a/KA2KWE_LNE7I2/KA2KWE_LNE7I2.sln b/KA2KWE_LNE7I2/KA2KWE_LNE7I2.sln new file mode 100644 index 0000000..50bb1b1 --- /dev/null +++ b/KA2KWE_LNE7I2/KA2KWE_LNE7I2.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33122.133 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KA2KWE_LNE7I2", "KA2KWE_LNE7I2\KA2KWE_LNE7I2.csproj", "{5835BC21-6E36-493F-8181-45C3A007CB6F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KA2KWE_LNE7I2Tests", "KA2KWE_LNE7I2Tests\KA2KWE_LNE7I2Tests.csproj", "{CDABB595-9C04-4262-BC94-F22C1A131520}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5835BC21-6E36-493F-8181-45C3A007CB6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5835BC21-6E36-493F-8181-45C3A007CB6F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5835BC21-6E36-493F-8181-45C3A007CB6F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5835BC21-6E36-493F-8181-45C3A007CB6F}.Release|Any CPU.Build.0 = Release|Any CPU + {CDABB595-9C04-4262-BC94-F22C1A131520}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CDABB595-9C04-4262-BC94-F22C1A131520}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CDABB595-9C04-4262-BC94-F22C1A131520}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CDABB595-9C04-4262-BC94-F22C1A131520}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {DE47A104-8D76-4B2C-ACCA-B1E2FD39AEBE} + EndGlobalSection +EndGlobal diff --git a/KA2KWE_LNE7I2/KA2KWE_LNE7I2/KA2KWE_LNE7I2.csproj b/KA2KWE_LNE7I2/KA2KWE_LNE7I2/KA2KWE_LNE7I2.csproj new file mode 100644 index 0000000..74abf5c --- /dev/null +++ b/KA2KWE_LNE7I2/KA2KWE_LNE7I2/KA2KWE_LNE7I2.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/KA2KWE_LNE7I2/KA2KWE_LNE7I2/Kutya.cs b/KA2KWE_LNE7I2/KA2KWE_LNE7I2/Kutya.cs new file mode 100644 index 0000000..bd9d89d --- /dev/null +++ b/KA2KWE_LNE7I2/KA2KWE_LNE7I2/Kutya.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace KA2KWE_LNE7I2 +{ + public class Kutya + { + private readonly int _kor; + private readonly string _nev; + private readonly bool _ehes; + + public Kutya(int kor, string nev, bool ehes) + { + _kor = kor; + _nev = nev; + _ehes = ehes; + + } + public int Kor { get { return _kor; } } + public string Nev { get { return _nev; } } + + public bool Ehes { get { return _ehes; } } + + public Kutya Etet() { return new Kutya(_kor, _nev, false); } + public Kutya Megehez() { return new Kutya(_kor, _nev, true); } + public Kutya Oregedes() { return new Kutya((_kor + 1), _nev, _ehes); } + public int Evszamkonvertalas() { return _kor * 7; } + } +} diff --git a/KA2KWE_LNE7I2/KA2KWE_LNE7I2/Program.cs b/KA2KWE_LNE7I2/KA2KWE_LNE7I2/Program.cs new file mode 100644 index 0000000..b66e471 --- /dev/null +++ b/KA2KWE_LNE7I2/KA2KWE_LNE7I2/Program.cs @@ -0,0 +1,143 @@ + +using System.Runtime.Serialization; +using System.Runtime.Serialization.Formatters.Binary; +using System.IO; +using System.Xml.Serialization; +using System.Security.Cryptography.X509Certificates; +using KA2KWE_LNE7I2; + +[Serializable()] +public class Program : ISerializable +{ + public static List adatbekeres() + { + + Console.WriteLine("adj meg 10 szamot"); + int[] szamtomb = new int[10]; + for (int i = 0; i < 10; i++) + { + int beolvasott; + beolvasott = Convert.ToInt32(Console.ReadLine()); + szamtomb[i] = beolvasott; + } + List szamoklistaja = new List(); + for (int i = 0; i < 10; i++) + { + szamoklistaja.Add(szamtomb[i]); + } + try + { + using (Stream fs = new FileStream(@"E:\\mukodj\szamok.xml", FileMode.Create, FileAccess.Write, FileShare.None)) + { + XmlSerializer serilaizer = new XmlSerializer(typeof(List)); + serilaizer.Serialize(fs, szamoklistaja); + } + szamoklistaja = null; + XmlSerializer serializer1 = new XmlSerializer(typeof(List)); + using (FileStream fs2 = File.OpenRead(@"E:\\mukodj\szamok.xml")) + { + szamoklistaja = (List)serializer1.Deserialize(fs2); + + } + Console.WriteLine("Az elmentet szamok:"); + foreach (int i in szamoklistaja) + { + Console.WriteLine(i); + } + return szamoklistaja; + + } + catch (IOException e) { Console.WriteLine("IOexception kelettkezett"); return null; } + catch (Exception e) { throw; return null; } + } + public static void minimumvagymaximum(List szamoklistaja) + { + int valasz = 0; + + while (true) + { + + Console.WriteLine("Irjon 1-et ha a szamok kozul a minimumot szeretne megnezni, 2-ot ha a szamok maximumat."); + valasz = Convert.ToInt32(Console.ReadLine()); + if (valasz == 1) + { + int minimum = szamoklistaja.AsQueryable().Min(); + Console.WriteLine("A megadott szamok minimuma:\n"); + vegrehajt(); + Thread.Sleep(3200); + Console.WriteLine(minimum); + break; + } + else if (valasz == 2) + { + int max = szamoklistaja.AsQueryable().Max(); + Console.WriteLine("A megadott szamok maximuma:\n"); + vegrehajt(); + Thread.Sleep(3200); + Console.WriteLine(max); + break; + } + else + { + Console.BackgroundColor = ConsoleColor.Red; + Console.Error.WriteLine("Nem megfelelo valasz, kerlek 1 vagy 2 irj be."); + Console.BackgroundColor = ConsoleColor.Black; + } + } + } + public void GetObjectData(SerializationInfo info, StreamingContext context) + { + throw new NotImplementedException(); + } + public static async void vegrehajt() + { + Console.WriteLine("Szamolas!"); + await hosszuszamolas(); + + Console.WriteLine("Szamolas befejezodott!"); + } + private static async Task hosszuszamolas() + { + await Task.Run(() => + { + + Console.WriteLine("Szamol..."); + Thread.Sleep(3000); + }); + + } + static void Main(string[] args) + { + + List szamoklistaja = new List(); + szamoklistaja = adatbekeres(); + minimumvagymaximum(szamoklistaja); + + //-------------------- Kutya + Console.WriteLine("\n \n Kutyas resz:"); + Kutya Zsebi=new Kutya(4,"Zsebi",true); + Console.WriteLine("A kutya adatai:"); + Console.WriteLine("Kutya kora:{0},Kutya neve:{1},Kutya ehes-e?:{2}", Zsebi.Kor, Zsebi.Nev, Zsebi.Ehes); + Console.WriteLine("Oregedik a kutya"); + Zsebi=Zsebi.Oregedes(); + Console.WriteLine("Kutya kora:{0},Kutya neve:{1},Kutya ehes-e?:{2}", Zsebi.Kor, Zsebi.Nev, Zsebi.Ehes); + Console.WriteLine("Megetetjuk Zsebit"); + Zsebi=Zsebi.Etet(); + Console.WriteLine("Kutya kora:{0},Kutya neve:{1},Kutya ehes-e?:{2}", Zsebi.Kor, Zsebi.Nev, Zsebi.Ehes); + int emberievekben=new int(); + emberievekben=Zsebi.Evszamkonvertalas(); + Console.WriteLine("Kutya eletkora kutya evekbe konvertalva:{0}", emberievekben); + Console.WriteLine("Zsebi mindig tudna enni ezert megint megehezett"); + Zsebi=Zsebi.Megehez(); + Console.WriteLine("Kutya kora:{0},Kutya neve:{1},Kutya ehes-e?:{2}", Zsebi.Kor, Zsebi.Nev, Zsebi.Ehes); + Console.Read(); + + + + + } + + + + +} \ No newline at end of file diff --git a/KA2KWE_LNE7I2/KA2KWE_LNE7I2Tests/KA2KWE_LNE7I2Tests.csproj b/KA2KWE_LNE7I2/KA2KWE_LNE7I2Tests/KA2KWE_LNE7I2Tests.csproj new file mode 100644 index 0000000..d69a490 --- /dev/null +++ b/KA2KWE_LNE7I2/KA2KWE_LNE7I2Tests/KA2KWE_LNE7I2Tests.csproj @@ -0,0 +1,22 @@ + + + + net6.0 + enable + enable + + false + + + + + + + + + + + + + + diff --git a/KA2KWE_LNE7I2/KA2KWE_LNE7I2Tests/KutyaTests.cs b/KA2KWE_LNE7I2/KA2KWE_LNE7I2Tests/KutyaTests.cs new file mode 100644 index 0000000..929c8ee --- /dev/null +++ b/KA2KWE_LNE7I2/KA2KWE_LNE7I2Tests/KutyaTests.cs @@ -0,0 +1,54 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using KA2KWE_LNE7I2; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace KA2KWE_LNE7I2.Tests +{ + [TestClass()] + public class KutyaTests + { + [TestMethod()] + public void KutyaTest() + { + Kutya Dinnye = new Kutya(1, "Dinnye", true); + + Assert.AreEqual(1, Dinnye.Kor); + } + + [TestMethod()] + public void EtetTest() + { + Kutya Dinnye = new Kutya(1, "Dinnye", true); + Dinnye = Dinnye.Etet(); + Assert.IsFalse( Dinnye.Ehes); + } + + [TestMethod()] + public void MegehezTest() + { + Kutya Dinnye = new Kutya(1, "Dinnye", false); + Dinnye = Dinnye.Megehez(); + Assert.IsTrue(Dinnye.Ehes); + } + + [TestMethod()] + public void OregedesTest() + { + Kutya Dinnye = new Kutya(1, "Dinnye", true); + Dinnye= Dinnye.Oregedes(); + Assert.AreEqual(2,Dinnye.Kor); + } + + [TestMethod()] + public void EvszamkonvertalasTest() + { + Kutya Dinnye = new Kutya(1, "Dinnye", true); + int kutyaevben = Dinnye.Evszamkonvertalas(); + Assert.AreEqual(Dinnye.Kor*7,kutyaevben); + } + } +} \ No newline at end of file diff --git a/KA2KWE_LNE7I2/KA2KWE_LNE7I2Tests/ProgramTests.cs b/KA2KWE_LNE7I2/KA2KWE_LNE7I2Tests/ProgramTests.cs new file mode 100644 index 0000000..a7f0645 --- /dev/null +++ b/KA2KWE_LNE7I2/KA2KWE_LNE7I2Tests/ProgramTests.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace KA2KWE_LNE7I2Tests +{ + internal class ProgramTests + { + } +} diff --git a/hazifeladatok.sln b/hazifeladatok.sln index 58ea566..6ecac6e 100644 --- a/hazifeladatok.sln +++ b/hazifeladatok.sln @@ -1,14 +1,31 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 -VisualStudioVersion = 17.0.31903.59 +VisualStudioVersion = 17.4.33122.133 MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KA2KWE_LNE7I2", "KA2KWE_LNE7I2\KA2KWE_LNE7I2.csproj", "{5835BC21-6E36-493F-8181-45C3A007CB6F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KA2KWE_LNE7I2Tests", "KA2KWE_LNE7I2Tests\KA2KWE_LNE7I2Tests.csproj", "{CDABB595-9C04-4262-BC94-F22C1A131520}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5835BC21-6E36-493F-8181-45C3A007CB6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5835BC21-6E36-493F-8181-45C3A007CB6F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5835BC21-6E36-493F-8181-45C3A007CB6F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5835BC21-6E36-493F-8181-45C3A007CB6F}.Release|Any CPU.Build.0 = Release|Any CPU + {CDABB595-9C04-4262-BC94-F22C1A131520}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CDABB595-9C04-4262-BC94-F22C1A131520}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CDABB595-9C04-4262-BC94-F22C1A131520}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CDABB595-9C04-4262-BC94-F22C1A131520}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection -EndGlobal + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {DE47A104-8D76-4B2C-ACCA-B1E2FD39AEBE} + EndGlobalSection +EndGlobal \ No newline at end of file