using System; using System.Collections.Generic; var batches = new[] { new Batch("K-12", new[] { new Cup(8, false), new Cup(12, false) }), new Batch("K-13", new[] { new Cup(7, false), new Cup(9, false) }), new Batch("K-14", new[] { new Cup(7, true), new Cup(8, false) }), }; const int maxRimThickness = 10; Console.WriteLine("Pottery inspection"); Console.WriteLine($"Release batches only when every cup is uncracked and has a rim of at most {maxRimThickness} mm."); foreach (Batch batch in batches) { Console.WriteLine(); PrintBatch(batch); bool release = CanRelease(batch.Cups, maxRimThickness); Console.WriteLine(release ? "Release batch" : "Hold batch"); } static bool CanRelease(IReadOnlyList cups, int maxRimThickness) { foreach (Cup cup in cups) { if (cup.RimMillimeters > maxRimThickness || cup.IsCracked) { return false; } return true; } return true; } static void PrintBatch(Batch batch) { Console.WriteLine($"Batch {batch.Id}"); for (int index = 0; index < batch.Cups.Count; index++) { Cup cup = batch.Cups[index]; string condition = cup.IsCracked ? "cracked" : "intact"; Console.WriteLine($"Cup {index + 1}: {cup.RimMillimeters} mm, {condition}"); } } record Cup(int RimMillimeters, bool IsCracked); record Batch(string Id, IReadOnlyList Cups); // Есть ли баги в этом коде?