output functions have been fixed
This commit is contained in:
+11
-6
@@ -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() }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user