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,
|
data class Star (val identifier: Int,
|
||||||
val constellation: Int,
|
val constellation: Int,
|
||||||
@@ -54,13 +56,15 @@ fun printConstellationInfo(constellation: Constellation){
|
|||||||
}
|
}
|
||||||
fun getConstellation(): String{
|
fun getConstellation(): String{
|
||||||
println("Введите созвездие:")
|
println("Введите созвездие:")
|
||||||
val constellationsList = constellations.map { it.name }
|
|
||||||
var constellationName: String = readln().lowercase().replaceFirstChar { it.uppercase() }
|
var constellationName: String = readln().lowercase().replaceFirstChar { it.uppercase() }
|
||||||
while (true) {
|
while (true) {
|
||||||
if (constellationName in constellationsList){
|
|
||||||
|
if (constellations.firstOrNull{it.name == constellationName} != null){
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
println("Список созвездий: ${constellationsList.joinToString(", ")}")
|
print("Список созвездий: ")
|
||||||
|
constellations.forEach { print(it.name) }
|
||||||
|
println()
|
||||||
constellationName = readln().lowercase().replaceFirstChar { it.uppercase() }
|
constellationName = readln().lowercase().replaceFirstChar { it.uppercase() }
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -224,13 +228,14 @@ fun main(){
|
|||||||
println("Введите звезду:")
|
println("Введите звезду:")
|
||||||
// Находим id созвездия
|
// Находим id созвездия
|
||||||
val constellationId: Int? = (constellations.firstOrNull {it.name == constellationName})?.identifier
|
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() }
|
var starName: String = readln().lowercase().replaceFirstChar { it.uppercase() }
|
||||||
while (true) {
|
while (true) {
|
||||||
if (starName in starsList){
|
if (stars.firstOrNull{it.name == starName && it.constellation == constellationId} != null){
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
println("Список звезд: ${starsList.joinToString(", ")}")
|
println("Список звезд: ")
|
||||||
|
stars.forEach { print(it.name + " ") }
|
||||||
|
println()
|
||||||
|
|
||||||
starName = readln().lowercase().replaceFirstChar { it.uppercase() }
|
starName = readln().lowercase().replaceFirstChar { it.uppercase() }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user