// ======================================= // Smart Home Automation System // Developer: Ahmed Alawazim // Student ID: 2021204738 // ======================================= import 'dart:io'; void main() { // ======================= // Constants // ======================= const int minTemp = 15; const int maxTemp = 30; // ======================= // Default Device States // ======================= bool lightsOn = false; int thermostat = 20; bool securityArmed = false; // ======================= // Main Loop // ======================= while (true) { print('\n======================================='); print(' Welcome to the Smart Home System! '); print(' Developer: Ahmed Alawazim'); print(' Student ID: 2021204738'); print('======================================='); print('Please choose an action:'); 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(); switch (choice) { case '1': lightsOn = !lightsOn; print('Lights are now ${lightsOn ? "ON" : "OFF"}.\n'); break; case '2': stdout.write('Enter temperature ($minTemp°C - $maxTemp°C): '); String? input = stdin.readLineSync(); int? newTemp = int.tryParse(input ?? ''); if (newTemp == null) { print('Invalid input. Please enter a number.'); } else if (newTemp < minTemp || newTemp > maxTemp) { print('Temperature must be between $minTemp°C and $maxTemp°C.'); } else { thermostat = newTemp; print('Thermostat set to $thermostat°C.'); // FizzBuzz-like feature 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!'); } } break; case '3': securityArmed = !securityArmed; print('Security system is now ${securityArmed ? "ARMED" : "DISARMED"}.\n'); break; case '4': print('\n=== System Status ==='); print('Lights: ${lightsOn ? "ON" : "OFF"}'); print('Thermostat: $thermostat°C'); print('Security: ${securityArmed ? "ARMED" : "DISARMED"}'); break; case '5': print('Exiting Smart Home System. Goodbye!'); return; default: print('Invalid choice. Please try again.'); } } }