import 'dart:io'; const int MIN_TEMP = 15; const int MAX_TEMP = 30; void main() { bool lightsOn = false; int thermostat = 20; bool securityArmed = false; while (true) { print('\n=== نظام المنزل الذكي ==='); print('1. تشغيل/إيقاف الأضواء'); print('2. ضبط الثرموستات'); print('3. تسليح/فك تسليح نظام الأمان'); print('4. عرض حالة النظام'); print('5. الخروج'); stdout.write('اختر خيارك: '); String? choice = stdin.readLineSync(); switch (choice) { case '1': lightsOn = !lightsOn; print('الأضواء الآن: ${lightsOn ? "ON" : "OFF"}'); break; case '2': stdout.write('أدخل درجة الحرارة ($MIN_TEMP-$MAX_TEMP): '); String? tempInput = stdin.readLineSync(); int? temp = int.tryParse(tempInput ?? ''); if (temp != null && temp >= MIN_TEMP && temp <= MAX_TEMP) { thermostat = temp; print('تم ضبط الثرموستات على $thermostat°C'); } else { print('درجة حرارة غير صالحة! حاول إدخال قيمة بين $MIN_TEMP و $MAX_TEMP.'); } break; case '3': securityArmed = !securityArmed; print('نظام الأمان الآن: ${securityArmed ? "ARMED" : "DISARMED"}'); break; case '4': print('\n=== حالة النظام ==='); print('الأضواء: ${lightsOn ? "ON" : "OFF"}'); String tempStatus = ''; if (thermostat % 3 == 0 && thermostat % 5 == 0) { tempStatus = 'Perfect Day'; } else if (thermostat % 3 == 0) { tempStatus = 'Cool Day'; } else if (thermostat % 5 == 0) { tempStatus = 'Warm Day'; } print('الثرموستات: $thermostat°C ${tempStatus.isNotEmpty ? "- $tempStatus" : ""}'); print('نظام الأمان: ${securityArmed ? "ARMED" : "DISARMED"}'); break; case '5': print('الخروج من النظام. وداعًا!'); return; default: print('خيار غير صالح. حاول مرة أخرى.'); } } }