Sha256: 3a3e8750b958d4d3e1eff8647fe7c8e536e55ebc244dd4b9e3ee92390919e335

Contents?: true

Size: 909 Bytes

Versions: 396

Compression:

Stored size: 909 Bytes

Contents

Public Class Allergies
    Private ReadOnly score As Integer
    Private Shared ReadOnly AvailableAllergies As New Dictionary(Of String, Integer) From {
        {"eggs", 1},
        {"peanuts", 2},
        {"shellfish", 4},
        {"strawberries", 8},
        {"tomatoes", 16},
        {"chocolate", 32},
        {"pollen", 64},
        {"cats", 128}
    }

    Public Sub New(score As Integer)
        Me.score = score
    End Sub

    Public Function AllergicTo(allergy As String) As Boolean
        Return IsInAllergyScore(AvailableAllergies(allergy))
    End Function

    Public Function List() As IList(Of String)
        Return AvailableAllergies.Where(Function(x) IsInAllergyScore(x.Value)).Select(Function(x) x.Key).ToList()
    End Function

    Private Function IsInAllergyScore(allergyValue As Integer) As Boolean
        Return (score And allergyValue) = allergyValue
    End Function
End Class

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.179 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.178 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.177 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.176 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.175 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.174 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.173 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.172 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.171 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.170 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.169 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.167 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.166 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.165 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.164 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.163 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.162 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.161 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.160 tracks/vbnet/exercises/allergies/Example.vb