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