From b74f843f5d392c9508e82745321b226c6645bcc5 Mon Sep 17 00:00:00 2001 From: Lendaia Mirai Date: Wed, 24 Sep 2025 23:55:52 +0200 Subject: [PATCH] commit --- ALGA/Paradigmak/01_ImperativParadigma.cs | 46 +++++++++++++++++------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/ALGA/Paradigmak/01_ImperativParadigma.cs b/ALGA/Paradigmak/01_ImperativParadigma.cs index a9a87fd..3028074 100644 --- a/ALGA/Paradigmak/01_ImperativParadigma.cs +++ b/ALGA/Paradigmak/01_ImperativParadigma.cs @@ -6,7 +6,7 @@ namespace OE.ALGA.Paradigmak { public interface IVegrehajthato { - public void Vegrehajtas(); + void Vegrehajtas(); } public interface IFuggo @@ -35,27 +35,45 @@ namespace OE.ALGA.Paradigmak public void Felvesz(T t) { - if (n <= tarolo.Length) - { - tarolo[n] = t; - n++; - } - else + if (tarolo.Length == 0) { throw new TaroloMegteltKivetel(); } + else + { + if (n < tarolo.Length) + { + tarolo[n] = t; + n++; + } + else + { + throw new TaroloMegteltKivetel(); + } + } + } public IEnumerator GetEnumerator() { - throw new NotImplementedException(); + foreach (T t in tarolo) + { + if (t != null) + { + yield return t; + } + } + } virtual public void MindentVegrehajt() { foreach (T t in tarolo) { - t.Vegrehajtas(); + if (t != null) + { + t.Vegrehajtas(); + } } } @@ -67,7 +85,7 @@ namespace OE.ALGA.Paradigmak } - public class FuggoFeladatTarolo : FeladatTarolo where T : IVegrehajthato, IFuggo + public class FuggoFeladatTarolo : FeladatTarolo, IEnumerable where T : IVegrehajthato, IFuggo { public FuggoFeladatTarolo(int l) : base(l) { @@ -77,10 +95,14 @@ namespace OE.ALGA.Paradigmak { foreach (T t in tarolo) { - if (t.FuggosegTeljesul) + if (t != null) { - t.Vegrehajtas(); + if (t.FuggosegTeljesul) + { + t.Vegrehajtas(); + } } + } } }