private void bookRoom(String name, String phone, boolean smoking, int partySize) { boolean booked = false; // Iterate over the rooms for (Room r : rooms) { // To find one that is available and meets the client's smoking preference if (r.isAvailable() && (r.isSmokingRoom() == smoking)) { // Then book the room r.bookRoom(name, phone, partySize); booked = true; break; } } if (!booked) { // Show a message alerting the user with the Reservations frame as the alert's parent or // origin frame JOptionPane.showMessageDialog( this, "Could not find an available room that meet the client's preferences."); } }