Untitled
Alemkhan
csharp
a year ago
3.2 kB
7
Indexable
using System; namespace Sport { internal class Program { static void Main(string[] args) { Console.WriteLine("Удержание (сек.)"); PracticeModel holdTimeModel = new PracticeModel() { Value = 80, Actions = new Func<int, string>[] { (value) => { return (value >= 90) ? "Отлично" : null; }, (value) => { return (value >= 80 && value < 90) ? "Хорошо" : null; }, (value) => { return (value >= 70 && value < 80) ? "Удовлетворительно" : null; }, (value) => { return "Не удовлетворительно"; } }, }; holdTimeModel.Value = Convert.ToInt32(Console.ReadLine()); ExecutePractice(holdTimeModel); Console.WriteLine("Планка (сек.)"); PracticeModel plankModel = new PracticeModel() { Value = 80, Actions = new Func<int, string>[] { (value) => { return (value >= 121) ? "Высокий" : null; }, (value) => { return (value >= 61 && value < 120) ? "Выше среднего" : null; }, (value) => { return (value >= 31 && value < 60) ? "Средний" : null; }, (value) => { return (value >= 15 && value < 30) ? "Ниже среднего" : null; }, (value) => { return (value <= 14) ? "Низкий" : null; }, }, }; plankModel.Value = Convert.ToInt32(Console.ReadLine()); ExecutePractice(plankModel); } public static void ExecutePractice(PracticeModel model) { foreach (var action in model.Actions) { string result = action?.Invoke(model.Value); if (result != null) { Console.WriteLine(result); return; } } Console.WriteLine("Не корректные данные"); } } public class PracticeModel { public int Value { get; set; } public Func<int, string>[] Actions { get; set; } } }
Editor is loading...
Leave a Comment