output functions have been fixed

This commit is contained in:
2026-09-14 11:45:58 +03:00
parent fe64caef82
commit 4dc6c0045f
+11 -6
View File
@@ -1,3 +1,5 @@
import kotlin.collections.firstOrNull
// Класс для храниения звезд
data class Star (val identifier: Int,
val constellation: Int,
@@ -54,13 +56,15 @@ fun printConstellationInfo(constellation: Constellation){
}
fun getConstellation(): String{
println("Введите созвездие:")
val constellationsList = constellations.map { it.name }
var constellationName: String = readln().lowercase().replaceFirstChar { it.uppercase() }
while (true) {
if (constellationName in constellationsList){
if (constellations.firstOrNull{it.name == constellationName} != null){
break
}
println("Список созвездий: ${constellationsList.joinToString(", ")}")
print("Список созвездий: ")
constellations.forEach { print(it.name) }
println()
constellationName = readln().lowercase().replaceFirstChar { it.uppercase() }
}
@@ -224,13 +228,14 @@ fun main(){
println("Введите звезду:")
// Находим id созвездия
val constellationId: Int? = (constellations.firstOrNull {it.name == constellationName})?.identifier
val starsList = stars.filter{it.constellation == constellationId }.map{it.name}
var starName: String = readln().lowercase().replaceFirstChar { it.uppercase() }
while (true) {
if (starName in starsList){
if (stars.firstOrNull{it.name == starName && it.constellation == constellationId} != null){
break
}
println("Список звезд: ${starsList.joinToString(", ")}")
println("Список звезд: ")
stars.forEach { print(it.name + " ") }
println()
starName = readln().lowercase().replaceFirstChar { it.uppercase() }