import 'dart:io'; const int minTemp = 15; const int maxTemp = 30; class SmartHome { bool lightsOn = false; int thermostat = 20; bool securityArmed = false; void toggleLights() { lightsOn = !lightsOn; print('Lights are now ${lightsOn ? 'ON' : 'OFF'}'); } void setTemperature(int temp) { if (temp >= minTemp && temp <= maxTemp) { thermostat = temp; print('Thermostat set to $thermostat°C'); } else { print('❌ Invalid temperature! Please enter a value between $minTemp and $maxTemp.'); } } void toggleSecurity() { securityArmed = !securityArmed; print('Security system is now ${securityArmed ? 'ARMED' : 'DISARMED'}'); } void showStatus() { print('\n--- Smart Home Status ---'); print('Lights: ${lightsOn ? 'ON' : 'OFF'}'); print('Thermostat: $thermostat°C'); // FizzBuzz-like logic if (thermostat % 3 == 0 && thermostat % 5 == 0) { print('Perfect Day'); } else if (thermostat % 3 == 0) { print('Cool Day'); } else if (thermostat % 5 == 0) { print('Warm Day'); } String securityStatus = securityArmed ? 'ARMED' : 'DISARMED'; print('Security System: $securityStatus'); } } void main() { SmartHome home = SmartHome(); bool running = true; print('🏠 Welcome to Smart Home Automation System'); while (running) { print('\nSelect an option:'); print('1. Toggle Lights'); print('2. Set Thermostat Temperature'); print('3. Toggle Security System'); print('4. View System Status'); print('5. Exit'); stdout.write('Your choice: '); String? choice = stdin.readLineSync(); if (choice == null) continue; switch (choice) { case '1': home.toggleLights(); break; case '2': stdout.write('Enter temperature ($minTemp–$maxTemp): '); String? input = stdin.readLineSync(); int? temp = int.tryParse(input ?? ''); if (temp != null && temp >= minTemp && temp <= maxTemp) { home.setTemperature(temp); } else { print('⚠️ Please enter a valid temperature between $minTemp and $maxTemp.'); } break; case '3': home.toggleSecurity(); break; case '4': home.showStatus(); break; case '5': running = false; print('👋 Exiting Smart Home System... Goodbye!'); break; default: print('❌ Invalid option. Please select between 1–5.'); } } }