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.159 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.158 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.157 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.156 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.155 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.154 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.153 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.152 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.151 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.150 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.149 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.148 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.147 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.146 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.145 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.144 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.143 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.142 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.141 tracks/vbnet/exercises/allergies/Example.vb
trackler-2.2.1.140 tracks/vbnet/exercises/allergies/Example.vb