import 'dart:io'; // ثوابت للحرارة const int minTemp = 15; const int maxTemp = 30; void main() { // الحالة الافتراضية للأجهزة bool lightsOn = false; int thermostat = 20; bool securityArmed = false; while (true) { // عرض الخيارات للمستخدم print('\n=== Smart Home Control ==='); print('1. Toggle Lights'); print('2. Set Thermostat'); print('3. Arm/Disarm Security System'); print('4. View System Status'); print('5. Exit'); stdout.write('Enter your choice: '); String? choice = stdin.readLineSync(); if (choice == '5') { print('See you next time! Have a great day.'); break; } switch (choice) { case '1': lightsOn = !lightsOn; print('Lights are now ${lightsOn ? "ON" : "OFF"}'); break; case '2': stdout.write('Enter temperature ($minTemp-$maxTemp°C): '); String? tempInput = stdin.readLineSync(); int? temp = int.tryParse(tempInput ?? ''); if (temp != null && temp >= minTemp && temp <= maxTemp) { thermostat = temp; print('Thermostat set to $thermostat°C'); } else { print('Invalid temperature! Please enter a value between $minTemp and $maxTemp.'); } break; case '3': securityArmed = !securityArmed; print('Security System is now ${securityArmed ? "ARMED" : "DISARMED"}'); break; case '4': print('\n--- System Status ---'); print('Lights: ${lightsOn ? "ON" : "OFF"}'); print('Thermostat: $thermostat°C ${temperatureMessage(thermostat)}'); print('Security System: ${securityArmed ? "ARMED" : "DISARMED"}'); break; default: print('Invalid choice! Please select a valid option.'); } } } // دالة لإظهار رسالة FizzBuzz-like حسب الحرارة String temperatureMessage(int temp) { if (temp % 3 == 0 && temp % 5 == 0) { return '- Perfect Day'; } else if (temp % 3 == 0) { return '- Cool Day'; } else if (temp % 5 == 0) { return '- Warm Day'; } else { return ''; } }