import 'dart:io'; void main() { // 💻 Display startup hint print('💻 To run this program again, use: dart run Smarthome.dart'); // 🔹 Constants (final / const variables) const int minTemp = 15; const int maxTemp = 30; // 🔹 Default device states bool lightsOn = false; int thermostat = 20; bool securityArmed = false; // 🔹 Welcome message print('====================================='); print('🤖 Welcome Ahmed to Smart Home System'); print('====================================='); // 🔹 Main loop for user interaction while (true) { print('\n=== SMART HOME AUTOMATION SYSTEM ==='); print('1️⃣ Toggle Lights'); print('2️⃣ Set Thermostat Temperature'); print('3️⃣ Arm/Disarm Security System'); print('4️⃣ View System Status'); print('5️⃣ Exit'); stdout.write('\nEnter your choice: '); String? choice = stdin.readLineSync(); if (choice == null) continue; if (choice == '5') { print('\nShutting down Smart Home System...'); print('Goodbye, Ahmed! 👋'); break; } switch (choice) { case '1': lightsOn = !lightsOn; print('\n💡 Lights are now ${lightsOn ? "ON" : "OFF"}'); break; case '2': stdout.write('\nEnter temperature ($minTemp°C - $maxTemp°C): '); String? input = stdin.readLineSync(); if (input != null) { int? temp = int.tryParse(input); if (temp != null && temp >= minTemp && temp <= maxTemp) { thermostat = temp; print('🌡️ Thermostat set to $thermostat°C'); } else { print('⚠️ Invalid temperature! Must be between $minTemp°C and $maxTemp°C.'); } } break; case '3': securityArmed = !securityArmed; print('🔒 Security System is now ${securityArmed ? "ARMED" : "DISARMED"}'); break; case '4': // 🔹 FizzBuzz-like logic String dayMessage = ''; if (thermostat % 3 == 0 && thermostat % 5 == 0) { dayMessage = 'Perfect Day'; } else if (thermostat % 3 == 0) { dayMessage = 'Cool Day'; } else if (thermostat % 5 == 0) { dayMessage = 'Warm Day'; } // 🔹 Display system status String lightsStatus = lightsOn ? 'ON' : 'OFF'; String securityStatus = securityArmed ? 'ARMED' : 'DISARMED'; print('\n--- 🏠 SYSTEM STATUS ---'); print('💡 Lights: $lightsStatus'); print('🌡️ Thermostat: $thermostat°C ${dayMessage.isNotEmpty ? "($dayMessage)" : ""}'); print('🔐 Security System: ${securityStatus.toUpperCase()}'); print('--------------------------'); break; default: print('❌ Invalid choice! Please select a valid option (1–5).'); } } }