interfaceFilter{funfilteBySex()}classMale:Filter{overridefunfilteBySex(persons:List<Person>):List<Person>{valmen:List<Person>=List<Person>()for(personinpersons){if(person.isMale()){men.add(person)}else{// do Nothing
}}returnmen}}classFemale:Filter{overridefunfilteBySex(persons:List<Person>):List<Person>{valwomen:List<Person>=List<Person>()for(personinpersons){if(person.isFemale()){women.add(person)}else{// do Nothing
}}returnwomen}}