mirror of
https://github.com/Lendaia/oe-alga-feladatok.git
synced 2026-04-23 04:16:32 +01:00
Add project files.
This commit is contained in:
6
.editorconfig
Normal file
6
.editorconfig
Normal file
@@ -0,0 +1,6 @@
|
||||
[*.cs]
|
||||
|
||||
dotnet_diagnostic.IDE1006.severity = none
|
||||
dotnet_diagnostic.IDE0090.severity = none
|
||||
dotnet_diagnostic.IDE0290.severity = none
|
||||
dotnet_diagnostic.CA1859.severity = none
|
||||
111
ALGA/ADT.cs
Normal file
111
ALGA/ADT.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
namespace OE.ALGA.Adatszerkezetek
|
||||
{
|
||||
public interface Lista<T>
|
||||
{
|
||||
public int Elemszam { get; }
|
||||
|
||||
public T Kiolvas(int index);
|
||||
public void Modosit(int index, T ertek);
|
||||
public void Hozzafuz(T ertek);
|
||||
public void Beszur(int index, T ertek);
|
||||
public void Torol(T ertek);
|
||||
public void Bejar(Action<T> muvelet);
|
||||
}
|
||||
|
||||
public interface Halmaz<T>
|
||||
{
|
||||
public void Beszur(T ertek);
|
||||
public bool Eleme(T ertek);
|
||||
public void Torol(T ertek);
|
||||
public void Bejar(Action<T> muvelet);
|
||||
}
|
||||
|
||||
public interface Verem<T>
|
||||
{
|
||||
bool Ures { get; }
|
||||
void Verembe(T ertek);
|
||||
T Verembol();
|
||||
T Felso();
|
||||
}
|
||||
|
||||
public interface Sor<T>
|
||||
{
|
||||
bool Ures { get; }
|
||||
void Sorba(T ertek);
|
||||
T Sorbol();
|
||||
T Elso();
|
||||
}
|
||||
|
||||
public interface PrioritasosSor<T>
|
||||
{
|
||||
bool Ures { get; }
|
||||
void Sorba(T ertek);
|
||||
T Sorbol();
|
||||
T Elso();
|
||||
void Frissit(T elem);
|
||||
}
|
||||
|
||||
public interface GrafEl<V>
|
||||
{
|
||||
V Honnan { get; }
|
||||
V Hova { get; }
|
||||
}
|
||||
|
||||
public interface Graf<V, E>
|
||||
{
|
||||
int CsucsokSzama { get; }
|
||||
int ElekSzama { get; }
|
||||
Halmaz<V> Csucsok { get; }
|
||||
Halmaz<E> Elek { get; }
|
||||
bool VezetEl(V honnan, V hova);
|
||||
Halmaz<V> Szomszedai(V csucs);
|
||||
}
|
||||
|
||||
public interface SulyozatlanGraf<V, E> : Graf<V, E>
|
||||
{
|
||||
void UjEl(V honnan, V hova);
|
||||
}
|
||||
|
||||
public interface SulyozottGrafEl<V> : GrafEl<V>
|
||||
{
|
||||
float Suly { get; }
|
||||
}
|
||||
|
||||
public interface SulyozottGraf<V, E> : Graf<V, E>
|
||||
{
|
||||
void UjEl(V honnan, V hova, float suly);
|
||||
float Suly(V honnan, V hova);
|
||||
}
|
||||
|
||||
public interface Szotar<K, T>
|
||||
{
|
||||
public void Beir(K kulcs, T ertek);
|
||||
public T Kiolvas(K kulcs);
|
||||
public void Torol(K kulcs);
|
||||
}
|
||||
|
||||
public class HibasKulcsKivetel : Exception
|
||||
{
|
||||
}
|
||||
|
||||
public class HibasIndexKivetel : Exception
|
||||
{
|
||||
}
|
||||
|
||||
public class NincsElemKivetel : Exception
|
||||
{
|
||||
}
|
||||
|
||||
public class NincsHelyKivetel : Exception
|
||||
{
|
||||
}
|
||||
|
||||
public class NincsElKivetel : Exception
|
||||
{
|
||||
}
|
||||
|
||||
public class NemOsszehasonlithatoKivetel : Exception
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
10
ALGA/ALGA.csproj
Normal file
10
ALGA/ALGA.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>OE.ALGA.Adatszerkezetek</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
57
ALGA_heti_feladatok.sln
Normal file
57
ALGA_heti_feladatok.sln
Normal file
@@ -0,0 +1,57 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.8.34330.188
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ALGAme", "ALGAme\ALGAme.csproj", "{E879C59F-BD64-4DE0-A54F-C632395E62B2}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{F1EF1714-78CB-4FDC-9CE2-B9A7D9F94729} = {F1EF1714-78CB-4FDC-9CE2-B9A7D9F94729}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Engine", "Engine\Engine.csproj", "{15A07E98-65CB-4894-B600-8CAF16AEBA75}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ALGA", "ALGA\ALGA.csproj", "{F1EF1714-78CB-4FDC-9CE2-B9A7D9F94729}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tesztek", "Tesztek\Tesztek.csproj", "{87FEB91B-F223-432E-9A58-1CD0D6894896}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{18C1E947-7BE8-466A-AF69-8EDAF6ADEB3E}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.editorconfig = .editorconfig
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sandbox", "Sandbox\Sandbox.csproj", "{2517350C-751A-4876-AEDE-D6AE9D6815C7}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{E879C59F-BD64-4DE0-A54F-C632395E62B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E879C59F-BD64-4DE0-A54F-C632395E62B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E879C59F-BD64-4DE0-A54F-C632395E62B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E879C59F-BD64-4DE0-A54F-C632395E62B2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{15A07E98-65CB-4894-B600-8CAF16AEBA75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{15A07E98-65CB-4894-B600-8CAF16AEBA75}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{15A07E98-65CB-4894-B600-8CAF16AEBA75}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{15A07E98-65CB-4894-B600-8CAF16AEBA75}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F1EF1714-78CB-4FDC-9CE2-B9A7D9F94729}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F1EF1714-78CB-4FDC-9CE2-B9A7D9F94729}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F1EF1714-78CB-4FDC-9CE2-B9A7D9F94729}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F1EF1714-78CB-4FDC-9CE2-B9A7D9F94729}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{87FEB91B-F223-432E-9A58-1CD0D6894896}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{87FEB91B-F223-432E-9A58-1CD0D6894896}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{87FEB91B-F223-432E-9A58-1CD0D6894896}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{87FEB91B-F223-432E-9A58-1CD0D6894896}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2517350C-751A-4876-AEDE-D6AE9D6815C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2517350C-751A-4876-AEDE-D6AE9D6815C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2517350C-751A-4876-AEDE-D6AE9D6815C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2517350C-751A-4876-AEDE-D6AE9D6815C7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {AD85FE57-DF45-4952-926D-B1F4A0316100}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
16
ALGAme/ALGAme.csproj
Normal file
16
ALGAme/ALGAme.csproj
Normal file
@@ -0,0 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>OE.ALGA.ALGAme</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ALGA\ALGA.csproj" />
|
||||
<ProjectReference Include="..\Engine\Engine.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
42
ALGAme/Jatek.cs
Normal file
42
ALGAme/Jatek.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using OE.ALGA.Engine;
|
||||
|
||||
namespace OE.ALGA.ALGAme
|
||||
{
|
||||
public class Jatek
|
||||
{
|
||||
readonly Terkep terkep;
|
||||
public Terkep Terkep { get { return terkep; } }
|
||||
|
||||
readonly Backend backend;
|
||||
public Backend Backend { get { return backend; } }
|
||||
|
||||
public Jatek()
|
||||
{
|
||||
backend = new Backend();
|
||||
terkep = new Terkep(Param.TERKEP_SZELESSEG, Param.TERKEP_MAGASSAG);
|
||||
|
||||
PalyaGeneralas();
|
||||
NezopontokLetrehozasa();
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
backend.Start();
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
backend.Stop();
|
||||
}
|
||||
|
||||
private void PalyaGeneralas()
|
||||
{
|
||||
terkep.LabirintusGeneralas();
|
||||
}
|
||||
|
||||
private void NezopontokLetrehozasa()
|
||||
{
|
||||
backend.Megjelenites.NezopontFelvetele(terkep);
|
||||
}
|
||||
}
|
||||
}
|
||||
4
ALGAme/Program.cs
Normal file
4
ALGAme/Program.cs
Normal file
@@ -0,0 +1,4 @@
|
||||
using OE.ALGA.ALGAme;
|
||||
|
||||
Jatek jatek = new Jatek();
|
||||
jatek.Start();
|
||||
91
Engine/AlapTipusok.cs
Normal file
91
Engine/AlapTipusok.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
namespace OE.ALGA.Engine
|
||||
{
|
||||
public class KetElemuVektor : IComparable
|
||||
{
|
||||
readonly int x;
|
||||
readonly int y;
|
||||
|
||||
public int X { get { return x; } }
|
||||
public int Y { get { return y; } }
|
||||
|
||||
public KetElemuVektor(int x, int y)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj != null && obj is KetElemuVektor b)
|
||||
{
|
||||
return X == b.X && Y == b.Y;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return X.GetHashCode() ^ Y.GetHashCode();
|
||||
}
|
||||
|
||||
public int CompareTo(object? obj)
|
||||
{
|
||||
if (obj != null && obj is KetElemuVektor b)
|
||||
{
|
||||
if (x != b.x)
|
||||
return x.CompareTo(b.x);
|
||||
else
|
||||
return y.CompareTo(b.y);
|
||||
}
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
public static bool operator ==(KetElemuVektor a, KetElemuVektor b) => a.Equals(b);
|
||||
public static bool operator !=(KetElemuVektor a, KetElemuVektor b) => !a.Equals(b);
|
||||
}
|
||||
|
||||
public class Pozicio : KetElemuVektor
|
||||
{
|
||||
public Pozicio(int x, int y) : base(x, y)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static Pozicio operator +(Pozicio p, Irany m) => new Pozicio(p.X + m.X, p.Y + m.Y);
|
||||
public static double Tavolsag(Pozicio a, Pozicio b) => Math.Sqrt(Math.Pow(a.X - b.X, 2) + Math.Pow(a.Y - b.Y, 2));
|
||||
}
|
||||
|
||||
public class Irany : KetElemuVektor
|
||||
{
|
||||
public static readonly Irany[] FoIranyok = new Irany[4] { new Irany(0, -1), new Irany(-1, 0), new Irany(0, 1), new Irany(1, 0) };
|
||||
|
||||
public static int Balra(int iranyIndex)
|
||||
{
|
||||
return (iranyIndex - 1 + 4) % 4;
|
||||
}
|
||||
|
||||
public static int Jobbra(int iranyIndex)
|
||||
{
|
||||
return (iranyIndex + 1) % 4;
|
||||
}
|
||||
|
||||
public Irany(int x, int y) : base(x, y)
|
||||
{
|
||||
}
|
||||
|
||||
public static Irany operator *(Irany i, int s) => new Irany(i.X * s, i.Y * s);
|
||||
}
|
||||
|
||||
public class Meret
|
||||
{
|
||||
public int Szelesseg { get; set; }
|
||||
public int Magassag { get; set; }
|
||||
|
||||
public Meret(int szelesseg, int magassag)
|
||||
{
|
||||
this.Szelesseg = szelesseg;
|
||||
this.Magassag = magassag;
|
||||
}
|
||||
}
|
||||
}
|
||||
31
Engine/Backend.cs
Normal file
31
Engine/Backend.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
namespace OE.ALGA.Engine
|
||||
{
|
||||
public class Backend
|
||||
{
|
||||
public Kepernyo Megjelenites { get; } = new Kepernyo();
|
||||
public BillentyuzetKezelo Bemenet { get; } = new BillentyuzetKezelo();
|
||||
public OrajelGenerator Orajel { get; } = new OrajelGenerator();
|
||||
|
||||
public Backend()
|
||||
{
|
||||
Orajel.OrajelFogadoFelvetele(Bemenet);
|
||||
Orajel.OrajelFogadoFelvetele(Megjelenites);
|
||||
}
|
||||
|
||||
bool kilepes = false;
|
||||
public void Start()
|
||||
{
|
||||
Orajel.Start();
|
||||
while (!kilepes)
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
Orajel.Stop();
|
||||
kilepes = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
43
Engine/BillentyuzetKezelo.cs
Normal file
43
Engine/BillentyuzetKezelo.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
namespace OE.ALGA.Engine
|
||||
{
|
||||
public interface IBillentyuLenyomasKezelo
|
||||
{
|
||||
void BillentyuLenyomas(ConsoleKey billentyu);
|
||||
}
|
||||
|
||||
public class BillentyuzetKezelo : IOrajelFogado
|
||||
{
|
||||
private readonly List<IBillentyuLenyomasKezelo> billentyuLenyomasKezelok = new List<IBillentyuLenyomasKezelo>();
|
||||
|
||||
public void BillentyuLenyomasKezeloFelvetele(IBillentyuLenyomasKezelo kezelo)
|
||||
{
|
||||
billentyuLenyomasKezelok.Add(kezelo);
|
||||
}
|
||||
|
||||
public void BillentyuLenyomasKezeloEltavolitasa(IBillentyuLenyomasKezelo kezelo)
|
||||
{
|
||||
billentyuLenyomasKezelok.Remove(kezelo);
|
||||
}
|
||||
|
||||
private readonly Dictionary<ConsoleKey, Action> billentyuAkciok = new Dictionary<ConsoleKey, Action>();
|
||||
|
||||
public void BillentyuAkcioFelvetele(ConsoleKey billentyu, Action akcio)
|
||||
{
|
||||
billentyuAkciok.Add(billentyu, akcio);
|
||||
}
|
||||
|
||||
public void Orajel(int ido)
|
||||
{
|
||||
while (Console.KeyAvailable)
|
||||
{
|
||||
ConsoleKey billentyu = Console.ReadKey(true).Key;
|
||||
foreach (IBillentyuLenyomasKezelo kezelo in billentyuLenyomasKezelok)
|
||||
{
|
||||
kezelo.BillentyuLenyomas(billentyu);
|
||||
}
|
||||
if (billentyuAkciok.TryGetValue(billentyu, out Action? value))
|
||||
value();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Engine/Engine.csproj
Normal file
10
Engine/Engine.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>OE.ALGA.Engine</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
12
Engine/GlobalSuppressions.cs
Normal file
12
Engine/GlobalSuppressions.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
// This file is used by Code Analysis to maintain SuppressMessage
|
||||
// attributes that are applied to this project.
|
||||
// Project-level suppressions either have no target or are given
|
||||
// a specific target and scoped to a namespace, type, member, etc.
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
[assembly: SuppressMessage("Style", "IDE0290:Use primary constructor", Justification = "<Pending>", Scope = "module")]
|
||||
[assembly: SuppressMessage("Style", "IDE0300:Simplify collection initialization", Justification = "<Pending>", Scope = "module")]
|
||||
[assembly: SuppressMessage("Style", "IDE0090:Use 'new(...)'", Justification = "<Pending>", Scope = "module")]
|
||||
[assembly: SuppressMessage("Style", "IDE0028:Simplify collection initialization", Justification = "<Pending>", Scope = "module")]
|
||||
[assembly: SuppressMessage("Style", "IDE0305:Simplify collection initialization", Justification = "<Pending>", Scope = "module")]
|
||||
22
Engine/Kivetelek.cs
Normal file
22
Engine/Kivetelek.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
namespace OE.ALGA.Engine
|
||||
{
|
||||
public class UtkozesKivetel : Exception
|
||||
{
|
||||
public TerkepElem Forras { get; set; }
|
||||
public TerkepElem Utkozes { get; set; }
|
||||
|
||||
public UtkozesKivetel(TerkepElem forras, TerkepElem utkozes)
|
||||
{
|
||||
this.Forras = forras;
|
||||
this.Utkozes = utkozes;
|
||||
}
|
||||
}
|
||||
|
||||
public class NemLehetIdeLepniKivetel : UtkozesKivetel
|
||||
{
|
||||
public NemLehetIdeLepniKivetel(TerkepElem forras, TerkepElem utkozes) : base(forras, utkozes)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
209
Engine/KonzolMegjelenito.cs
Normal file
209
Engine/KonzolMegjelenito.cs
Normal file
@@ -0,0 +1,209 @@
|
||||
using System.Text;
|
||||
|
||||
namespace OE.ALGA.Engine
|
||||
{
|
||||
public interface IMegjelenitheto
|
||||
{
|
||||
public Pozicio Pozicio { get; }
|
||||
public Jel Jel { get; }
|
||||
}
|
||||
|
||||
public class FixJel : IMegjelenitheto
|
||||
{
|
||||
public Pozicio Pozicio { get; private set; }
|
||||
|
||||
public Jel Jel { get; private set; }
|
||||
|
||||
public FixJel(Pozicio pozicio, Jel jel)
|
||||
{
|
||||
this.Pozicio = pozicio;
|
||||
this.Jel = jel;
|
||||
}
|
||||
|
||||
public FixJel(IMegjelenitheto eredeti)
|
||||
{
|
||||
this.Pozicio = eredeti.Pozicio;
|
||||
this.Jel = eredeti.Jel;
|
||||
}
|
||||
|
||||
public static FixJel[] SzovegbolJelsor(string szoveg, Pozicio hely, ConsoleColor szin)
|
||||
{
|
||||
FixJel[] jelsor = new FixJel[szoveg.Length];
|
||||
for (int i = 0; i < szoveg.Length; i++)
|
||||
jelsor[i] = new FixJel(new Pozicio(hely.X + i, hely.Y), new Jel(szoveg[i], szin));
|
||||
return jelsor;
|
||||
}
|
||||
}
|
||||
|
||||
public class Jel
|
||||
{
|
||||
readonly char karakter;
|
||||
readonly ConsoleColor szin;
|
||||
|
||||
public char Karakter { get { return karakter; } }
|
||||
public ConsoleColor Szin { get { return szin; } }
|
||||
|
||||
public Jel(char karakter, ConsoleColor szin)
|
||||
{
|
||||
this.karakter = karakter;
|
||||
this.szin = szin;
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj != null && obj is Jel b)
|
||||
{
|
||||
return this.Karakter == b.Karakter && this.Szin == b.Szin;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return karakter.GetHashCode() ^ szin.GetHashCode();
|
||||
}
|
||||
|
||||
public static bool operator ==(Jel a, Jel b) => a is not null && a.Equals(b);
|
||||
public static bool operator !=(Jel a, Jel b) => a is null || !a.Equals(b);
|
||||
}
|
||||
|
||||
public interface INezopont
|
||||
{
|
||||
string Fejlec { get; }
|
||||
Meret Meret { get; }
|
||||
IMegjelenitheto[] MegjelenitendoElemek();
|
||||
}
|
||||
|
||||
public class Kepernyo : IOrajelFogado
|
||||
{
|
||||
readonly Meret meret;
|
||||
readonly Jel[,] puffer;
|
||||
readonly Jel[,] utolso;
|
||||
|
||||
public Kepernyo(int szelesseg, int magassag)
|
||||
{
|
||||
meret = new Meret(szelesseg, magassag);
|
||||
|
||||
Console.CursorVisible = false;
|
||||
Console.OutputEncoding = Encoding.Unicode;
|
||||
|
||||
puffer = new Jel[szelesseg, magassag];
|
||||
utolso = new Jel[szelesseg, magassag];
|
||||
}
|
||||
|
||||
public Kepernyo() : this(Console.WindowWidth, Console.WindowHeight)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
readonly List<Func<string>> HUDmegjelenitok = new List<Func<string>>();
|
||||
|
||||
public void HUDAdatFelvetele(Func<string> hudMegjelenito)
|
||||
{
|
||||
HUDmegjelenitok.Add(hudMegjelenito);
|
||||
}
|
||||
|
||||
readonly List<INezopont> nezopontok = new List<INezopont>();
|
||||
|
||||
public void NezopontFelvetele(INezopont nezopont)
|
||||
{
|
||||
nezopontok.Add(nezopont);
|
||||
}
|
||||
|
||||
public void NezopontEltavolitasa(INezopont nezopont)
|
||||
{
|
||||
nezopontok.Remove(nezopont);
|
||||
}
|
||||
|
||||
public void Kirajzolas()
|
||||
{
|
||||
PufferTorles();
|
||||
|
||||
int eltolasX = 0;
|
||||
foreach (INezopont nezopont in nezopontok)
|
||||
{
|
||||
KeretRajzolas(eltolasX, 0, nezopont.Meret, nezopont.Fejlec);
|
||||
ElemekRajzolasa(eltolasX, 0, nezopont);
|
||||
eltolasX += nezopont.Meret.Szelesseg + 2;
|
||||
}
|
||||
|
||||
eltolasX = 0;
|
||||
foreach (Func<string> hudMegjelenito in HUDmegjelenitok)
|
||||
{
|
||||
string adat = hudMegjelenito();
|
||||
for (int i = 0; i < adat.Length; i++)
|
||||
puffer[eltolasX + i, meret.Magassag - 1] = new Jel(adat[i], ConsoleColor.White);
|
||||
puffer[eltolasX + adat.Length, meret.Magassag - 1] = new Jel('|', ConsoleColor.Red);
|
||||
eltolasX += adat.Length + 1;
|
||||
}
|
||||
|
||||
PufferKirajzolas();
|
||||
}
|
||||
|
||||
readonly Jel ures = new Jel(' ', ConsoleColor.Black);
|
||||
|
||||
private void PufferTorles()
|
||||
{
|
||||
for (int i = 0; i < meret.Szelesseg; i++)
|
||||
for (int j = 0; j < meret.Magassag; j++)
|
||||
{
|
||||
puffer[i, j] = ures;
|
||||
}
|
||||
}
|
||||
|
||||
private void KeretRajzolas(int eltolasX, int eltolasY, Meret meret, string fejlec)
|
||||
{
|
||||
for (int i = 1; i <= meret.Szelesseg; i++)
|
||||
{
|
||||
puffer[eltolasX + i, eltolasY] = new Jel('\u2550', ConsoleColor.Gray);
|
||||
puffer[eltolasX + i, eltolasY + meret.Magassag + 1] = new Jel('\u2550', ConsoleColor.Gray);
|
||||
}
|
||||
|
||||
for (int i = 1; i <= meret.Magassag; i++)
|
||||
{
|
||||
puffer[eltolasX, eltolasY + i] = new Jel('\u2551', ConsoleColor.Gray);
|
||||
puffer[eltolasX + meret.Szelesseg + 1, eltolasY + i] = new Jel('\u2551', ConsoleColor.Gray);
|
||||
}
|
||||
|
||||
puffer[eltolasX, eltolasY] = new Jel('\u2554', ConsoleColor.Gray);
|
||||
puffer[eltolasX + meret.Szelesseg + 1, eltolasY] = new Jel('\u2557', ConsoleColor.Gray);
|
||||
puffer[eltolasX, eltolasY + meret.Magassag + 1] = new Jel('\u255a', ConsoleColor.Gray);
|
||||
puffer[eltolasX + meret.Szelesseg + 1, eltolasY + meret.Magassag + 1] = new Jel('\u255d', ConsoleColor.Gray);
|
||||
|
||||
for (int i = 0; i < fejlec.Length; i++)
|
||||
puffer[eltolasX + 2 + i, eltolasY] = new Jel(fejlec[i], ConsoleColor.Gray);
|
||||
}
|
||||
|
||||
private void ElemekRajzolasa(int eltolasX, int eltolasY, INezopont nezopont)
|
||||
{
|
||||
foreach (IMegjelenitheto elem in nezopont.MegjelenitendoElemek())
|
||||
{
|
||||
puffer[eltolasX + 1 + elem.Pozicio.X, eltolasY + 1 + elem.Pozicio.Y] = elem.Jel;
|
||||
}
|
||||
}
|
||||
|
||||
private void PufferKirajzolas()
|
||||
{
|
||||
for (int j = 0; j < meret.Magassag; j++)
|
||||
{
|
||||
for (int i = 0; i < meret.Szelesseg; i++)
|
||||
{
|
||||
if (utolso[i, j] != puffer[i, j])
|
||||
{
|
||||
Console.SetCursorPosition(i, j);
|
||||
Console.ForegroundColor = puffer[i, j].Szin;
|
||||
Console.Write(puffer[i, j].Karakter);
|
||||
utolso[i, j] = puffer[i, j];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Orajel(int ido)
|
||||
{
|
||||
Kirajzolas();
|
||||
}
|
||||
}
|
||||
}
|
||||
54
Engine/OrajelGenerator.cs
Normal file
54
Engine/OrajelGenerator.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
namespace OE.ALGA.Engine
|
||||
{
|
||||
public interface IOrajelFogado
|
||||
{
|
||||
void Orajel(int ido);
|
||||
}
|
||||
|
||||
public class OrajelGenerator
|
||||
{
|
||||
Timer? timer;
|
||||
|
||||
public int Ido { get; private set; } = 0;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
timer = new Timer(FoCiklus, null, 0, 100);
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
timer?.Change(Timeout.Infinite, Timeout.Infinite);
|
||||
}
|
||||
|
||||
bool foglalt = false;
|
||||
private void FoCiklus(object? state)
|
||||
{
|
||||
if (!foglalt) // ha nem végzett az előző ciklus, akkor kihagyja a következőt
|
||||
{
|
||||
foglalt = true;
|
||||
Ido++;
|
||||
|
||||
List<IOrajelFogado> aktivOrajelFogadok = new List<IOrajelFogado>(orajelFogadok); // azért kell a másolat, mert valamelyik órajel kezelés módosíthatja az orajelFogadok listát
|
||||
foreach (IOrajelFogado fogado in aktivOrajelFogadok)
|
||||
{
|
||||
fogado.Orajel(Ido);
|
||||
}
|
||||
|
||||
foglalt = false;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly List<IOrajelFogado> orajelFogadok = new List<IOrajelFogado>();
|
||||
|
||||
public void OrajelFogadoFelvetele(IOrajelFogado fogado)
|
||||
{
|
||||
orajelFogadok.Add(fogado);
|
||||
}
|
||||
|
||||
public void OrajelFogadoEltavolitasa(IOrajelFogado fogado)
|
||||
{
|
||||
orajelFogadok.Remove(fogado);
|
||||
}
|
||||
}
|
||||
}
|
||||
43
Engine/Parameterek.cs
Normal file
43
Engine/Parameterek.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
namespace OE.ALGA.Engine
|
||||
{
|
||||
public static class Param
|
||||
{
|
||||
public const int TERKEP_SZELESSEG = 15;
|
||||
public const int TERKEP_MAGASSAG = 19;
|
||||
|
||||
public const char NYIL_FEL = '\u02c4';
|
||||
public const char NYIL_BAL = '\u02c2';
|
||||
public const char NYIL_LE = '\u02c5';
|
||||
public const char NYIL_JOBB = '\u02c3';
|
||||
public const char HALOTT = '+';
|
||||
|
||||
public const char FAL = '\u2593';
|
||||
public const char LOVEDEK_VIZSZINTES = '-';
|
||||
public const char LOVEDEK_FUGGOLEGES = '-';
|
||||
|
||||
public const int JATEKVEGE_IDO = 500;
|
||||
public const int HIRTELENHALAL_KEZDO_IDO = 100;
|
||||
public const int HIRTELENHALAL_FOKOZAS_IDO = 10;
|
||||
public const int HIRTELENHALAL_BUNTETES = 1;
|
||||
|
||||
public const int LOVEDEK_MAX_SEBZES = 10;
|
||||
|
||||
public const int JATEKOS_LATOTAVOLSAG = 2;
|
||||
public const int JATEKOS_MEMORIAMERET = 30;
|
||||
|
||||
public const int KINCSEK_SZAMA = 5;
|
||||
public const int KINCSEK_MAX_MERETE = 8;
|
||||
public const int HATIZSAK_MAX_MERETE = 10;
|
||||
|
||||
public const double GEP_VISSZARAK_ESELY = 0.1;
|
||||
|
||||
// optimalizalas
|
||||
public const double MIN_KINCS_TAVOLSAG = 4;
|
||||
|
||||
// kupac
|
||||
public const int LOVEDEKEK_SZAMA = 10;
|
||||
|
||||
// szélességi bejárás
|
||||
public const int TERKEP_BEJARAS_LEPESKORLAT = 30;
|
||||
}
|
||||
}
|
||||
277
Engine/Terkep.cs
Normal file
277
Engine/Terkep.cs
Normal file
@@ -0,0 +1,277 @@
|
||||
namespace OE.ALGA.Engine
|
||||
{
|
||||
public class Terkep : INezopont
|
||||
{
|
||||
readonly Random rnd = new Random();
|
||||
|
||||
public string Fejlec { get { return "Térkép"; } }
|
||||
|
||||
readonly Meret meret;
|
||||
public Meret Meret { get { return meret; } }
|
||||
|
||||
readonly List<TerkepElem> elemek = new List<TerkepElem>();
|
||||
|
||||
public void Felvesz(TerkepElem elem)
|
||||
{
|
||||
elemek.Add(elem);
|
||||
}
|
||||
|
||||
public void Eltavolit(TerkepElem elem)
|
||||
{
|
||||
elemek.Remove(elem);
|
||||
}
|
||||
|
||||
public bool Mozgat(TerkepElem elem, Irany irany)
|
||||
{
|
||||
Pozicio ujPoz = elem.Pozicio + irany;
|
||||
|
||||
bool odaLephet = true;
|
||||
|
||||
foreach (TerkepElem ottvan in AdottHelyen(ujPoz))
|
||||
{
|
||||
ottvan.Utkozes?.Invoke(elem);
|
||||
elem.Utkozes?.Invoke(ottvan);
|
||||
}
|
||||
|
||||
elem.Athelyez(ujPoz);
|
||||
|
||||
return odaLephet;
|
||||
}
|
||||
|
||||
public List<TerkepElem> AdottHelyen(Pozicio pozicio)
|
||||
{
|
||||
return elemek.FindAll(x => x.Pozicio == pozicio);
|
||||
}
|
||||
|
||||
public TerkepElem[] Kornyezet(Pozicio pozicio, int tavolsag)
|
||||
{
|
||||
List<TerkepElem> elemek = new List<TerkepElem>();
|
||||
for (int x = -tavolsag; x <= tavolsag; x++)
|
||||
for (int y = -tavolsag; y <= tavolsag; y++)
|
||||
elemek.AddRange(AdottHelyen(new Pozicio(pozicio.X + x, pozicio.Y + y)));
|
||||
return elemek.ToArray();
|
||||
}
|
||||
|
||||
public IMegjelenitheto[] MegjelenitendoElemek()
|
||||
{
|
||||
return elemek.ToArray();
|
||||
}
|
||||
|
||||
|
||||
public Terkep(int szelesseg, int magassag)
|
||||
{
|
||||
this.meret = new Meret(szelesseg, magassag);
|
||||
}
|
||||
|
||||
public void LabirintusGeneralas()
|
||||
{
|
||||
List<Fal> falak = new List<Fal>();
|
||||
List<Pozicio> bovitheto = new List<Pozicio>();
|
||||
|
||||
// korbe falak letrehozasa
|
||||
for (int x = 0; x < meret.Szelesseg; x++)
|
||||
{
|
||||
falak.Add(new Fal(this, new Pozicio(x, 0)));
|
||||
falak.Add(new Fal(this, new Pozicio(x, meret.Magassag - 1)));
|
||||
}
|
||||
for (int y = 0; y < meret.Magassag; y++)
|
||||
{
|
||||
falak.Add(new Fal(this, new Pozicio(0, y)));
|
||||
falak.Add(new Fal(this, new Pozicio(meret.Szelesseg - 1, y)));
|
||||
}
|
||||
falak.Add(new Fal(this, new Pozicio(1, 2)));
|
||||
|
||||
// belso szerkezet letrehozasa
|
||||
Pozicio kezdoPozicio = new Pozicio(2, 2);
|
||||
falak.Add(new Fal(this, kezdoPozicio));
|
||||
bovitheto.Add(kezdoPozicio);
|
||||
|
||||
int falProba;
|
||||
do
|
||||
{
|
||||
int falRnd = rnd.Next(bovitheto.Count); // melyik falnal probaljon eloszor tovabb boviteni
|
||||
falProba = 0; // az elso fal valasztas random, de utana szisztematikusan tovabbnezi a mogotte levoket
|
||||
bool ok = false;
|
||||
while (falProba < bovitheto.Count && !ok) // ha nem nezte meg at az osszes falat es nem sikerult boviteni
|
||||
{
|
||||
Pozicio vizsgalt = bovitheto[(falRnd + falProba) % bovitheto.Count]; // ezt a falat vizsgaljuk
|
||||
|
||||
int iranyRnd = rnd.Next(4); // ebbe az iranyba probal eloszor boviteni
|
||||
int iranyProba = 0; // az elso irany valasztas random, de utana szisztematikusan nezi a tobbi iranyt
|
||||
while (iranyProba < 4 && !ok) // meg nem nezte azt az osszes iranyt es nem sikerult boviteni
|
||||
{
|
||||
Irany irany = Irany.FoIranyok[(iranyRnd + iranyProba) % 4];
|
||||
Pozicio uj = vizsgalt + irany * 2;
|
||||
if (TerkepenBelulVan(uj) && !falak.Exists(x => x.Pozicio == uj)) // ha itt nincs meg fal
|
||||
{
|
||||
falak.Add(new Fal(this, uj)); // uj 2. tavolsagra levo fal letrehozasa, ebbol indulhat bovites is
|
||||
falak.Add(new Fal(this, vizsgalt + irany)); // uj koztes fal letrehozasa
|
||||
bovitheto.Add(uj);
|
||||
ok = true; // sikerult boviteni
|
||||
}
|
||||
iranyProba++; // uj iranyt probalunk
|
||||
}
|
||||
falProba++; // uj falat probalunk
|
||||
}
|
||||
} while (falProba < bovitheto.Count); // minden fal minden iranyt vegigneztunk es nincs bovites
|
||||
}
|
||||
|
||||
public bool TerkepenBelulVan(Pozicio pozicio)
|
||||
{
|
||||
return pozicio.X > 0 && pozicio.X < meret.Szelesseg - 1 && pozicio.Y > 0 && pozicio.Y < meret.Magassag - 1;
|
||||
}
|
||||
|
||||
public bool NincsFal(Pozicio pozicio)
|
||||
{
|
||||
return !AdottHelyen(pozicio).Exists(x => x is Fal);
|
||||
}
|
||||
}
|
||||
|
||||
abstract public class TerkepElem : IMegjelenitheto, IComparable
|
||||
{
|
||||
readonly private Terkep terkep;
|
||||
public Terkep Terkep { get { return terkep; } }
|
||||
|
||||
protected Pozicio pozicio;
|
||||
public Pozicio Pozicio { get { return pozicio; } }
|
||||
|
||||
abstract public Jel Jel { get; }
|
||||
|
||||
public Action<TerkepElem>? Utkozes { get; set; }
|
||||
|
||||
public virtual void Athelyez(Pozicio ujPozicio)
|
||||
{
|
||||
if (terkep.TerkepenBelulVan(ujPozicio))
|
||||
pozicio = ujPozicio;
|
||||
}
|
||||
|
||||
protected TerkepElem(Terkep terkep, Pozicio pozicio)
|
||||
{
|
||||
this.terkep = terkep;
|
||||
terkep.Felvesz(this);
|
||||
this.pozicio = pozicio;
|
||||
}
|
||||
|
||||
public virtual void Megszunik()
|
||||
{
|
||||
terkep.Eltavolit(this);
|
||||
}
|
||||
|
||||
static int idSzamlalo = 0;
|
||||
readonly int id = idSzamlalo++;
|
||||
|
||||
public int CompareTo(object? obj)
|
||||
{
|
||||
if (obj is TerkepElem o)
|
||||
return id.CompareTo(o.id);
|
||||
else
|
||||
throw new ArgumentException("Hibás összehasonlítás");
|
||||
}
|
||||
}
|
||||
|
||||
public class FixTerkepElem : TerkepElem
|
||||
{
|
||||
protected Jel jel;
|
||||
|
||||
public override Jel Jel
|
||||
{
|
||||
get { return jel; }
|
||||
}
|
||||
|
||||
protected FixTerkepElem(Terkep terkep, Pozicio pozicio, Jel jel) : base(terkep, pozicio)
|
||||
{
|
||||
this.pozicio = pozicio;
|
||||
this.jel = jel;
|
||||
}
|
||||
}
|
||||
|
||||
public class Fal : FixTerkepElem
|
||||
{
|
||||
static readonly Jel FAL_KARAKTER = new Jel(Param.FAL, ConsoleColor.DarkRed);
|
||||
|
||||
public Fal(Terkep terkep, Pozicio pozicio) : base(terkep, pozicio, FAL_KARAKTER)
|
||||
{
|
||||
Utkozes = elem => throw new NemLehetIdeLepniKivetel(this, elem);
|
||||
}
|
||||
}
|
||||
|
||||
public class Kincs : TerkepElem
|
||||
{
|
||||
readonly ConsoleColor[] szinek = new ConsoleColor[] { ConsoleColor.DarkRed, ConsoleColor.Red, ConsoleColor.DarkYellow, ConsoleColor.Yellow,
|
||||
ConsoleColor.DarkYellow, ConsoleColor.Red };
|
||||
|
||||
public char Azonosito { get; private set; }
|
||||
public float Ertek { get; private set; }
|
||||
public int Suly { get; private set; }
|
||||
|
||||
int villogasSzamlalo = 0;
|
||||
public override Jel Jel
|
||||
{
|
||||
get { return new Jel(Azonosito, szinek[villogasSzamlalo++ % szinek.Length]); }
|
||||
}
|
||||
|
||||
public Kincs(Terkep terkep, Pozicio pozicio, char azonosito, float ertek, int suly) : base(terkep, pozicio)
|
||||
{
|
||||
this.Azonosito = azonosito;
|
||||
this.Ertek = ertek;
|
||||
this.Suly = suly;
|
||||
}
|
||||
}
|
||||
|
||||
public class KincsKezelo : INezopont
|
||||
{
|
||||
readonly protected Kincs[] kincsek = new Kincs[Param.KINCSEK_SZAMA];
|
||||
readonly protected Terkep terkep;
|
||||
|
||||
public KincsKezelo(Terkep terkep)
|
||||
{
|
||||
this.terkep = terkep;
|
||||
megjelenithetoKincsAdatok = Array.Empty<FixJel>();
|
||||
}
|
||||
|
||||
public void KincsekGeneralasa()
|
||||
{
|
||||
Random rnd = new Random();
|
||||
for (int i = 0; i < Param.KINCSEK_SZAMA; i++)
|
||||
kincsek[i] = new Kincs(terkep, new Pozicio(0, 0), (char)(i + 97), rnd.Next(1, 100 / Param.KINCSEK_SZAMA), rnd.Next(1, Param.KINCSEK_MAX_MERETE));
|
||||
KincsekElhelyezese();
|
||||
MegjelenitesRendereles();
|
||||
}
|
||||
|
||||
protected virtual void KincsekElhelyezese()
|
||||
{
|
||||
Random rnd = new Random();
|
||||
int i = 0;
|
||||
while (i < Param.KINCSEK_SZAMA)
|
||||
{
|
||||
Pozicio rndPozicio = new Pozicio(rnd.Next(terkep.Meret.Szelesseg), rnd.Next(terkep.Meret.Magassag));
|
||||
if (terkep.AdottHelyen(rndPozicio).Count == 0)
|
||||
{
|
||||
kincsek[i].Athelyez(rndPozicio);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IMegjelenitheto[] megjelenithetoKincsAdatok;
|
||||
private void MegjelenitesRendereles()
|
||||
{
|
||||
List<FixJel> elemek = new List<FixJel>();
|
||||
for (int i = 0; i < kincsek.Length; i++)
|
||||
{
|
||||
string szoveg = kincsek[i].Jel.Karakter + " " + kincsek[i].Ertek + "/" + kincsek[i].Suly;
|
||||
elemek.AddRange(FixJel.SzovegbolJelsor(szoveg, new Pozicio(1, i), ConsoleColor.White));
|
||||
}
|
||||
megjelenithetoKincsAdatok = elemek.ToArray();
|
||||
}
|
||||
|
||||
public string Fejlec => "Kincsek";
|
||||
|
||||
public Meret Meret => new Meret(9, Param.KINCSEK_SZAMA);
|
||||
|
||||
public IMegjelenitheto[] MegjelenitendoElemek()
|
||||
{
|
||||
return megjelenithetoKincsAdatok;
|
||||
}
|
||||
}
|
||||
}
|
||||
9
Sandbox/Program.cs
Normal file
9
Sandbox/Program.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace OE.ALGA.Sandbox
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Sandbox/Sandbox.csproj
Normal file
10
Sandbox/Sandbox.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
257
Tesztek/01_ImperativParadigmaTesztek.cs
Normal file
257
Tesztek/01_ImperativParadigmaTesztek.cs
Normal file
@@ -0,0 +1,257 @@
|
||||
// using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
// using OE.ALGA.Paradigmak;
|
||||
//
|
||||
// namespace OE.ALGA.Tesztek
|
||||
// {
|
||||
// class TesztFeladat : IVegrehajthato //F1.
|
||||
// {
|
||||
// public string Azonosito { get; set; }
|
||||
//
|
||||
// public bool Vegrehajtott { get; set; }
|
||||
//
|
||||
// public void Vegrehajtas()
|
||||
// {
|
||||
// Vegrehajtott = true;
|
||||
// }
|
||||
//
|
||||
// public TesztFeladat(string nev)
|
||||
// {
|
||||
// this.Azonosito = nev;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [TestClass()]
|
||||
// public class FeladatTaroloTeszt
|
||||
// {
|
||||
// [TestMethod()]
|
||||
// public void FelveszTeszt() //F2.(c)
|
||||
// {
|
||||
// FeladatTarolo<TesztFeladat> tarolo = new FeladatTarolo<TesztFeladat>(5);
|
||||
// TesztFeladat a = new TesztFeladat("a");
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(a);
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// [ExpectedException(typeof(TaroloMegteltKivetel))]
|
||||
// public void TulsokatFelveszTeszt() //F2.(c)
|
||||
// {
|
||||
// FeladatTarolo<TesztFeladat> tarolo = new FeladatTarolo<TesztFeladat>(5);
|
||||
// TesztFeladat a = new TesztFeladat("a");
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(a);
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void VegrehajtasTeszt() //F2.(d)
|
||||
// {
|
||||
// FeladatTarolo<TesztFeladat> tarolo = new FeladatTarolo<TesztFeladat>(10);
|
||||
// TesztFeladat a = new TesztFeladat("a");
|
||||
// TesztFeladat b = new TesztFeladat("b");
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(b);
|
||||
// Assert.IsFalse(a.Vegrehajtott);
|
||||
// Assert.IsFalse(b.Vegrehajtott);
|
||||
// tarolo.MindentVegrehajt();
|
||||
// Assert.IsTrue(a.Vegrehajtott);
|
||||
// Assert.IsTrue(b.Vegrehajtott);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class TesztFuggoFeladat : TesztFeladat, IFuggo //F3.
|
||||
// {
|
||||
// public bool Vegrehajthato { get; set; }
|
||||
//
|
||||
// public virtual bool FuggosegTeljesul
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// return Vegrehajthato;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public TesztFuggoFeladat(string nev) : base(nev)
|
||||
// {
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [TestClass()]
|
||||
// public class FuggoFeladatTaroloTeszt //F4.
|
||||
// {
|
||||
// [TestMethod()]
|
||||
// public void FelveszTeszt()
|
||||
// {
|
||||
// FuggoFeladatTarolo<TesztFuggoFeladat> tarolo = new FuggoFeladatTarolo<TesztFuggoFeladat>(5);
|
||||
// TesztFuggoFeladat a = new TesztFuggoFeladat("a");
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(a);
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// [ExpectedException(typeof(TaroloMegteltKivetel))]
|
||||
// public void TulsokatFelveszTeszt()
|
||||
// {
|
||||
// FuggoFeladatTarolo<TesztFuggoFeladat> tarolo = new FuggoFeladatTarolo<TesztFuggoFeladat>(5);
|
||||
// TesztFuggoFeladat a = new TesztFuggoFeladat("a");
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(a);
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void VegrehajtasAmikorNemVegrehajthatokTeszt()
|
||||
// {
|
||||
// FuggoFeladatTarolo<TesztFuggoFeladat> tarolo = new FuggoFeladatTarolo<TesztFuggoFeladat>(5);
|
||||
// TesztFuggoFeladat a = new TesztFuggoFeladat("a");
|
||||
// TesztFuggoFeladat b = new TesztFuggoFeladat("b");
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(b);
|
||||
// Assert.IsFalse(a.Vegrehajtott);
|
||||
// Assert.IsFalse(b.Vegrehajtott);
|
||||
// tarolo.MindentVegrehajt();
|
||||
// Assert.IsFalse(a.Vegrehajtott);
|
||||
// Assert.IsFalse(b.Vegrehajtott);
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void VegrehajtasAmikorVegrehajthatokTeszt()
|
||||
// {
|
||||
// FuggoFeladatTarolo<TesztFuggoFeladat> tarolo = new FuggoFeladatTarolo<TesztFuggoFeladat>(5);
|
||||
// TesztFuggoFeladat a = new TesztFuggoFeladat("a") { Vegrehajthato = true };
|
||||
// TesztFuggoFeladat b = new TesztFuggoFeladat("b");
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(b);
|
||||
// Assert.IsFalse(a.Vegrehajtott);
|
||||
// Assert.IsFalse(b.Vegrehajtott);
|
||||
// tarolo.MindentVegrehajt();
|
||||
// Assert.IsTrue(a.Vegrehajtott);
|
||||
// Assert.IsFalse(b.Vegrehajtott);
|
||||
// b.Vegrehajthato = true;
|
||||
// tarolo.MindentVegrehajt();
|
||||
// Assert.IsTrue(a.Vegrehajtott);
|
||||
// Assert.IsTrue(b.Vegrehajtott);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class TesztElokovetelmenytolFuggoFeladat : TesztFuggoFeladat //F4.
|
||||
// {
|
||||
// readonly TesztFeladat elokovetelmeny;
|
||||
//
|
||||
// public TesztElokovetelmenytolFuggoFeladat(string nev, TesztFeladat elokovetelmeny) : base(nev)
|
||||
// {
|
||||
// this.elokovetelmeny = elokovetelmeny;
|
||||
// }
|
||||
//
|
||||
// public override bool FuggosegTeljesul
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// return base.FuggosegTeljesul && elokovetelmeny.Vegrehajtott;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [TestClass()]
|
||||
// public class FuggoFeladatTaroloElokovetelmenyekkelTeszt //F4.
|
||||
// {
|
||||
// [TestMethod()]
|
||||
// public void ElokovetelmenyesTeszt()
|
||||
// {
|
||||
// FuggoFeladatTarolo<TesztFuggoFeladat> tarolo = new FuggoFeladatTarolo<TesztFuggoFeladat>(5);
|
||||
// TesztFuggoFeladat a = new TesztFuggoFeladat("a");
|
||||
// TesztElokovetelmenytolFuggoFeladat b = new TesztElokovetelmenytolFuggoFeladat("b", a) { Vegrehajthato = true };
|
||||
// // a->b
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(b);
|
||||
// tarolo.MindentVegrehajt();
|
||||
// Assert.IsFalse(a.Vegrehajtott);
|
||||
// Assert.IsFalse(b.Vegrehajtott);
|
||||
// a.Vegrehajthato = true;
|
||||
// tarolo.MindentVegrehajt();
|
||||
// Assert.IsTrue(a.Vegrehajtott);
|
||||
// Assert.IsTrue(b.Vegrehajtott);
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void TobbKorosElokovetelmenyesTeszt()
|
||||
// {
|
||||
// FuggoFeladatTarolo<TesztFuggoFeladat> tarolo = new FuggoFeladatTarolo<TesztFuggoFeladat>(5);
|
||||
// TesztFuggoFeladat a = new TesztFuggoFeladat("a") { Vegrehajthato = true };
|
||||
// TesztElokovetelmenytolFuggoFeladat b = new TesztElokovetelmenytolFuggoFeladat("b", a) { Vegrehajthato = true };
|
||||
// TesztElokovetelmenytolFuggoFeladat c = new TesztElokovetelmenytolFuggoFeladat("c", a) { Vegrehajthato = true };
|
||||
// TesztElokovetelmenytolFuggoFeladat d = new TesztElokovetelmenytolFuggoFeladat("d", b) { Vegrehajthato = true };
|
||||
// // a->b->d
|
||||
// // ->c
|
||||
// tarolo.Felvesz(d);
|
||||
// tarolo.Felvesz(c);
|
||||
// tarolo.Felvesz(b);
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.MindentVegrehajt();
|
||||
// Assert.IsTrue(a.Vegrehajtott);
|
||||
// Assert.IsFalse(b.Vegrehajtott); // a 'b' kiértékelése az 'a' végrehajtása előtt volt, ezért az még nem lett feldolgozva
|
||||
// Assert.IsFalse(c.Vegrehajtott); // a 'c' kiértékelése az 'a' végrehajtása előtt volt, ezért az még nem lett feldolgozva
|
||||
// Assert.IsFalse(d.Vegrehajtott);
|
||||
// tarolo.MindentVegrehajt();
|
||||
// Assert.IsTrue(a.Vegrehajtott);
|
||||
// Assert.IsTrue(b.Vegrehajtott);
|
||||
// Assert.IsTrue(c.Vegrehajtott);
|
||||
// Assert.IsFalse(d.Vegrehajtott); // a 'd' kiértékelése a 'b' végrehajtása előtt volt, ezért az még nem lett feldolgozva
|
||||
// tarolo.MindentVegrehajt();
|
||||
// Assert.IsTrue(a.Vegrehajtott);
|
||||
// Assert.IsTrue(b.Vegrehajtott);
|
||||
// Assert.IsTrue(c.Vegrehajtott);
|
||||
// Assert.IsTrue(d.Vegrehajtott);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class BejarasokTeszt //F5.
|
||||
// {
|
||||
// [TestMethod()]
|
||||
// public void FeladatTaroloBejaroTeszt()
|
||||
// {
|
||||
// FeladatTarolo<TesztFeladat> tarolo = new FeladatTarolo<TesztFeladat>(10);
|
||||
// TesztFeladat a = new TesztFeladat("a");
|
||||
// TesztFeladat b = new TesztFeladat("b");
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(b);
|
||||
// string nevek = "";
|
||||
// foreach (TesztFeladat u in tarolo)
|
||||
// {
|
||||
// nevek += u.Azonosito;
|
||||
// }
|
||||
// Assert.AreEqual("ab", nevek);
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void FuggoFeladatTaroloBejaroTeszt()
|
||||
// {
|
||||
// FuggoFeladatTarolo<TesztFuggoFeladat> tarolo = new FuggoFeladatTarolo<TesztFuggoFeladat>(5);
|
||||
// TesztFuggoFeladat a = new TesztFuggoFeladat("a");
|
||||
// TesztFuggoFeladat b = new TesztFuggoFeladat("b") { Vegrehajthato = true };
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(b);
|
||||
// tarolo.MindentVegrehajt();
|
||||
// string nevek = "";
|
||||
// foreach (TesztFuggoFeladat u in tarolo)
|
||||
// {
|
||||
// if (u.Vegrehajtott)
|
||||
// nevek += u.Azonosito;
|
||||
// }
|
||||
// Assert.AreEqual("b", nevek);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
136
Tesztek/02_FunkcionalisParadigmaTesztek.cs
Normal file
136
Tesztek/02_FunkcionalisParadigmaTesztek.cs
Normal file
@@ -0,0 +1,136 @@
|
||||
// using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
// using OE.ALGA.Paradigmak;
|
||||
//
|
||||
// namespace OE.ALGA.Tesztek
|
||||
// {
|
||||
// [TestClass()]
|
||||
// public class FeltetelesFeladatTaroloTesztek
|
||||
// {
|
||||
// [TestMethod()]
|
||||
// public void FelveszTeszt() //F1.(a)
|
||||
// {
|
||||
// FeltetelesFeladatTarolo<TesztFeladat> tarolo = new FeltetelesFeladatTarolo<TesztFeladat>(10);
|
||||
// TesztFeladat a = new TesztFeladat("a");
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(a);
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// [ExpectedException(typeof(TaroloMegteltKivetel))]
|
||||
// public void TulsokatFelveszTeszt() //F1.(a)
|
||||
// {
|
||||
// FeltetelesFeladatTarolo<TesztFeladat> tarolo = new FeltetelesFeladatTarolo<TesztFeladat>(5);
|
||||
// TesztFeladat a = new TesztFeladat("a");
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(a);
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void MindenVegrehajtasTeszt() //F1.(a)
|
||||
// {
|
||||
// FeltetelesFeladatTarolo<TesztFeladat> tarolo = new FeltetelesFeladatTarolo<TesztFeladat>(10);
|
||||
// TesztFeladat a = new TesztFeladat("a");
|
||||
// TesztFeladat b = new TesztFeladat("b");
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(b);
|
||||
// Assert.IsFalse(a.Vegrehajtott);
|
||||
// Assert.IsFalse(b.Vegrehajtott);
|
||||
// tarolo.MindentVegrehajt();
|
||||
// Assert.IsTrue(a.Vegrehajtott);
|
||||
// Assert.IsTrue(b.Vegrehajtott);
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void BejaroTeszt() //F1.(a)
|
||||
// {
|
||||
// FeltetelesFeladatTarolo<TesztFeladat> tarolo = new FeltetelesFeladatTarolo<TesztFeladat>(10);
|
||||
// TesztFeladat a = new TesztFeladat("a");
|
||||
// TesztFeladat b = new TesztFeladat("b");
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(b);
|
||||
// string nevek = "";
|
||||
// foreach (TesztFeladat u in tarolo)
|
||||
// {
|
||||
// nevek += u.Azonosito;
|
||||
// }
|
||||
// Assert.AreEqual("ab", nevek);
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void FeltetelesVegrehajtasTeszt() //F1.(b)
|
||||
// {
|
||||
// FeltetelesFeladatTarolo<TesztFeladat> tarolo = new FeltetelesFeladatTarolo<TesztFeladat>(10);
|
||||
// TesztFeladat a1 = new TesztFeladat("a1");
|
||||
// TesztFeladat b1 = new TesztFeladat("b1");
|
||||
// TesztFeladat a2 = new TesztFeladat("a2");
|
||||
// tarolo.Felvesz(a1);
|
||||
// tarolo.Felvesz(b1);
|
||||
// tarolo.Felvesz(a2);
|
||||
// Assert.IsFalse(a1.Vegrehajtott);
|
||||
// Assert.IsFalse(b1.Vegrehajtott);
|
||||
// Assert.IsFalse(a2.Vegrehajtott);
|
||||
// tarolo.FeltetelesVegrehajtas(x => x.Azonosito[0] == 'a'); // csak 'a' kezdetűek végrehajtása
|
||||
// Assert.IsTrue(a1.Vegrehajtott);
|
||||
// Assert.IsFalse(b1.Vegrehajtott);
|
||||
// Assert.IsTrue(a2.Vegrehajtott);
|
||||
// tarolo.FeltetelesVegrehajtas(x => x.Azonosito[0] == 'b'); // csak 'b' kezdetűek végrehajtása
|
||||
// Assert.IsTrue(a1.Vegrehajtott);
|
||||
// Assert.IsTrue(b1.Vegrehajtott);
|
||||
// Assert.IsTrue(a2.Vegrehajtott);
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void FeltetelesFuggosegesVegrehajtasTeszt() //F1.(b)
|
||||
// {
|
||||
// FeltetelesFeladatTarolo<TesztFuggoFeladat> tarolo = new FeltetelesFeladatTarolo<TesztFuggoFeladat>(10);
|
||||
// TesztFuggoFeladat a1 = new TesztFuggoFeladat("a1") { Vegrehajthato = true };
|
||||
// TesztFuggoFeladat b1 = new TesztFuggoFeladat("b1") { Vegrehajthato = true };
|
||||
// TesztFuggoFeladat a2 = new TesztFuggoFeladat("a2") { Vegrehajthato = false };
|
||||
// tarolo.Felvesz(a1);
|
||||
// tarolo.Felvesz(b1);
|
||||
// tarolo.Felvesz(a2);
|
||||
// Assert.IsFalse(a1.Vegrehajtott);
|
||||
// Assert.IsFalse(b1.Vegrehajtott);
|
||||
// Assert.IsFalse(a2.Vegrehajtott);
|
||||
// tarolo.FeltetelesVegrehajtas(x => x.Azonosito[0] == 'a' && x.FuggosegTeljesul); // csak 'a' kezdetű és végrehajtható
|
||||
// Assert.IsTrue(a1.Vegrehajtott);
|
||||
// Assert.IsFalse(b1.Vegrehajtott);
|
||||
// Assert.IsFalse(a2.Vegrehajtott);
|
||||
// tarolo.FeltetelesVegrehajtas(x => x.Azonosito[0] == 'b' && x.FuggosegTeljesul); // csak 'b' kezdetű és végrehajtható
|
||||
// Assert.IsTrue(a1.Vegrehajtott);
|
||||
// Assert.IsTrue(b1.Vegrehajtott);
|
||||
// Assert.IsFalse(a2.Vegrehajtott);
|
||||
// a2.Vegrehajthato = true;
|
||||
// tarolo.FeltetelesVegrehajtas(x => x.Azonosito[0] == 'a' && x.FuggosegTeljesul); // csak 'a' kezdetű és végrehajtható
|
||||
// Assert.IsTrue(a1.Vegrehajtott);
|
||||
// Assert.IsTrue(b1.Vegrehajtott);
|
||||
// Assert.IsTrue(a2.Vegrehajtott);
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void FeltetelesBejaroTeszt() //F3.(b)
|
||||
// {
|
||||
// FeltetelesFeladatTarolo<TesztFuggoFeladat> tarolo = new FeltetelesFeladatTarolo<TesztFuggoFeladat>(10);
|
||||
// tarolo.BejaroFeltetel = (x => x.FuggosegTeljesul);
|
||||
// TesztFuggoFeladat a = new TesztFuggoFeladat("a") { Vegrehajthato = true };
|
||||
// TesztFuggoFeladat b = new TesztFuggoFeladat("b") { Vegrehajthato = false };
|
||||
// TesztFuggoFeladat c = new TesztFuggoFeladat("c") { Vegrehajthato = true };
|
||||
// tarolo.Felvesz(a);
|
||||
// tarolo.Felvesz(b);
|
||||
// tarolo.Felvesz(c);
|
||||
// string nevek = "";
|
||||
// foreach (TesztFeladat u in tarolo)
|
||||
// {
|
||||
// nevek += u.Azonosito;
|
||||
// }
|
||||
// Assert.AreEqual("ac", nevek);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
263
Tesztek/03_TombImplementacioTesztek.cs
Normal file
263
Tesztek/03_TombImplementacioTesztek.cs
Normal file
@@ -0,0 +1,263 @@
|
||||
// using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
// using OE.ALGA.Adatszerkezetek;
|
||||
//
|
||||
// namespace OE.ALGA.Tesztek
|
||||
// {
|
||||
// [TestClass()]
|
||||
// public class TombVeremTesztek
|
||||
// {
|
||||
// [TestMethod()]
|
||||
// public void MindenJolMukodik() //F1.
|
||||
// {
|
||||
// Verem<int> v = new TombVerem<int>(3);
|
||||
// v.Verembe(1);
|
||||
// v.Verembe(3);
|
||||
// v.Verembe(2);
|
||||
// Assert.AreEqual(2, v.Verembol());
|
||||
// v.Verembe(4);
|
||||
// Assert.AreEqual(4, v.Verembol());
|
||||
// Assert.AreEqual(3, v.Verembol());
|
||||
// Assert.AreEqual(1, v.Verembol());
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// [ExpectedException(typeof(NincsHelyKivetel))]
|
||||
// public void TulSokElem() //F1.
|
||||
// {
|
||||
// Verem<int> v = new TombVerem<int>(3);
|
||||
// v.Verembe(1);
|
||||
// v.Verembe(3);
|
||||
// v.Verembe(2);
|
||||
// v.Verembe(4);
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// [ExpectedException(typeof(NincsElemKivetel))]
|
||||
// public void TulKevesElem() //F1.
|
||||
// {
|
||||
// Verem<int> v = new TombVerem<int>(3);
|
||||
// v.Verembe(1);
|
||||
// v.Verembe(3);
|
||||
// v.Verembe(2);
|
||||
// v.Verembol();
|
||||
// v.Verembol();
|
||||
// v.Verembol();
|
||||
// v.Verembol();
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void Felso() //F1.
|
||||
// {
|
||||
// Verem<int> v = new TombVerem<int>(3);
|
||||
// v.Verembe(1);
|
||||
// v.Verembe(3);
|
||||
// v.Verembe(2);
|
||||
// Assert.AreEqual(2, v.Felso());
|
||||
// Assert.AreEqual(2, v.Felso());
|
||||
// v.Verembol();
|
||||
// Assert.AreEqual(3, v.Felso());
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void Ures() //F1.
|
||||
// {
|
||||
// Verem<int> v = new TombVerem<int>(2);
|
||||
// Assert.IsTrue(v.Ures);
|
||||
// v.Verembe(1);
|
||||
// Assert.IsFalse(v.Ures);
|
||||
// v.Verembol();
|
||||
// Assert.IsTrue(v.Ures);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [TestClass()]
|
||||
// public class TombSorTesztek
|
||||
// {
|
||||
// [TestMethod()]
|
||||
// public void AlapMukodes() //F2.
|
||||
// {
|
||||
// Sor<int> s = new TombSor<int>(3);
|
||||
// s.Sorba(1);
|
||||
// s.Sorba(3);
|
||||
// s.Sorba(2);
|
||||
// Assert.AreEqual(1, s.Sorbol());
|
||||
// Assert.AreEqual(3, s.Sorbol());
|
||||
// Assert.AreEqual(2, s.Sorbol());
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void Korbeeres() //F2.
|
||||
// {
|
||||
// Sor<int> s = new TombSor<int>(3);
|
||||
// s.Sorba(1);
|
||||
// s.Sorba(3);
|
||||
// s.Sorba(2);
|
||||
// Assert.AreEqual(1, s.Sorbol());
|
||||
// Assert.AreEqual(3, s.Sorbol());
|
||||
// s.Sorba(4);
|
||||
// s.Sorba(5);
|
||||
// Assert.AreEqual(2, s.Sorbol());
|
||||
// Assert.AreEqual(4, s.Sorbol());
|
||||
// Assert.AreEqual(5, s.Sorbol());
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// [ExpectedException(typeof(NincsHelyKivetel))]
|
||||
// public void TulSokElem() //F2.
|
||||
// {
|
||||
// Sor<int> s = new TombSor<int>(3);
|
||||
// s.Sorba(1);
|
||||
// s.Sorba(3);
|
||||
// s.Sorba(2);
|
||||
// s.Sorba(4);
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// [ExpectedException(typeof(NincsElemKivetel))]
|
||||
// public void TulKevesElem() //F2.
|
||||
// {
|
||||
// Sor<int> s = new TombSor<int>(3);
|
||||
// s.Sorba(1);
|
||||
// s.Sorba(3);
|
||||
// s.Sorba(2);
|
||||
// s.Sorbol();
|
||||
// s.Sorbol();
|
||||
// s.Sorbol();
|
||||
// s.Sorbol();
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void Elso() //F2.
|
||||
// {
|
||||
// Sor<int> s = new TombSor<int>(3);
|
||||
// s.Sorba(1);
|
||||
// s.Sorba(3);
|
||||
// s.Sorba(2);
|
||||
// Assert.AreEqual(1, s.Elso());
|
||||
// Assert.AreEqual(1, s.Elso());
|
||||
// s.Sorbol();
|
||||
// Assert.AreEqual(3, s.Elso());
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void Ures() //F2.
|
||||
// {
|
||||
// Sor<int> s = new TombSor<int>(2);
|
||||
// Assert.IsTrue(s.Ures);
|
||||
// s.Sorba(1);
|
||||
// Assert.IsFalse(s.Ures);
|
||||
// s.Sorbol();
|
||||
// Assert.IsTrue(s.Ures);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [TestClass]
|
||||
// public class TombListaTesztek
|
||||
// {
|
||||
// [TestMethod]
|
||||
// public void Bejaras() //F3.
|
||||
// {
|
||||
// Lista<int> l = new TombLista<int>();
|
||||
// l.Hozzafuz(1);
|
||||
// l.Hozzafuz(3);
|
||||
// l.Hozzafuz(2);
|
||||
// string s = "";
|
||||
// l.Bejar(x => s += x.ToString());
|
||||
// Assert.AreEqual("132", s);
|
||||
// }
|
||||
//
|
||||
// [TestMethod]
|
||||
// public void HozzaFuzes() //F3.
|
||||
// {
|
||||
// Lista<int> l = new TombLista<int>();
|
||||
// l.Hozzafuz(1);
|
||||
// l.Hozzafuz(3);
|
||||
// l.Hozzafuz(2);
|
||||
// Assert.AreEqual(1, l.Kiolvas(0));
|
||||
// Assert.AreEqual(3, l.Kiolvas(1));
|
||||
// Assert.AreEqual(2, l.Kiolvas(2));
|
||||
// }
|
||||
//
|
||||
// [TestMethod]
|
||||
// public void Meret() //F3.
|
||||
// {
|
||||
// Lista<string> l = new TombLista<string>();
|
||||
// Assert.AreEqual(0, l.Elemszam);
|
||||
// l.Hozzafuz("A");
|
||||
// Assert.AreEqual(1, l.Elemszam);
|
||||
// l.Hozzafuz("B");
|
||||
// Assert.AreEqual(2, l.Elemszam);
|
||||
// }
|
||||
//
|
||||
// [TestMethod]
|
||||
// public void Novekedes() //F3.
|
||||
// {
|
||||
// Lista<int> l = new TombLista<int>();
|
||||
// for (int i = 0; i < 1000; i++)
|
||||
// l.Hozzafuz(i * i);
|
||||
// for (int i = 0; i < 1000; i++)
|
||||
// Assert.AreEqual(i * i, l.Kiolvas(i));
|
||||
// }
|
||||
//
|
||||
// [TestMethod]
|
||||
// public void Beszuras() //F3.
|
||||
// {
|
||||
// Lista<int> l = new TombLista<int>();
|
||||
// l.Beszur(0, 1);
|
||||
// l.Beszur(0, 2);
|
||||
// l.Beszur(1, 3);
|
||||
// l.Beszur(3, 4);
|
||||
// l.Beszur(2, 5);
|
||||
// Assert.AreEqual(2, l.Kiolvas(0));
|
||||
// Assert.AreEqual(3, l.Kiolvas(1));
|
||||
// Assert.AreEqual(5, l.Kiolvas(2));
|
||||
// Assert.AreEqual(1, l.Kiolvas(3));
|
||||
// Assert.AreEqual(4, l.Kiolvas(4));
|
||||
// }
|
||||
//
|
||||
// [TestMethod]
|
||||
// public void Torles() //F3.
|
||||
// {
|
||||
// Lista<int> l = new TombLista<int>();
|
||||
// l.Hozzafuz(1);
|
||||
// l.Hozzafuz(3);
|
||||
// l.Hozzafuz(2);
|
||||
// l.Hozzafuz(3);
|
||||
// l.Hozzafuz(4);
|
||||
// l.Torol(3);
|
||||
// Assert.AreEqual(1, l.Kiolvas(0));
|
||||
// Assert.AreEqual(2, l.Kiolvas(1));
|
||||
// Assert.AreEqual(4, l.Kiolvas(2));
|
||||
// }
|
||||
//
|
||||
// [TestMethod]
|
||||
// public void Modositas() //F3.
|
||||
// {
|
||||
// Lista<int> l = new TombLista<int>();
|
||||
// l.Hozzafuz(1);
|
||||
// l.Hozzafuz(3);
|
||||
// l.Hozzafuz(2);
|
||||
// l.Modosit(1, 5);
|
||||
// l.Modosit(0, 4);
|
||||
// Assert.AreEqual(4, l.Kiolvas(0));
|
||||
// Assert.AreEqual(5, l.Kiolvas(1));
|
||||
// Assert.AreEqual(2, l.Kiolvas(2));
|
||||
// }
|
||||
//
|
||||
// [TestMethod]
|
||||
// public void ForeachBejaras() //F4.
|
||||
// {
|
||||
// TombLista<string> l = new TombLista<string>();
|
||||
// l.Hozzafuz("a");
|
||||
// l.Hozzafuz("c");
|
||||
// l.Hozzafuz("d");
|
||||
// l.Hozzafuz("b");
|
||||
// string osszefuzo = "";
|
||||
// foreach(string x in l)
|
||||
// {
|
||||
// osszefuzo += x;
|
||||
// }
|
||||
// Assert.AreEqual("acdb", osszefuzo);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
225
Tesztek/04_EgyszeruLancTesztek.cs
Normal file
225
Tesztek/04_EgyszeruLancTesztek.cs
Normal file
@@ -0,0 +1,225 @@
|
||||
// using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
// using OE.ALGA.Adatszerkezetek;
|
||||
//
|
||||
// namespace OE.ALGA.Tesztek
|
||||
// {
|
||||
// [TestClass()]
|
||||
// public class LancoltVeremTesztek
|
||||
// {
|
||||
// [TestMethod()]
|
||||
// public void MindenJolMukodik() //F2.
|
||||
// {
|
||||
// Verem<int> v = new LancoltVerem<int>();
|
||||
// v.Verembe(1);
|
||||
// v.Verembe(3);
|
||||
// v.Verembe(2);
|
||||
// Assert.AreEqual(2, v.Verembol());
|
||||
// v.Verembe(4);
|
||||
// Assert.AreEqual(4, v.Verembol());
|
||||
// Assert.AreEqual(3, v.Verembol());
|
||||
// Assert.AreEqual(1, v.Verembol());
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// [ExpectedException(typeof(NincsElemKivetel))]
|
||||
// public void TulKevesElem() //F2.
|
||||
// {
|
||||
// Verem<int> v = new LancoltVerem<int>();
|
||||
// v.Verembe(1);
|
||||
// v.Verembe(3);
|
||||
// v.Verembe(2);
|
||||
// v.Verembol();
|
||||
// v.Verembol();
|
||||
// v.Verembol();
|
||||
// v.Verembol();
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void Felso() //F2.
|
||||
// {
|
||||
// Verem<int> v = new LancoltVerem<int>();
|
||||
// v.Verembe(1);
|
||||
// v.Verembe(3);
|
||||
// v.Verembe(2);
|
||||
// Assert.AreEqual(2, v.Felso());
|
||||
// Assert.AreEqual(2, v.Felso());
|
||||
// v.Verembol();
|
||||
// Assert.AreEqual(3, v.Felso());
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void Ures() //F2.
|
||||
// {
|
||||
// Verem<int> v = new LancoltVerem<int>();
|
||||
// Assert.IsTrue(v.Ures);
|
||||
// v.Verembe(1);
|
||||
// Assert.IsFalse(v.Ures);
|
||||
// v.Verembol();
|
||||
// Assert.IsTrue(v.Ures);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [TestClass()]
|
||||
// public class LancoltSorTesztek
|
||||
// {
|
||||
// [TestMethod()]
|
||||
// public void AlapMukodes() //F3.
|
||||
// {
|
||||
// Sor<int> s = new LancoltSor<int>();
|
||||
// s.Sorba(1);
|
||||
// s.Sorba(3);
|
||||
// s.Sorba(2);
|
||||
// Assert.AreEqual(1, s.Sorbol());
|
||||
// Assert.AreEqual(3, s.Sorbol());
|
||||
// Assert.AreEqual(2, s.Sorbol());
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// [ExpectedException(typeof(NincsElemKivetel))]
|
||||
// public void TulKevesElem() //F3.
|
||||
// {
|
||||
// Sor<int> s = new LancoltSor<int>();
|
||||
// s.Sorba(1);
|
||||
// s.Sorba(3);
|
||||
// s.Sorba(2);
|
||||
// s.Sorbol();
|
||||
// s.Sorbol();
|
||||
// s.Sorbol();
|
||||
// s.Sorbol();
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void Elso() //F3.
|
||||
// {
|
||||
// Sor<int> s = new LancoltSor<int>();
|
||||
// s.Sorba(1);
|
||||
// s.Sorba(3);
|
||||
// s.Sorba(2);
|
||||
// Assert.AreEqual(1, s.Elso());
|
||||
// Assert.AreEqual(1, s.Elso());
|
||||
// s.Sorbol();
|
||||
// Assert.AreEqual(3, s.Elso());
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void Ures() //F3.
|
||||
// {
|
||||
// Sor<int> s = new LancoltSor<int>();
|
||||
// Assert.IsTrue(s.Ures);
|
||||
// s.Sorba(1);
|
||||
// Assert.IsFalse(s.Ures);
|
||||
// s.Sorbol();
|
||||
// Assert.IsTrue(s.Ures);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [TestClass]
|
||||
// public class LancoltListaTesztek
|
||||
// {
|
||||
// [TestMethod]
|
||||
// public void Bejaras() //F4.
|
||||
// {
|
||||
// Lista<int> l = new LancoltLista<int>();
|
||||
// l.Hozzafuz(1);
|
||||
// l.Hozzafuz(3);
|
||||
// l.Hozzafuz(2);
|
||||
// string s = "";
|
||||
// l.Bejar(x => s += x.ToString());
|
||||
// Assert.AreEqual("132", s);
|
||||
// }
|
||||
//
|
||||
// [TestMethod]
|
||||
// public void HozzaFuzes() //F4.
|
||||
// {
|
||||
// Lista<int> l = new LancoltLista<int>();
|
||||
// l.Hozzafuz(1);
|
||||
// l.Hozzafuz(3);
|
||||
// l.Hozzafuz(2);
|
||||
// Assert.AreEqual(1, l.Kiolvas(0));
|
||||
// Assert.AreEqual(3, l.Kiolvas(1));
|
||||
// Assert.AreEqual(2, l.Kiolvas(2));
|
||||
// }
|
||||
//
|
||||
// [TestMethod]
|
||||
// public void Meret() //F4.
|
||||
// {
|
||||
// Lista<string> l = new LancoltLista<string>();
|
||||
// Assert.AreEqual(0, l.Elemszam);
|
||||
// l.Hozzafuz("A");
|
||||
// Assert.AreEqual(1, l.Elemszam);
|
||||
// l.Hozzafuz("B");
|
||||
// Assert.AreEqual(2, l.Elemszam);
|
||||
// }
|
||||
//
|
||||
// [TestMethod]
|
||||
// public void Novekedes() //F4.
|
||||
// {
|
||||
// Lista<int> l = new LancoltLista<int>();
|
||||
// for (int i = 0; i < 1000; i++)
|
||||
// l.Hozzafuz(i * i);
|
||||
// for (int i = 0; i < 1000; i++)
|
||||
// Assert.AreEqual(i * i, l.Kiolvas(i));
|
||||
// }
|
||||
//
|
||||
// [TestMethod]
|
||||
// public void Beszuras() //F4.
|
||||
// {
|
||||
// Lista<int> l = new LancoltLista<int>();
|
||||
// l.Beszur(0, 1);
|
||||
// l.Beszur(0, 2);
|
||||
// l.Beszur(1, 3);
|
||||
// l.Beszur(3, 4);
|
||||
// l.Beszur(2, 5);
|
||||
// Assert.AreEqual(2, l.Kiolvas(0));
|
||||
// Assert.AreEqual(3, l.Kiolvas(1));
|
||||
// Assert.AreEqual(5, l.Kiolvas(2));
|
||||
// Assert.AreEqual(1, l.Kiolvas(3));
|
||||
// Assert.AreEqual(4, l.Kiolvas(4));
|
||||
// }
|
||||
//
|
||||
// [TestMethod]
|
||||
// public void Torles() //F4.
|
||||
// {
|
||||
// Lista<int> l = new LancoltLista<int>();
|
||||
// l.Hozzafuz(1);
|
||||
// l.Hozzafuz(3);
|
||||
// l.Hozzafuz(2);
|
||||
// l.Hozzafuz(3);
|
||||
// l.Hozzafuz(4);
|
||||
// l.Torol(3);
|
||||
// Assert.AreEqual(1, l.Kiolvas(0));
|
||||
// Assert.AreEqual(2, l.Kiolvas(1));
|
||||
// Assert.AreEqual(4, l.Kiolvas(2));
|
||||
// }
|
||||
//
|
||||
// [TestMethod]
|
||||
// public void Modositas() //F4.
|
||||
// {
|
||||
// Lista<int> l = new LancoltLista<int>();
|
||||
// l.Hozzafuz(1);
|
||||
// l.Hozzafuz(3);
|
||||
// l.Hozzafuz(2);
|
||||
// l.Modosit(1, 5);
|
||||
// l.Modosit(0, 4);
|
||||
// Assert.AreEqual(4, l.Kiolvas(0));
|
||||
// Assert.AreEqual(5, l.Kiolvas(1));
|
||||
// Assert.AreEqual(2, l.Kiolvas(2));
|
||||
// }
|
||||
//
|
||||
// [TestMethod]
|
||||
// public void ForeachBejaras() //F5.
|
||||
// {
|
||||
// LancoltLista<string> l = new LancoltLista<string>();
|
||||
// l.Hozzafuz("a");
|
||||
// l.Hozzafuz("c");
|
||||
// l.Hozzafuz("d");
|
||||
// l.Hozzafuz("b");
|
||||
// string osszefuzo = "";
|
||||
// foreach (string x in l)
|
||||
// {
|
||||
// osszefuzo += x;
|
||||
// }
|
||||
// Assert.AreEqual("acdb", osszefuzo);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
68
Tesztek/05_BinarisKeresoFaTesztek.cs
Normal file
68
Tesztek/05_BinarisKeresoFaTesztek.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
// using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
// using OE.ALGA.Adatszerkezetek;
|
||||
//
|
||||
// namespace OE.ALGA.Tesztek
|
||||
// {
|
||||
// [TestClass()]
|
||||
// public class FaHalmazTesztek
|
||||
// {
|
||||
// [TestMethod()]
|
||||
// public void Beszuras() //F4.
|
||||
// {
|
||||
// Halmaz<int> v = new FaHalmaz<int>();
|
||||
// v.Beszur(1);
|
||||
// v.Beszur(3);
|
||||
// v.Beszur(2);
|
||||
// Assert.IsTrue(v.Eleme(1));
|
||||
// Assert.IsTrue(v.Eleme(2));
|
||||
// Assert.IsTrue(v.Eleme(3));
|
||||
// Assert.IsFalse(v.Eleme(4));
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void Torles() //F5.
|
||||
// {
|
||||
// Halmaz<int> v = new FaHalmaz<int>();
|
||||
// v.Beszur(1);
|
||||
// v.Beszur(3);
|
||||
// v.Beszur(2);
|
||||
// v.Torol(2);
|
||||
// Assert.IsTrue(v.Eleme(1));
|
||||
// Assert.IsFalse(v.Eleme(2));
|
||||
// Assert.IsTrue(v.Eleme(3));
|
||||
// Assert.IsFalse(v.Eleme(4));
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void DuplaBeszuras() //F5.
|
||||
// {
|
||||
// Halmaz<int> v = new FaHalmaz<int>();
|
||||
// v.Beszur(1);
|
||||
// v.Beszur(2);
|
||||
// v.Beszur(3);
|
||||
// v.Beszur(2);
|
||||
// v.Torol(2);
|
||||
// Assert.IsTrue(v.Eleme(1));
|
||||
// Assert.IsFalse(v.Eleme(2));
|
||||
// Assert.IsTrue(v.Eleme(3));
|
||||
// Assert.IsFalse(v.Eleme(4));
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void PreorderBejaras() //F6.
|
||||
// {
|
||||
// Halmaz<int> v = new FaHalmaz<int>();
|
||||
// v.Beszur(5);
|
||||
// v.Beszur(3);
|
||||
// v.Beszur(1);
|
||||
// v.Beszur(8);
|
||||
// v.Beszur(4);
|
||||
// v.Beszur(9);
|
||||
// v.Beszur(7);
|
||||
// string osszefuzo = "";
|
||||
// v.Bejar(x => osszefuzo += x);
|
||||
// Assert.AreEqual("5314879", osszefuzo);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
85
Tesztek/06_SzotarTesztek.cs
Normal file
85
Tesztek/06_SzotarTesztek.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
// using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
// using OE.ALGA.Adatszerkezetek;
|
||||
//
|
||||
// namespace OE.ALGA.Tesztek
|
||||
// {
|
||||
// [TestClass()]
|
||||
// public class SzotarTesztek
|
||||
// {
|
||||
// public static int TesztHasitoFuggveny(string kulcs) //F2.(f)
|
||||
// {
|
||||
// if (string.IsNullOrEmpty(kulcs))
|
||||
// return 0;
|
||||
// int sum = 0;
|
||||
// foreach (char c in kulcs.ToCharArray())
|
||||
// sum += ((byte)c);
|
||||
// return (sum * sum); // a modulo osztást a szótárnak kell végeznie, mert ő tudja csak a belső tömb méretet
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void AlapMukodes() //F2.(f)
|
||||
// {
|
||||
// Szotar<string, int> sz = new HasitoSzotarTulcsordulasiTerulettel<string, int>(10, TesztHasitoFuggveny);
|
||||
// sz.Beir("Bela", 5);
|
||||
// sz.Beir("Lajos", 2);
|
||||
// Assert.AreEqual(5, sz.Kiolvas("Bela"));
|
||||
// Assert.AreEqual(2, sz.Kiolvas("Lajos"));
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void AlapertelmezettHasitoFuggvennyel() //F2.(f)
|
||||
// {
|
||||
// Szotar<string, int> sz = new HasitoSzotarTulcsordulasiTerulettel<string, int>(10);
|
||||
// sz.Beir("Bela", 5);
|
||||
// sz.Beir("Lajos", 2);
|
||||
// Assert.AreEqual(5, sz.Kiolvas("Bela"));
|
||||
// Assert.AreEqual(2, sz.Kiolvas("Lajos"));
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void Kulcsutkozes() //F2.(f)
|
||||
// {
|
||||
// Szotar<string, int> sz = new HasitoSzotarTulcsordulasiTerulettel<string, int>(10, TesztHasitoFuggveny);
|
||||
// sz.Beir("Bela", 5);
|
||||
// sz.Beir("Bale", 15);
|
||||
// sz.Beir("Lajos", 2);
|
||||
// sz.Beir("Lasoj", 12);
|
||||
// Assert.AreEqual(5, sz.Kiolvas("Bela"));
|
||||
// Assert.AreEqual(2, sz.Kiolvas("Lajos"));
|
||||
// Assert.AreEqual(15, sz.Kiolvas("Bale"));
|
||||
// Assert.AreEqual(12, sz.Kiolvas("Lasoj"));
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// [ExpectedException(typeof(HibasKulcsKivetel))]
|
||||
// public void NincsElem() //F2.(f)
|
||||
// {
|
||||
// Szotar<string, int> sz = new HasitoSzotarTulcsordulasiTerulettel<string, int>(5, TesztHasitoFuggveny);
|
||||
// sz.Beir("Bela", 5);
|
||||
// sz.Beir("Lajos", 2);
|
||||
// sz.Kiolvas("Ferenc");
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void TorlesMarad() //F2.(g)
|
||||
// {
|
||||
// Szotar<string, int> sz = new HasitoSzotarTulcsordulasiTerulettel<string, int>(5, TesztHasitoFuggveny);
|
||||
// sz.Beir("Bela", 5);
|
||||
// sz.Beir("Lajos", 2);
|
||||
// sz.Torol("Bela");
|
||||
// Assert.AreEqual(2, sz.Kiolvas("Lajos"));
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// [ExpectedException(typeof(HibasKulcsKivetel))]
|
||||
// public void TorlesEltunt() //F2.(g)
|
||||
// {
|
||||
// Szotar<string, int> sz = new HasitoSzotarTulcsordulasiTerulettel<string, int>(5, TesztHasitoFuggveny);
|
||||
// sz.Beir("Bela", 5);
|
||||
// sz.Beir("Lajos", 2);
|
||||
// sz.Torol("Bela");
|
||||
// sz.Kiolvas("Bela");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
109
Tesztek/07_NyersEroTesztek.cs
Normal file
109
Tesztek/07_NyersEroTesztek.cs
Normal file
@@ -0,0 +1,109 @@
|
||||
// using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
// using OE.ALGA.Optimalizalas;
|
||||
//
|
||||
// namespace OE.ALGA.Tesztek
|
||||
// {
|
||||
// public class PakolasTesztEsetek //F1.
|
||||
// {
|
||||
// public static readonly bool[] uresPakolas = new bool[] { false, false, false, false, false, false };
|
||||
// public static readonly bool[] feligPakolas = new bool[] { false, true, false, true, false, false };
|
||||
// public static readonly bool[] teljesPakolas = new bool[] { true, true, true, true, true, true };
|
||||
//
|
||||
// public static readonly int[] jegyzet_w = new int[] { 2, 1, 1, 1, 3, 2 };
|
||||
// public static readonly float[] jegyzet_p = new float[] { 4, 3, 2, 8, 7, 5 };
|
||||
// public static readonly int jegyzet_n = jegyzet_w.Length;
|
||||
// public static readonly int jegyzet_Wmax = 4;
|
||||
// public static readonly float jegyzet_optimalis_ertek = 16;
|
||||
// public static readonly bool[] jegyzet_optimalis_pakolas = new bool[] { false, true, false, true, false, true };
|
||||
//
|
||||
// public static readonly int[] nagy_w = new int[] { 21, 41, 26, 11, 37, 25, 25, 44, 33, 29, 32, 52, 41, 62, 56, 81, 43 };
|
||||
// public static readonly float[] nagy_p = new float[] { 4, 3, 2, 8, 7, 5, 4, 3, 2, 5, 3, 9, 5, 1, 7, 9, 4 };
|
||||
// public static readonly int nagy_n = nagy_w.Length;
|
||||
// public static readonly int nagy_Wmax = 100;
|
||||
// public static readonly float nagy_optimalis_ertek = 24;
|
||||
// }
|
||||
//
|
||||
// [TestClass()]
|
||||
// public class HatizsakTesztek
|
||||
// {
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void SulyTeszt() //F1.
|
||||
// {
|
||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.jegyzet_n, PakolasTesztEsetek.jegyzet_Wmax, PakolasTesztEsetek.jegyzet_w, PakolasTesztEsetek.jegyzet_p);
|
||||
// Assert.AreEqual(0, problema.OsszSuly(PakolasTesztEsetek.uresPakolas));
|
||||
// Assert.AreEqual(10, problema.OsszSuly(PakolasTesztEsetek.teljesPakolas));
|
||||
// Assert.AreEqual(2, problema.OsszSuly(PakolasTesztEsetek.feligPakolas));
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void JosagTeszt() //F1.
|
||||
// {
|
||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.jegyzet_n, PakolasTesztEsetek.jegyzet_Wmax, PakolasTesztEsetek.jegyzet_w, PakolasTesztEsetek.jegyzet_p);
|
||||
// Assert.AreEqual(0, problema.OsszErtek(PakolasTesztEsetek.uresPakolas));
|
||||
// Assert.AreEqual(29, problema.OsszErtek(PakolasTesztEsetek.teljesPakolas));
|
||||
// Assert.AreEqual(11, problema.OsszErtek(PakolasTesztEsetek.feligPakolas));
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void ErvenyesTeszt() //F1.
|
||||
// {
|
||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.jegyzet_n, PakolasTesztEsetek.jegyzet_Wmax, PakolasTesztEsetek.jegyzet_w, PakolasTesztEsetek.jegyzet_p);
|
||||
// Assert.IsTrue(problema.Ervenyes(PakolasTesztEsetek.uresPakolas));
|
||||
// Assert.IsFalse(problema.Ervenyes(PakolasTesztEsetek.teljesPakolas));
|
||||
// Assert.IsTrue(problema.Ervenyes(PakolasTesztEsetek.feligPakolas));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [TestClass()]
|
||||
// public class NyersEroTesztek
|
||||
// {
|
||||
// [TestMethod()]
|
||||
// public void TombLegnagyobbEleme() //F2.
|
||||
// {
|
||||
// int[] A = { 4, 6, 7, 4, 2, 1 };
|
||||
// NyersEro<int> opt = new NyersEro<int>(
|
||||
// A.Length,
|
||||
// x => A[x-1],
|
||||
// x => x);
|
||||
// Assert.AreEqual(7, opt.OptimalisMegoldas());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [TestClass()]
|
||||
// public class NyersEroHatizsakPakolasTesztek
|
||||
// {
|
||||
// [TestMethod()]
|
||||
// public void JegyzetbenLevoPeldaErtekTeszt() //F3.
|
||||
// {
|
||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.jegyzet_n, PakolasTesztEsetek.jegyzet_Wmax, PakolasTesztEsetek.jegyzet_w, PakolasTesztEsetek.jegyzet_p);
|
||||
// NyersEroHatizsakPakolas opt = new NyersEroHatizsakPakolas(problema);
|
||||
// Assert.AreEqual(PakolasTesztEsetek.jegyzet_optimalis_ertek, opt.OptimalisErtek());
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void JegyzetbenLevoPeldaMegoldasTeszt() //F3.
|
||||
// {
|
||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.jegyzet_n, PakolasTesztEsetek.jegyzet_Wmax, PakolasTesztEsetek.jegyzet_w, PakolasTesztEsetek.jegyzet_p);
|
||||
// NyersEroHatizsakPakolas opt = new NyersEroHatizsakPakolas(problema);
|
||||
// CollectionAssert.AreEqual(PakolasTesztEsetek.jegyzet_optimalis_pakolas, opt.OptimalisMegoldas());
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void NagyPeldaMegoldasTeszt() //F3.
|
||||
// {
|
||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.nagy_n, PakolasTesztEsetek.nagy_Wmax, PakolasTesztEsetek.nagy_w, PakolasTesztEsetek.nagy_p);
|
||||
// NyersEroHatizsakPakolas opt = new NyersEroHatizsakPakolas(problema);
|
||||
// Assert.AreEqual(PakolasTesztEsetek.nagy_optimalis_ertek, opt.OptimalisErtek());
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void LepesszamVizsgalat() //F3.
|
||||
// {
|
||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.nagy_n, PakolasTesztEsetek.nagy_Wmax, PakolasTesztEsetek.nagy_w, PakolasTesztEsetek.nagy_p);
|
||||
// NyersEroHatizsakPakolas opt = new NyersEroHatizsakPakolas(problema);
|
||||
// Assert.AreEqual(PakolasTesztEsetek.nagy_optimalis_ertek, opt.OptimalisErtek());
|
||||
// Console.WriteLine("Lépésszám: " + opt.LepesSzam);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
42
Tesztek/08_DinamikusProgramozasTesztek.cs
Normal file
42
Tesztek/08_DinamikusProgramozasTesztek.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
// using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
// using OE.ALGA.Optimalizalas;
|
||||
//
|
||||
// namespace OE.ALGA.Tesztek
|
||||
// {
|
||||
// [TestClass()]
|
||||
// public class DinamikusProgramozasTesztek
|
||||
// {
|
||||
// [TestMethod()]
|
||||
// public void JegyzetbenLevoPeldaErtekTeszt() //F1.
|
||||
// {
|
||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.jegyzet_n, PakolasTesztEsetek.jegyzet_Wmax, PakolasTesztEsetek.jegyzet_w, PakolasTesztEsetek.jegyzet_p);
|
||||
// DinamikusHatizsakPakolas opt = new DinamikusHatizsakPakolas(problema);
|
||||
// Assert.AreEqual(PakolasTesztEsetek.jegyzet_optimalis_ertek, opt.OptimalisErtek());
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void JegyzetbenLevoPeldaMegoldasTeszt() //F1.
|
||||
// {
|
||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.jegyzet_n, PakolasTesztEsetek.jegyzet_Wmax, PakolasTesztEsetek.jegyzet_w, PakolasTesztEsetek.jegyzet_p);
|
||||
// DinamikusHatizsakPakolas opt = new DinamikusHatizsakPakolas(problema);
|
||||
// CollectionAssert.AreEqual(PakolasTesztEsetek.jegyzet_optimalis_pakolas, opt.OptimalisMegoldas());
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void NagyPeldaMegoldasTeszt() //F1.
|
||||
// {
|
||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.nagy_n, PakolasTesztEsetek.nagy_Wmax, PakolasTesztEsetek.nagy_w, PakolasTesztEsetek.nagy_p);
|
||||
// DinamikusHatizsakPakolas opt = new DinamikusHatizsakPakolas(problema);
|
||||
// Assert.AreEqual(PakolasTesztEsetek.nagy_optimalis_ertek, opt.OptimalisErtek());
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void LepesszamVizsgalat() //F1.
|
||||
// {
|
||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.nagy_n, PakolasTesztEsetek.nagy_Wmax, PakolasTesztEsetek.nagy_w, PakolasTesztEsetek.nagy_p);
|
||||
// DinamikusHatizsakPakolas opt = new DinamikusHatizsakPakolas(problema);
|
||||
// Assert.AreEqual(PakolasTesztEsetek.nagy_optimalis_ertek, opt.OptimalisErtek());
|
||||
// Console.WriteLine("Lépésszám: " + opt.LepesSzam);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
79
Tesztek/09_VisszalepesesKeresesTesztek.cs
Normal file
79
Tesztek/09_VisszalepesesKeresesTesztek.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
// using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
// using OE.ALGA.Optimalizalas;
|
||||
//
|
||||
// namespace OE.ALGA.Tesztek
|
||||
// {
|
||||
// [TestClass()]
|
||||
// public class VisszalepesesKeresesTesztek
|
||||
// {
|
||||
// [TestMethod()]
|
||||
// public void JegyzetbenLevoPeldaErtekTeszt() //F2.
|
||||
// {
|
||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.jegyzet_n, PakolasTesztEsetek.jegyzet_Wmax, PakolasTesztEsetek.jegyzet_w, PakolasTesztEsetek.jegyzet_p);
|
||||
// VisszalepesesHatizsakPakolas opt = new VisszalepesesHatizsakPakolas(problema);
|
||||
// Assert.AreEqual(PakolasTesztEsetek.jegyzet_optimalis_ertek, opt.OptimalisErtek());
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void JegyzetbenLevoPeldaMegoldasTeszt() //F2.
|
||||
// {
|
||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.jegyzet_n, PakolasTesztEsetek.jegyzet_Wmax, PakolasTesztEsetek.jegyzet_w, PakolasTesztEsetek.jegyzet_p);
|
||||
// VisszalepesesHatizsakPakolas opt = new VisszalepesesHatizsakPakolas(problema);
|
||||
// CollectionAssert.AreEqual(PakolasTesztEsetek.jegyzet_optimalis_pakolas, opt.OptimalisMegoldas());
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void NagyPeldaMegoldasTeszt() //F2.
|
||||
// {
|
||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.nagy_n, PakolasTesztEsetek.nagy_Wmax, PakolasTesztEsetek.nagy_w, PakolasTesztEsetek.nagy_p);
|
||||
// VisszalepesesHatizsakPakolas opt = new VisszalepesesHatizsakPakolas(problema);
|
||||
// Assert.AreEqual(PakolasTesztEsetek.nagy_optimalis_ertek, opt.OptimalisErtek());
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void LepesszamVizsgalat() //F2.
|
||||
// {
|
||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.nagy_n, PakolasTesztEsetek.nagy_Wmax, PakolasTesztEsetek.nagy_w, PakolasTesztEsetek.nagy_p);
|
||||
// VisszalepesesHatizsakPakolas opt = new VisszalepesesHatizsakPakolas(problema);
|
||||
// Assert.AreEqual(PakolasTesztEsetek.nagy_optimalis_ertek, opt.OptimalisErtek());
|
||||
// Console.WriteLine("Lépésszám: " + opt.LepesSzam);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [TestClass()]
|
||||
// public class SzetvalasztasEsKorlatozasTesztek
|
||||
// {
|
||||
// [TestMethod()]
|
||||
// public void JegyzetbenLevoPeldaErtekTeszt() //F4.
|
||||
// {
|
||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.jegyzet_n, PakolasTesztEsetek.jegyzet_Wmax, PakolasTesztEsetek.jegyzet_w, PakolasTesztEsetek.jegyzet_p);
|
||||
// SzetvalasztasEsKorlatozasHatizsakPakolas opt = new SzetvalasztasEsKorlatozasHatizsakPakolas(problema);
|
||||
// Assert.AreEqual(PakolasTesztEsetek.jegyzet_optimalis_ertek, opt.OptimalisErtek());
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void JegyzetbenLevoPeldaMegoldasTeszt() //F4.
|
||||
// {
|
||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.jegyzet_n, PakolasTesztEsetek.jegyzet_Wmax, PakolasTesztEsetek.jegyzet_w, PakolasTesztEsetek.jegyzet_p);
|
||||
// SzetvalasztasEsKorlatozasHatizsakPakolas opt = new SzetvalasztasEsKorlatozasHatizsakPakolas(problema);
|
||||
// CollectionAssert.AreEqual(PakolasTesztEsetek.jegyzet_optimalis_pakolas, opt.OptimalisMegoldas());
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void NagyPeldaMegoldasTeszt() //F4.
|
||||
// {
|
||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.nagy_n, PakolasTesztEsetek.nagy_Wmax, PakolasTesztEsetek.nagy_w, PakolasTesztEsetek.nagy_p);
|
||||
// SzetvalasztasEsKorlatozasHatizsakPakolas opt = new SzetvalasztasEsKorlatozasHatizsakPakolas(problema);
|
||||
// Assert.AreEqual(PakolasTesztEsetek.nagy_optimalis_ertek, opt.OptimalisErtek());
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void LepesszamVizsgalat() //F4.
|
||||
// {
|
||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.nagy_n, PakolasTesztEsetek.nagy_Wmax, PakolasTesztEsetek.nagy_w, PakolasTesztEsetek.nagy_p);
|
||||
// SzetvalasztasEsKorlatozasHatizsakPakolas opt = new SzetvalasztasEsKorlatozasHatizsakPakolas(problema);
|
||||
// Assert.AreEqual(PakolasTesztEsetek.nagy_optimalis_ertek, opt.OptimalisErtek());
|
||||
// Console.WriteLine("Lépésszám: " + opt.LepesSzam);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
119
Tesztek/10_SulyozatlanGrafTesztek.cs
Normal file
119
Tesztek/10_SulyozatlanGrafTesztek.cs
Normal file
@@ -0,0 +1,119 @@
|
||||
// using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
// using OE.ALGA.Adatszerkezetek;
|
||||
//
|
||||
// namespace OE.ALGA.Tesztek
|
||||
// {
|
||||
// [TestClass]
|
||||
// public class CsucsMatrixGrafTesztek
|
||||
// {
|
||||
// [TestMethod]
|
||||
// public void MindenCsucsTeszt() //F2.
|
||||
// {
|
||||
// CsucsmatrixSulyozatlanEgeszGraf csg = new CsucsmatrixSulyozatlanEgeszGraf(2);
|
||||
// Assert.IsTrue(csg.Csucsok.Eleme(0));
|
||||
// Assert.IsTrue(csg.Csucsok.Eleme(1));
|
||||
// }
|
||||
//
|
||||
// [TestMethod]
|
||||
// public void MindenElTeszt() //F2.
|
||||
// {
|
||||
// CsucsmatrixSulyozatlanEgeszGraf csg = new CsucsmatrixSulyozatlanEgeszGraf(3);
|
||||
// csg.UjEl(0, 1);
|
||||
// csg.UjEl(0, 2);
|
||||
// csg.UjEl(1, 2);
|
||||
//
|
||||
// Assert.IsFalse(csg.Elek.Eleme(new EgeszGrafEl(0, 0)));
|
||||
// Assert.IsTrue(csg.Elek.Eleme(new EgeszGrafEl(0, 1)));
|
||||
// Assert.IsTrue(csg.Elek.Eleme(new EgeszGrafEl(0, 2)));
|
||||
//
|
||||
// Assert.IsFalse(csg.Elek.Eleme(new EgeszGrafEl(1, 0)));
|
||||
// Assert.IsFalse(csg.Elek.Eleme(new EgeszGrafEl(1, 1)));
|
||||
// Assert.IsTrue(csg.Elek.Eleme(new EgeszGrafEl(1, 2)));
|
||||
//
|
||||
// Assert.IsFalse(csg.Elek.Eleme(new EgeszGrafEl(2, 0)));
|
||||
// Assert.IsFalse(csg.Elek.Eleme(new EgeszGrafEl(2, 1)));
|
||||
// Assert.IsFalse(csg.Elek.Eleme(new EgeszGrafEl(2, 2)));
|
||||
// }
|
||||
//
|
||||
// [TestMethod]
|
||||
// public void VezetElTeszt() //F2.
|
||||
// {
|
||||
// CsucsmatrixSulyozatlanEgeszGraf csg = new CsucsmatrixSulyozatlanEgeszGraf(2);
|
||||
// Assert.IsFalse(csg.VezetEl(0, 1));
|
||||
// csg.UjEl(0, 1);
|
||||
// Assert.IsTrue(csg.VezetEl(0, 1));
|
||||
// Assert.IsFalse(csg.VezetEl(1, 0));
|
||||
// }
|
||||
//
|
||||
// [TestMethod]
|
||||
// public void SzomszedsagTeszt() //F2.
|
||||
// {
|
||||
// CsucsmatrixSulyozatlanEgeszGraf csg = new CsucsmatrixSulyozatlanEgeszGraf(3);
|
||||
// csg.UjEl(0, 1);
|
||||
// csg.UjEl(0, 2);
|
||||
// csg.UjEl(1, 2);
|
||||
//
|
||||
// Halmaz<int> a_szomszedai = csg.Szomszedai(0);
|
||||
// Halmaz<int> b_szomszedai = csg.Szomszedai(1);
|
||||
// Halmaz<int> c_szomszedai = csg.Szomszedai(2);
|
||||
//
|
||||
// Assert.IsFalse(a_szomszedai.Eleme(0));
|
||||
// Assert.IsTrue(a_szomszedai.Eleme(1));
|
||||
// Assert.IsTrue(a_szomszedai.Eleme(2));
|
||||
//
|
||||
// Assert.IsFalse(b_szomszedai.Eleme(0));
|
||||
// Assert.IsFalse(b_szomszedai.Eleme(1));
|
||||
// Assert.IsTrue(b_szomszedai.Eleme(2));
|
||||
//
|
||||
// Assert.IsFalse(c_szomszedai.Eleme(0));
|
||||
// Assert.IsFalse(c_szomszedai.Eleme(1));
|
||||
// Assert.IsFalse(c_szomszedai.Eleme(2));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [TestClass]
|
||||
// public class GrafBejarasTesztek
|
||||
// {
|
||||
// [TestMethod]
|
||||
// public void SzelessegiBejarasTeszt() //F3.(a)
|
||||
// {
|
||||
// CsucsmatrixSulyozatlanEgeszGraf g = new CsucsmatrixSulyozatlanEgeszGraf(6);
|
||||
// g.UjEl(0, 1);
|
||||
// g.UjEl(1, 2);
|
||||
// g.UjEl(1, 4);
|
||||
// g.UjEl(2, 3);
|
||||
// g.UjEl(2, 4);
|
||||
// g.UjEl(4, 3);
|
||||
// g.UjEl(3, 0);
|
||||
//
|
||||
// string ut = "";
|
||||
// Halmaz<int> elertCsucsok = GrafBejarasok.SzelessegiBejaras(g, 0, (a) => { ut += a; });
|
||||
//
|
||||
// Assert.IsTrue(ut == "01243" || ut == "01423");
|
||||
// for (int i = 0; i <= 4; i++)
|
||||
// Assert.IsTrue(elertCsucsok.Eleme(i));
|
||||
// Assert.IsFalse(elertCsucsok.Eleme(6));
|
||||
// }
|
||||
//
|
||||
// [TestMethod]
|
||||
// public void MelysegiBejarasTeszt() //F3.(c)
|
||||
// {
|
||||
// CsucsmatrixSulyozatlanEgeszGraf g = new CsucsmatrixSulyozatlanEgeszGraf(6);
|
||||
// g.UjEl(0, 1);
|
||||
// g.UjEl(1, 2);
|
||||
// g.UjEl(1, 4);
|
||||
// g.UjEl(2, 3);
|
||||
// g.UjEl(2, 4);
|
||||
// g.UjEl(4, 3);
|
||||
// g.UjEl(3, 0);
|
||||
//
|
||||
// string ut = "";
|
||||
// Halmaz<int> elertCsucsok = GrafBejarasok.MelysegiBejaras(g, 0, (a) => { ut += a; });
|
||||
//
|
||||
// Assert.IsTrue(ut == "01243" || ut == "01432" || ut == "01234");
|
||||
// for (int i = 0; i <= 4; i++)
|
||||
// Assert.IsTrue(elertCsucsok.Eleme(i));
|
||||
// Assert.IsFalse(elertCsucsok.Eleme(6));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
211
Tesztek/11_KupacTesztek.cs
Normal file
211
Tesztek/11_KupacTesztek.cs
Normal file
@@ -0,0 +1,211 @@
|
||||
// using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
// using OE.ALGA.Adatszerkezetek;
|
||||
//
|
||||
// namespace OE.ALGA.Tesztek
|
||||
// {
|
||||
// [TestClass()]
|
||||
// public class KupacRendezesTesztek
|
||||
// {
|
||||
// [TestMethod()]
|
||||
// public void KupacEpites() //F1.
|
||||
// {
|
||||
// int[] A = [1, 3, 2, 4, 9, 12, 32, 21, 12, 8, 11];
|
||||
// _ = new Kupac<int>(A, A.Length, (x, y) => x > y);
|
||||
//
|
||||
// for (int i = 1; i < A.Length; i++)
|
||||
// Assert.IsTrue(A[Kupac<int>.Szulo(i)] >= A[i]);
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void KupacRendezes() //F2.
|
||||
// {
|
||||
// int[] A = [5, 8, 7, 0, 9, 6, 4, 1, 3, 2];
|
||||
// KupacRendezes<int> k = new KupacRendezes<int>(A);
|
||||
// k.Rendezes();
|
||||
//
|
||||
// for (int i = 0; i < A.Length; i++)
|
||||
// Assert.AreEqual(i, A[i]);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [TestClass()]
|
||||
// public class KupacPrioritasosSorTesztek
|
||||
// {
|
||||
// [TestMethod()]
|
||||
// [ExpectedException(typeof(NincsHelyKivetel))]
|
||||
// public void TulSokElemTeszt() //F3.
|
||||
// {
|
||||
// PrioritasosSor<int> s = new KupacPrioritasosSor<int>(2, (x, y) => x > y);
|
||||
// s.Sorba(1);
|
||||
// s.Sorba(2);
|
||||
// s.Sorba(3);
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// [ExpectedException(typeof(NincsElemKivetel))]
|
||||
// public void TulKevesElemTeszt() //F3.
|
||||
// {
|
||||
// PrioritasosSor<int> s = new KupacPrioritasosSor<int>(5, (x, y) => x > y);
|
||||
// s.Sorba(1);
|
||||
// s.Sorba(2);
|
||||
// s.Sorba(3);
|
||||
// s.Sorbol();
|
||||
// s.Sorbol();
|
||||
// s.Sorbol();
|
||||
// s.Sorbol();
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void UresTeszt() //F3.
|
||||
// {
|
||||
// PrioritasosSor<int> s = new KupacPrioritasosSor<int>(5, (x, y) => x > y);
|
||||
// Assert.IsTrue(s.Ures);
|
||||
// s.Sorba(1);
|
||||
// Assert.IsFalse(s.Ures);
|
||||
// s.Sorba(2);
|
||||
// Assert.IsFalse(s.Ures);
|
||||
// s.Sorbol();
|
||||
// Assert.IsFalse(s.Ures);
|
||||
// s.Elso();
|
||||
// Assert.IsFalse(s.Ures);
|
||||
// s.Sorbol();
|
||||
// Assert.IsTrue(s.Ures);
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void SorbaSorbolElsoTeszt() //F3.
|
||||
// {
|
||||
// PrioritasosSor<int> s = new KupacPrioritasosSor<int>(10, (x, y) => x > y);
|
||||
// s.Sorba(1);
|
||||
// s.Sorba(4);
|
||||
// Assert.AreEqual(4, s.Elso());
|
||||
// Assert.AreEqual(4, s.Sorbol());
|
||||
// Assert.AreEqual(1, s.Elso());
|
||||
// s.Sorba(4);
|
||||
// s.Sorba(2);
|
||||
// s.Sorba(8);
|
||||
// s.Sorba(3);
|
||||
// Assert.AreEqual(8, s.Elso());
|
||||
// s.Sorba(9);
|
||||
// s.Sorba(5);
|
||||
// Assert.AreEqual(9, s.Elso());
|
||||
// Assert.AreEqual(9, s.Elso());
|
||||
// Assert.AreEqual(9, s.Sorbol());
|
||||
// Assert.AreEqual(8, s.Elso());
|
||||
// s.Sorba(7);
|
||||
// Assert.AreEqual(8, s.Sorbol());
|
||||
// Assert.AreEqual(7, s.Sorbol());
|
||||
// Assert.AreEqual(5, s.Sorbol());
|
||||
// s.Sorba(2);
|
||||
// Assert.AreEqual(4, s.Sorbol());
|
||||
// Assert.AreEqual(3, s.Sorbol());
|
||||
// Assert.AreEqual(2, s.Sorbol());
|
||||
// Assert.AreEqual(2, s.Sorbol());
|
||||
// Assert.AreEqual(1, s.Elso());
|
||||
// Assert.AreEqual(1, s.Sorbol());
|
||||
// }
|
||||
//
|
||||
// class PrioritasosSzoveg : IComparable //F3.
|
||||
// {
|
||||
// public string Szoveg { get; set; }
|
||||
// public float Prioritas { get; set; }
|
||||
// public PrioritasosSzoveg(string szoveg, float prioritas)
|
||||
// {
|
||||
// this.Szoveg = szoveg;
|
||||
// this.Prioritas = prioritas;
|
||||
// }
|
||||
//
|
||||
// public int CompareTo(object? obj)
|
||||
// {
|
||||
// if (obj is not PrioritasosSzoveg o)
|
||||
// throw new NullReferenceException();
|
||||
// else
|
||||
// return Prioritas.CompareTo(o.Prioritas);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [TestMethod()]
|
||||
// public void PrioritasValtozasTeszt() //F3.
|
||||
// {
|
||||
// PrioritasosSzoveg a = new PrioritasosSzoveg("a", 10.0f);
|
||||
// PrioritasosSzoveg b = new PrioritasosSzoveg("b", 5.0f);
|
||||
// PrioritasosSzoveg c = new PrioritasosSzoveg("c", 2.0f);
|
||||
// PrioritasosSzoveg d = new PrioritasosSzoveg("d", 12.0f);
|
||||
// PrioritasosSzoveg e = new PrioritasosSzoveg("e", 15.0f);
|
||||
// PrioritasosSzoveg f = new PrioritasosSzoveg("f", 9.0f);
|
||||
// PrioritasosSzoveg g = new PrioritasosSzoveg("g", 2.0f);
|
||||
// PrioritasosSor<PrioritasosSzoveg> s = new KupacPrioritasosSor<PrioritasosSzoveg>(10, (x, y) => x.CompareTo(y) > 0);
|
||||
// s.Sorba(a);
|
||||
// s.Sorba(b);
|
||||
// s.Sorba(c);
|
||||
// s.Sorba(d);
|
||||
// s.Sorba(e);
|
||||
// Assert.AreEqual("e", s.Elso().Szoveg);
|
||||
// d.Prioritas = 22.0f;
|
||||
// s.Frissit(d);
|
||||
// Assert.AreEqual("d", s.Elso().Szoveg);
|
||||
// d.Prioritas = 8.0f;
|
||||
// s.Frissit(d);
|
||||
// e.Prioritas = 7.0f;
|
||||
// s.Frissit(e);
|
||||
// Assert.AreEqual("a", s.Sorbol().Szoveg);
|
||||
// s.Sorba(f);
|
||||
// s.Sorba(g);
|
||||
// Assert.AreEqual("f", s.Sorbol().Szoveg);
|
||||
// Assert.AreEqual("d", s.Sorbol().Szoveg);
|
||||
// Assert.AreEqual("e", s.Sorbol().Szoveg);
|
||||
// Assert.AreEqual("b", s.Sorbol().Szoveg);
|
||||
// c.Prioritas = 1.5f;
|
||||
// s.Frissit(c);
|
||||
// Assert.AreEqual("g", s.Sorbol().Szoveg);
|
||||
// Assert.AreEqual("c", s.Sorbol().Szoveg);
|
||||
// Assert.IsTrue(s.Ures);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [TestClass()]
|
||||
// public class KupacTesztekKulsoFuggvennyel //F3.
|
||||
// {
|
||||
// /// <summary>
|
||||
// /// Nincs külön rendező függvény, ezért ABC sorrendben rendez az IComparable alapján.
|
||||
// /// </summary>
|
||||
// [TestMethod()]
|
||||
// public void KupacEpitesIComparableAlapjan()
|
||||
// {
|
||||
// KupacPrioritasosSor<string> ps = new KupacPrioritasosSor<string>(10, (x, y) => x.CompareTo(y) > 0);
|
||||
// ps.Sorba("oszibarack");
|
||||
// ps.Sorba("alma");
|
||||
// ps.Sorba("korte");
|
||||
// ps.Sorba("birsalma");
|
||||
// ps.Sorba("barack");
|
||||
// ps.Sorba("dio");
|
||||
// Assert.AreEqual("oszibarack", ps.Sorbol());
|
||||
// Assert.AreEqual("korte", ps.Sorbol());
|
||||
// Assert.AreEqual("dio", ps.Sorbol());
|
||||
// Assert.AreEqual("birsalma", ps.Sorbol());
|
||||
// Assert.AreEqual("barack", ps.Sorbol());
|
||||
// Assert.AreEqual("alma", ps.Sorbol());
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Van egy saját hossz alapú rendező függvény, ezért elsőként a leghosszabb stringeket adja vissza.
|
||||
// /// </summary>
|
||||
// [TestMethod()]
|
||||
// public void KupacEpitesSajatFuggvennyel() //F3.
|
||||
// {
|
||||
// KupacPrioritasosSor<string> ps = new KupacPrioritasosSor<string>(10, (ez, ennel) => ez.Length > ennel.Length);
|
||||
// ps.Sorba("oszibarack");
|
||||
// ps.Sorba("alma");
|
||||
// ps.Sorba("korte");
|
||||
// ps.Sorba("birsalma");
|
||||
// ps.Sorba("barack");
|
||||
// ps.Sorba("dio");
|
||||
// Assert.AreEqual("oszibarack", ps.Sorbol());
|
||||
// Assert.AreEqual("birsalma", ps.Sorbol());
|
||||
// Assert.AreEqual("barack", ps.Sorbol());
|
||||
// Assert.AreEqual("korte", ps.Sorbol());
|
||||
// Assert.AreEqual("alma", ps.Sorbol());
|
||||
// Assert.AreEqual("dio", ps.Sorbol());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
252
Tesztek/12_SulyozottGrafTesztek.cs
Normal file
252
Tesztek/12_SulyozottGrafTesztek.cs
Normal file
@@ -0,0 +1,252 @@
|
||||
// using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
// using OE.ALGA.Adatszerkezetek;
|
||||
//
|
||||
// namespace OE.ALGA.Tesztek
|
||||
// {
|
||||
// [TestClass]
|
||||
// public class CsucsMatrixSulyozottGrafTesztek
|
||||
// {
|
||||
// [TestMethod]
|
||||
// public void MindenCsucsTeszt() //F2.
|
||||
// {
|
||||
// CsucsmatrixSulyozottEgeszGraf csg = new CsucsmatrixSulyozottEgeszGraf(2);
|
||||
// Assert.IsTrue(csg.Csucsok.Eleme(0));
|
||||
// Assert.IsTrue(csg.Csucsok.Eleme(1));
|
||||
// }
|
||||
//
|
||||
// [TestMethod]
|
||||
// public void MindenElTeszt() //F2.
|
||||
// {
|
||||
// CsucsmatrixSulyozottEgeszGraf csg = new CsucsmatrixSulyozottEgeszGraf(3);
|
||||
// csg.UjEl(0, 1, 1.0f);
|
||||
// csg.UjEl(0, 2, 2.0f);
|
||||
// csg.UjEl(1, 2, 3.0f);
|
||||
//
|
||||
// Assert.IsFalse(csg.Elek.Eleme(new SulyozottEgeszGrafEl(0, 0, 0.0f)));
|
||||
// Assert.IsTrue(csg.Elek.Eleme(new SulyozottEgeszGrafEl(0, 1, 1.0f)));
|
||||
// Assert.IsTrue(csg.Elek.Eleme(new SulyozottEgeszGrafEl(0, 2, 2.0f)));
|
||||
//
|
||||
// Assert.IsFalse(csg.Elek.Eleme(new SulyozottEgeszGrafEl(1, 0, 0.0f)));
|
||||
// Assert.IsFalse(csg.Elek.Eleme(new SulyozottEgeszGrafEl(1, 1, 0.0f)));
|
||||
// Assert.IsTrue(csg.Elek.Eleme(new SulyozottEgeszGrafEl(1, 2, 3.0f)));
|
||||
//
|
||||
// Assert.IsFalse(csg.Elek.Eleme(new SulyozottEgeszGrafEl(2, 0, 0.0f)));
|
||||
// Assert.IsFalse(csg.Elek.Eleme(new SulyozottEgeszGrafEl(2, 1, 0.0f)));
|
||||
// Assert.IsFalse(csg.Elek.Eleme(new SulyozottEgeszGrafEl(2, 2, 0.0f)));
|
||||
// }
|
||||
//
|
||||
// [TestMethod]
|
||||
// public void VezetElTeszt() //F2.
|
||||
// {
|
||||
// CsucsmatrixSulyozottEgeszGraf csg = new CsucsmatrixSulyozottEgeszGraf(2);
|
||||
// Assert.IsFalse(csg.VezetEl(0, 1));
|
||||
// csg.UjEl(0, 1, 1.0f);
|
||||
// Assert.IsTrue(csg.VezetEl(0, 1));
|
||||
// Assert.IsFalse(csg.VezetEl(1, 0));
|
||||
// }
|
||||
//
|
||||
// [TestMethod]
|
||||
// public void SzomszedsagTeszt() //F2.
|
||||
// {
|
||||
// CsucsmatrixSulyozottEgeszGraf csg = new CsucsmatrixSulyozottEgeszGraf(3);
|
||||
// csg.UjEl(0, 1, 1.0f);
|
||||
// csg.UjEl(0, 2, 1.0f);
|
||||
// csg.UjEl(1, 2, 1.0f);
|
||||
//
|
||||
// Halmaz<int> a_szomszedai = csg.Szomszedai(0);
|
||||
// Halmaz<int> b_szomszedai = csg.Szomszedai(1);
|
||||
// Halmaz<int> c_szomszedai = csg.Szomszedai(2);
|
||||
//
|
||||
// Assert.IsFalse(a_szomszedai.Eleme(0));
|
||||
// Assert.IsTrue(a_szomszedai.Eleme(1));
|
||||
// Assert.IsTrue(a_szomszedai.Eleme(2));
|
||||
//
|
||||
// Assert.IsFalse(b_szomszedai.Eleme(0));
|
||||
// Assert.IsFalse(b_szomszedai.Eleme(1));
|
||||
// Assert.IsTrue(b_szomszedai.Eleme(2));
|
||||
//
|
||||
// Assert.IsFalse(c_szomszedai.Eleme(0));
|
||||
// Assert.IsFalse(c_szomszedai.Eleme(1));
|
||||
// Assert.IsFalse(c_szomszedai.Eleme(2));
|
||||
// }
|
||||
//
|
||||
// [TestMethod]
|
||||
// [ExpectedException(typeof(NincsElKivetel))]
|
||||
// public void NemLetezoElTeszt() //F2.
|
||||
// {
|
||||
// CsucsmatrixSulyozottEgeszGraf csg = new CsucsmatrixSulyozottEgeszGraf(3);
|
||||
// csg.UjEl(0, 1, 1.0f);
|
||||
// csg.UjEl(0, 2, 1.0f);
|
||||
// csg.Suly(1, 0);
|
||||
// }
|
||||
//
|
||||
// [TestMethod]
|
||||
// public void ElSulyTeszt() //F2.
|
||||
// {
|
||||
// CsucsmatrixSulyozottEgeszGraf csg = new CsucsmatrixSulyozottEgeszGraf(3);
|
||||
// csg.UjEl(0, 1, 2.0f);
|
||||
// csg.UjEl(0, 2, 3.0f);
|
||||
// float szum = 0.0f;
|
||||
// csg.Elek.Bejar(x => szum += csg.Suly(x.Honnan, x.Hova));
|
||||
// Assert.AreEqual(5.0f, szum);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [TestClass]
|
||||
// public class GrafUtkeresesTesztek
|
||||
// {
|
||||
// [TestMethod]
|
||||
// public void DijkstraKicsiGrafTeszt() //F3.
|
||||
// {
|
||||
// CsucsmatrixSulyozottEgeszGraf csg = new CsucsmatrixSulyozottEgeszGraf(3);
|
||||
// csg.UjEl(0, 1, 10.0f);
|
||||
// csg.UjEl(0, 2, 20.0f);
|
||||
// Szotar<int, float> hossz = Utkereses.Dijkstra(csg, 0);
|
||||
// Assert.AreEqual(0.0f, hossz.Kiolvas(0));
|
||||
// Assert.AreEqual(10.0f, hossz.Kiolvas(1));
|
||||
// Assert.AreEqual(20.0f, hossz.Kiolvas(2));
|
||||
//
|
||||
// csg.UjEl(1, 2, 5.0f);
|
||||
// hossz = Utkereses.Dijkstra(csg, 0);
|
||||
// Assert.AreEqual(0.0f, hossz.Kiolvas(0));
|
||||
// Assert.AreEqual(10.0f, hossz.Kiolvas(1));
|
||||
// Assert.AreEqual(15.0f, hossz.Kiolvas(2));
|
||||
// }
|
||||
//
|
||||
// [TestMethod]
|
||||
// public void DijkstraJegyzetGrafTeszt() //F3.
|
||||
// {
|
||||
// CsucsmatrixSulyozottEgeszGraf csg = new CsucsmatrixSulyozottEgeszGraf(7);
|
||||
// csg.UjEl(0, 1, 1.0f);
|
||||
// csg.UjEl(0, 3, 2.0f);
|
||||
// csg.UjEl(0, 4, 4.0f);
|
||||
//
|
||||
// csg.UjEl(1, 0, 1.0f);
|
||||
// csg.UjEl(1, 3, 2.0f);
|
||||
// csg.UjEl(1, 2, 9.0f);
|
||||
//
|
||||
// csg.UjEl(2, 1, 9.0f);
|
||||
// csg.UjEl(2, 3, 5.0f);
|
||||
// csg.UjEl(2, 5, 1.0f);
|
||||
//
|
||||
// csg.UjEl(3, 0, 2.0f);
|
||||
// csg.UjEl(3, 1, 2.0f);
|
||||
// csg.UjEl(3, 2, 5.0f);
|
||||
// csg.UjEl(3, 5, 3.0f);
|
||||
//
|
||||
// csg.UjEl(5, 2, 1.0f);
|
||||
// csg.UjEl(5, 3, 3.0f);
|
||||
// csg.UjEl(5, 6, 3.0f);
|
||||
//
|
||||
// csg.UjEl(6, 5, 3.0f);
|
||||
//
|
||||
// Szotar<int, float> hossz = Utkereses.Dijkstra(csg, 1);
|
||||
// Assert.AreEqual(1.0f, hossz.Kiolvas(0));
|
||||
// Assert.AreEqual(0.0f, hossz.Kiolvas(1));
|
||||
// Assert.AreEqual(6.0f, hossz.Kiolvas(2));
|
||||
// Assert.AreEqual(2.0f, hossz.Kiolvas(3));
|
||||
// Assert.AreEqual(5.0f, hossz.Kiolvas(4));
|
||||
// Assert.AreEqual(5.0f, hossz.Kiolvas(5));
|
||||
// Assert.AreEqual(8.0f, hossz.Kiolvas(6));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// [TestClass]
|
||||
// public class GrafMininmalisFeszitofaTesztek
|
||||
// {
|
||||
// [TestMethod]
|
||||
// public void KisPrimTeszt() //F4.(a)
|
||||
// {
|
||||
// CsucsmatrixSulyozottEgeszGraf csg = new CsucsmatrixSulyozottEgeszGraf(3);
|
||||
// csg.UjEl(0, 1, 10.0f);
|
||||
// csg.UjEl(0, 2, 20.0f);
|
||||
// csg.UjEl(1, 2, 5.0f);
|
||||
// Szotar<int, int> elek = FeszitofaKereses.Prim(csg, 0);
|
||||
// Assert.AreEqual(0, elek.Kiolvas(1));
|
||||
// Assert.AreEqual(1, elek.Kiolvas(2));
|
||||
// }
|
||||
//
|
||||
// [TestMethod]
|
||||
// public void NagyPrimTeszt() //F4.(a)
|
||||
// {
|
||||
// CsucsmatrixSulyozottEgeszGraf csg = new CsucsmatrixSulyozottEgeszGraf(5);
|
||||
// csg.UjEl(0, 1, 5.0f);
|
||||
// csg.UjEl(0, 3, 4.0f);
|
||||
//
|
||||
// csg.UjEl(1, 0, 5.0f);
|
||||
// csg.UjEl(1, 3, 2.0f);
|
||||
// csg.UjEl(1, 2, 1.0f);
|
||||
//
|
||||
// csg.UjEl(2, 1, 1.0f);
|
||||
// csg.UjEl(2, 3, 3.0f);
|
||||
// csg.UjEl(2, 4, 4.0f);
|
||||
//
|
||||
// csg.UjEl(3, 0, 4.0f);
|
||||
// csg.UjEl(3, 1, 2.0f);
|
||||
// csg.UjEl(3, 2, 3.0f);
|
||||
// csg.UjEl(3, 4, 1.0f);
|
||||
//
|
||||
// csg.UjEl(4, 2, 4.0f);
|
||||
// csg.UjEl(4, 3, 1.0f);
|
||||
//
|
||||
// Szotar<int, int> elek = FeszitofaKereses.Prim(csg, 0);
|
||||
// float sum = 0.0f;
|
||||
// csg.Csucsok.Bejar(x =>
|
||||
// {
|
||||
// if (x != 0)
|
||||
// {
|
||||
// int p = elek.Kiolvas(x);
|
||||
// sum += csg.Suly(p, x);
|
||||
// }
|
||||
// }
|
||||
// );
|
||||
// Assert.AreEqual(8.0f, sum);
|
||||
// }
|
||||
//
|
||||
// [TestMethod]
|
||||
// public void KisKruskalTeszt() //F4.(b)
|
||||
// {
|
||||
// CsucsmatrixSulyozottEgeszGraf csg = new CsucsmatrixSulyozottEgeszGraf(3);
|
||||
// csg.UjEl(0, 1, 10.0f);
|
||||
// csg.UjEl(0, 2, 20.0f);
|
||||
// csg.UjEl(1, 2, 5.0f);
|
||||
// Halmaz<SulyozottEgeszGrafEl> elek = FeszitofaKereses.Kruskal(csg);
|
||||
// Assert.IsTrue(elek.Eleme(new SulyozottEgeszGrafEl(0, 1, 10.0f)));
|
||||
// Assert.IsFalse(elek.Eleme(new SulyozottEgeszGrafEl(0, 2, 20.0f)));
|
||||
// Assert.IsTrue(elek.Eleme(new SulyozottEgeszGrafEl(1, 2, 5.0f)));
|
||||
// }
|
||||
//
|
||||
// [TestMethod]
|
||||
// public void NagyKruskalTeszt() //F4.(b)
|
||||
// {
|
||||
// CsucsmatrixSulyozottEgeszGraf csg = new CsucsmatrixSulyozottEgeszGraf(5);
|
||||
// csg.UjEl(0, 1, 5.0f);
|
||||
// csg.UjEl(0, 3, 4.0f);
|
||||
//
|
||||
// csg.UjEl(1, 0, 5.0f);
|
||||
// csg.UjEl(1, 3, 2.0f);
|
||||
// csg.UjEl(1, 2, 1.0f);
|
||||
//
|
||||
// csg.UjEl(2, 1, 1.0f);
|
||||
// csg.UjEl(2, 3, 3.0f);
|
||||
// csg.UjEl(2, 4, 4.0f);
|
||||
//
|
||||
// csg.UjEl(3, 0, 4.0f);
|
||||
// csg.UjEl(3, 1, 2.0f);
|
||||
// csg.UjEl(3, 2, 3.0f);
|
||||
// csg.UjEl(3, 4, 1.0f);
|
||||
//
|
||||
// csg.UjEl(4, 2, 4.0f);
|
||||
// csg.UjEl(4, 3, 1.0f);
|
||||
//
|
||||
// Halmaz<SulyozottEgeszGrafEl> elek = FeszitofaKereses.Kruskal(csg);
|
||||
// float sum = 0.0f;
|
||||
// elek.Bejar(x =>
|
||||
// {
|
||||
// sum += x.Suly;
|
||||
// }
|
||||
// );
|
||||
// Assert.AreEqual(8.0f, sum);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
24
Tesztek/Tesztek.csproj
Normal file
24
Tesztek/Tesztek.csproj
Normal file
@@ -0,0 +1,24 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
<RootNamespace>OE.ALGA.Tesztek</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="3.0.4" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="3.0.4" />
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ALGA\ALGA.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user