Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
evanmyersflow committed Nov 23, 2017
0 parents commit d3e7cb4
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .idea/dictionaries/Servant.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/libraries/KotlinJavaRuntime.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Chem-Final.iml
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>
47 changes: 47 additions & 0 deletions src/Calculator.kt
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)
}
}

0 comments on commit d3e7cb4

Please sign in to comment.