import 'dart:io'; void main() { bool lights = false; bool security = false; int temp = 20; bool run = true; print("Welcome to smart home system!"); while (run) { print("\n1. Toggle Lights"); print("2. Set thermostat Temperature"); print("3. Arm/Disarm Security system"); print("4. view system Status"); print("5. Exit"); stdout.write("Choose option: "); var c = stdin.readLineSync(); if (c == "1") { if (lights) { lights = false; print("Lights are now turned off"); } else { lights = true; print("Lights are now turned on"); } } else if (c == "2") { print("Set thermostat temperature (15-30): "); var t = stdin.readLineSync(); var tt = int.tryParse(t ?? "0"); if (tt == null) { print("not a number"); } else if (tt < 15 || tt > 30) { print("Only 15-30 allowed!"); } else { temp = tt; print("Temperature set to $temp"); } } else if (c == "3") { if (security) { security = false; print("Disarmed"); } else { security = true; print("Armed"); } } else if (c == "4") { print("\n--- STATUS ---"); print("Lights: ${lights ? "ON" : "OFF"}"); print("Temp: $temp C"); print("Security: ${security ? "ARMED" : "OFF"}"); // little FizzBuzz check if (temp % 3 == 0 && temp % 5 == 0) { print("Perfect Day :)"); } else if (temp % 3 == 0) { print("Cool day"); } else if (temp % 5 == 0) { print("Warm day"); } } else if (c == "5") { print("Exitin the system, goodbye!!"); run = false; } else { print("Wrong choice!!"); } } } // اسف على اللخبطة بحاول اتحسن(: