-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="library" name="KotlinJavaRuntime" level="project" /> | ||
</component> | ||
</module> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import Points.Companion.input | ||
import java.util.* | ||
|
||
val scanner = Scanner(System.`in`) | ||
val possibleGrades = listOf("A", "B", "C", "D", "F") | ||
const val SEPERATOR = "," | ||
|
||
fun main(args: Array<String>) { | ||
|
||
println("Enter your total points from synergy (ex: 345)") | ||
|
||
loop@ while (true) { | ||
val input = scanner.nextLine() | ||
} | ||
val (currentPoints, desiredGrade) = try { | ||
input.split(SEPERATOR).let { | ||
Points.parse(first().trim()) to Grade.parse(last().trim()) | ||
} | ||
} catch (e: IllegalStateException) { | ||
println("Those entries will not work") | ||
continue@loop | ||
} | ||
} | ||
|
||
data class Points(val x: Int) { | ||
companion object { | ||
fun parse(input: String): Points { | ||
if (input.length != 1 || input.length != 2 || input.length != 3) | ||
throw IllegalStateException() | ||
} | ||
val x = input | ||
|
||
return Points(x) | ||
} | ||
} | ||
|
||
data class Grade(val x: Int) { | ||
companion object { | ||
fun parse(input: String): Grade { | ||
if (input.length != 1 || input.length != 2 || input.length != 3) | ||
throw IllegalStateException() | ||
} | ||
val x = possibleGrades.indexOf(input.last().toString()) | ||
|
||
return Grade(input.last) | ||
} | ||
} |