count people in a room, switch on the light if anybody in the room, and switch off if nobody in the room
bool isRoomEmpty(List<Person> people) { return people.isEmpty(); } void turnOnLight() { Light.brightness = 100; } void turnOffLight() { Light.brightness = 0; } void switchLight(List<Person> people) { if (isRoomEmpty(people)) { turnOffLight(); } else { turnOnLight(); } }