This commit is contained in:
Lendaia Mirai
2025-09-24 23:55:52 +02:00
parent 1d80c9e3fb
commit b74f843f5d

View File

@@ -6,7 +6,7 @@ namespace OE.ALGA.Paradigmak
{ {
public interface IVegrehajthato public interface IVegrehajthato
{ {
public void Vegrehajtas(); void Vegrehajtas();
} }
public interface IFuggo public interface IFuggo
@@ -35,27 +35,45 @@ namespace OE.ALGA.Paradigmak
public void Felvesz(T t) public void Felvesz(T t)
{ {
if (n <= tarolo.Length) if (tarolo.Length == 0)
{
tarolo[n] = t;
n++;
}
else
{ {
throw new TaroloMegteltKivetel(); throw new TaroloMegteltKivetel();
} }
else
{
if (n < tarolo.Length)
{
tarolo[n] = t;
n++;
}
else
{
throw new TaroloMegteltKivetel();
}
}
} }
public IEnumerator GetEnumerator() public IEnumerator GetEnumerator()
{ {
throw new NotImplementedException(); foreach (T t in tarolo)
{
if (t != null)
{
yield return t;
}
}
} }
virtual public void MindentVegrehajt() virtual public void MindentVegrehajt()
{ {
foreach (T t in tarolo) foreach (T t in tarolo)
{ {
t.Vegrehajtas(); if (t != null)
{
t.Vegrehajtas();
}
} }
} }
@@ -67,7 +85,7 @@ namespace OE.ALGA.Paradigmak
} }
public class FuggoFeladatTarolo<T> : FeladatTarolo<T> where T : IVegrehajthato, IFuggo public class FuggoFeladatTarolo<T> : FeladatTarolo<T>, IEnumerable<T> where T : IVegrehajthato, IFuggo
{ {
public FuggoFeladatTarolo(int l) : base(l) public FuggoFeladatTarolo(int l) : base(l)
{ {
@@ -77,10 +95,14 @@ namespace OE.ALGA.Paradigmak
{ {
foreach (T t in tarolo) foreach (T t in tarolo)
{ {
if (t.FuggosegTeljesul) if (t != null)
{ {
t.Vegrehajtas(); if (t.FuggosegTeljesul)
{
t.Vegrehajtas();
}
} }
} }
} }
} }