
import jdk.nashorn.tools.ShellFunctions.input

enum class Allergen(val score: Int) {
    EGGS(1),
    PEANUTS(2),
    SHELLFISH(4),
    STRAWBERRIES(8),
    TOMATOES(16),
    CHOCOLATE(32),
    POLLEN(64),
    CATS(128)
}

class Allergies(val allergyScore: Int){
    fun isAllergicTo(allergen: Allergen): Boolean {
        return getList().contains(allergen)
    }

    fun getList(): List<Allergen>{
        val returnList = mutableListOf<Allergen>()
        if (1 and allergyScore == 1){
            returnList.add(Allergen.EGGS)
        }
        if (2 and allergyScore == 2){
            returnList.add(Allergen.PEANUTS)
        }
        if (4 and allergyScore == 4){
            returnList.add(Allergen.SHELLFISH)
        }
        if (8 and allergyScore == 8){
            returnList.add(Allergen.STRAWBERRIES)
        }
        if (16 and allergyScore == 16){
            returnList.add(Allergen.TOMATOES)
        }
        if (32 and allergyScore == 32){
            returnList.add(Allergen.CHOCOLATE)
        }
        if (64 and allergyScore == 64){
            returnList.add(Allergen.POLLEN)
        }
        if (128 and allergyScore == 128){
            returnList.add(Allergen.CATS)
        }
        return returnList
    }
}