Last active
November 30, 2020 12:30
-
-
Save lunandd/acc21ed2170f4fca242b4a53caa76836 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package com.pavlos.efstathiou.seasons | |
/******************** | |
How to run: | |
Prerequisites: Have Java installed and the Kotlin compiler | |
First, execute this command: kotlinc seasons.kt -include-runtime -d seasons.jar | |
Then this: java -jar seasons.jar | |
********************/ | |
fun readInts() = readLine()!!.split(' ').map { it.toInt() } // Stolen from https://stackoverflow.com/questions/41283393/reading-console-input-in-kotlin | |
fun main() { | |
println("Enter a month by it's order and I will give you the season that it's in") | |
// var month : Int? = 12 // val month : Int? = null | |
var (month) = readInts() // Only accepts Integers | |
if (month !is Int) println("Are you that dumb I'm asking for an Int is it that difficult to enter an Int") | |
when (month) { | |
12, 1, 2-> println("Winter") | |
in 3..5 -> println("Spring") | |
in 6..8 -> println("Summer") | |
in 9..11 -> println("Autumn") | |
else -> println("Are you serious?") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment