using System; using System.Collections.Generic; var beds = new[] { new Bed("Seedlings", 19, true, false), new Bed("Orchids", 45, false, true), new Bed("Herbs", 38, true, true), new Bed("Ferns", 52, false, false), }; const int dryThreshold = 25; Console.WriteLine("Greenhouse watering"); Console.WriteLine($"Water enabled beds if moisture is below {dryThreshold}% or a manual cycle is due."); IReadOnlyList scheduled = BuildSchedule(beds, dryThreshold); Console.WriteLine(); Console.WriteLine("Beds scheduled for watering"); foreach (Bed bed in scheduled) { PrintBed(bed, dryThreshold); } Console.WriteLine($"Total beds scheduled: {scheduled.Count}"); static IReadOnlyList BuildSchedule(IReadOnlyList beds, int dryThreshold) { var scheduled = new List(); foreach (Bed bed in beds) { if (bed.IsEnabled && bed.MoisturePercent < dryThreshold || bed.ManualCycleDue) { scheduled.Add(bed); } } return scheduled; } static void PrintBed(Bed bed, int dryThreshold) { bool isDry = bed.MoisturePercent < dryThreshold; string reason = isDry ? "dry soil" : "manual cycle"; Console.WriteLine($"{bed.Name}: {bed.MoisturePercent}% ({reason})"); } record Bed( string Name, int MoisturePercent, bool IsEnabled, bool ManualCycleDue); // Есть ли баги в этом коде?