Skip to content

Instantly share code, notes, and snippets.

@y121516
Last active September 6, 2024 01:36
Show Gist options
  • Save y121516/e67906c40d5dc3fd3acd7496581f797b to your computer and use it in GitHub Desktop.
Save y121516/e67906c40d5dc3fd3acd7496581f797b to your computer and use it in GitHub Desktop.
Option Explicit On
Option Strict On
Option Infer On
Module RoomTemperature
Function IsTemperatureInRange(temperature As Integer) As Boolean
Return -50 <= temperature AndAlso temperature <= 50
End Function
Sub SetRoomTemperature(temperature As Integer)
If Not IsTemperatureInRange(temperature) Then
Throw New ArgumentOutOfRangeException(NameOf(temperature), temperature, Nothing)
End If
Console.WriteLine($"Setting room temperature to {temperature}°C")
End Sub
Sub Main()
Try
Dim currentTemperature = 60
SetRoomTemperature(currentTemperature)
Catch ex As ArgumentOutOfRangeException
Console.WriteLine(ex.Message)
End Try
End Sub
End Module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment