Skip to content

Lesson8#6

Open
pertsevpv wants to merge 3 commits intomasterfrom
lesson8
Open

Lesson8#6
pertsevpv wants to merge 3 commits intomasterfrom
lesson8

Conversation

@pertsevpv
Copy link
Copy Markdown
Owner

No description provided.


import kotlinx.coroutines.*

fun main() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

запусти несколько раз и получишь ошибку
Index -2 out of bounds for length 4


import kotlinx.coroutines.*

fun main() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

запусти несколько раз и получишь ошибку
Index -2 out of bounds for length 4

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

найди что вызывает такую ошибку) и потом и пометь комменатрием

Comment thread src/main/kotlin/task1/WeatherService.kt Outdated
)

val time: String = LocalDateTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss"))
val weather: String = possibleWeather[time.hashCode() % 4]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

кажется это класс про ткущее время) что у нас тут погода забыла?

Comment thread src/main/kotlin/task1/WeatherService.kt Outdated
val humidity: Int = time.hashCode() % 100 + 1
}

class TimeService {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Разнеси в разные классы

Comment thread src/main/kotlin/task2/KeyGenerator.kt Outdated

fun generateKey(): String {
val block: Array<CharArray> = Array(3) { "00000".toCharArray() }
for (i in block.indices) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

попробуй тут block.forEachIndexed

Comment thread src/main/kotlin/task2/KeyGenerator.kt Outdated
fun generateKey(): String {
val block: Array<CharArray> = Array(3) { "00000".toCharArray() }
for (i in block.indices) {
for (c in 0 until 5) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

что за magicNumber

Comment thread src/main/kotlin/task2/KeyGenerator.kt Outdated
}
}

fun main() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

кажется это что-то тестовое?

Comment thread src/main/kotlin/task2/Main.kt Outdated
}

suspend fun CoroutineScope.generate() = produce{
while (true) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

давай какое то условие все таки

Comment thread src/main/kotlin/task1/Main.kt Outdated
@@ -0,0 +1,28 @@
package task1

import kotlinx.coroutines.*
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

так лучше не импортировать

Comment thread src/main/kotlin/task2/Main.kt Outdated
val iter = generate().iterator()
while (iter.hasNext()) {
println(iter.next())
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

producer стоит закрыть cancel()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants