Skip to content

Commit

Permalink
le fix Le fix :)
Browse files Browse the repository at this point in the history
  • Loading branch information
Z-100 committed Jan 25, 2024
1 parent d513ad8 commit d58ae43
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions soemi-woeb/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ function App() {
}

export function Planet({ planet }) {
const {name, img} = planet
const {name, image} = planet

return (
<>
<h1>Name: {name}</h1>
<img src={img} alt="Star Wars Planet"/>
<img src={image} alt="Star Wars Planet"/>
</>
);
}
Expand Down
8 changes: 7 additions & 1 deletion soemi-woers/src/main/kotlin/ch/soemiweather/Application.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import java.io.FileNotFoundException
import java.io.InputStreamReader
import java.nio.charset.StandardCharsets.UTF_8

const val MAX_TEMP = 55
const val MIN_TEMP = -90

fun main() {
embeddedServer(Netty, port = 8089) {
install(CORS) {
Expand Down Expand Up @@ -58,7 +61,10 @@ fun getPlanetForTemp(temp: Double): Planet {
.map { it.split(";") }
.map { Planet(Integer.parseInt(it[0]), it[1], it[2]) }

return planets.first { it.temp == (5 * Math.round(temp / 5)).toInt() }
val planet = planets.firstOrNull { it.temp == 5 * Math.round(temp / 5).toInt() }
?: planets.first { if (temp > 0) it.temp == MAX_TEMP else it.temp == MIN_TEMP }

return planet
}

fun getFileContent(uri: String): List<String> {
Expand Down

0 comments on commit d58ae43

Please sign in to comment.