static void Main(string[] args) { Random rand = new Random(); Greenhouse house = new Greenhouse(20, 28, 24); house.TooCold += Heater.Warm; house.TooHot += Cooler.Cool; house.Well += (Greenhouse gh) => Console.WriteLine($"Temperature is well. Temperature: {gh.CurrentT}"); while (true) { Console.Clear(); double TemChange = rand.Next(-5, 6); house.print(); Console.WriteLine($"Temperature change: {TemChange}"); house.CurrentT += TemChange; string end = Console.ReadLine(); if (end == "exit" || end == "Exit") { break; } } }
public static void Cool(Greenhouse gh) { Console.WriteLine($"Cooler is working. Temperature: {gh.CurrentT}"); gh.CurrentT -= 5; }
public static void Warm(Greenhouse gh) { Console.WriteLine($"Heater is working. Temperature: {gh.CurrentT}"); gh.CurrentT += 5; }