Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

KA2KWE_LNE7I2 #15

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions KA2KWE_LNE7I2/KA2KWE_LNE7I2.sln
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions KA2KWE_LNE7I2/KA2KWE_LNE7I2/KA2KWE_LNE7I2.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
32 changes: 32 additions & 0 deletions KA2KWE_LNE7I2/KA2KWE_LNE7I2/Kutya.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
}
143 changes: 143 additions & 0 deletions KA2KWE_LNE7I2/KA2KWE_LNE7I2/Program.cs
Original file line number Diff line number Diff line change
@@ -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<int> 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<int> szamoklistaja = new List<int>();
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<int>));
serilaizer.Serialize(fs, szamoklistaja);
}
szamoklistaja = null;
XmlSerializer serializer1 = new XmlSerializer(typeof(List<int>));
using (FileStream fs2 = File.OpenRead(@"E:\\mukodj\szamok.xml"))
{
szamoklistaja = (List<int>)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<int> 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<int> szamoklistaja = new List<int>();
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();




}




}
22 changes: 22 additions & 0 deletions KA2KWE_LNE7I2/KA2KWE_LNE7I2Tests/KA2KWE_LNE7I2Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
<PackageReference Include="coverlet.collector" Version="3.1.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\KA2KWE_LNE7I2\KA2KWE_LNE7I2.csproj" />
</ItemGroup>

</Project>
54 changes: 54 additions & 0 deletions KA2KWE_LNE7I2/KA2KWE_LNE7I2Tests/KutyaTests.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
12 changes: 12 additions & 0 deletions KA2KWE_LNE7I2/KA2KWE_LNE7I2Tests/ProgramTests.cs
Original file line number Diff line number Diff line change
@@ -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
{
}
}
21 changes: 19 additions & 2 deletions hazifeladatok.sln
Original file line number Diff line number Diff line change
@@ -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