19 lines
446 B
Dart
19 lines
446 B
Dart
class Allergies {
|
|
static const List<String> _allergies = [
|
|
'eggs',
|
|
'peanuts',
|
|
'shellfish',
|
|
'strawberries',
|
|
'tomatoes',
|
|
'chocolate',
|
|
'pollen',
|
|
'cats',
|
|
];
|
|
|
|
bool allergicTo(final String item, final int allergyScore) =>
|
|
((allergyScore >> _allergies.indexOf(item)) & 1) == 1;
|
|
|
|
List<String> list(final int allergyScore) =>
|
|
_allergies.where((allergy) => allergicTo(allergy, allergyScore)).toList();
|
|
}
|