Last active
September 6, 2024 01:36
-
-
Save y121516/e67906c40d5dc3fd3acd7496581f797b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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