JavaRush
AI Academy
new
Promotion
Learning
Courses
Tasks
Quizzes
Games
Help
Schedule of nudges
Internship
Community
Users
Forum
Chat
Articles
Success stories
Activities
Reviews
Subscriptions
Light theme

Lectures

  • Reviews
  • About us
  • CS50
Start
Start learning
Start learning
  • My progress
  • Courses
  • Quest map
  • Lectures
  • Game rules and state

    Kotlin SELF
    15 level,0 lecture
    We formalize the “rules” of the “Guess the Number” game as a model: what counts as an attempt, when the game ends, and how to handle invalid input. We separate settings and state using val/ var, introduce invariants and early checks via require(...), express rules as functions ( validateGameSettings, isInRange), and agree on where exactly attempt ++ lives. At the end, we outline the scenario skeleton and review typical mistakes.
    Open
  • Generating a secret with Random: range boundaries and the “off-by-one” error

    Kotlin SELF
    15 level,1 lecture
    We break down how to fairly generate a secret number in Kotlin using kotlin.random.Random: the Random.nextInt( from, until) contract, why the upper bound is excluded, where the “off-by-one” error comes from, and how to avoid it with the max + 1 formula. We write the generateSecret() function, add require for fail-fast, do a quick boundary check, and discuss nuances: nextInt(range) and seed for reproducible debugging.
    Open
  • Decomposition into functions: input, comparison, messages, and contracts

    Kotlin SELF
    15 level,2 lecture
    We break down how to turn a “wall of code” in main() into a set of clear functions: move input into readGuessOrNull() with result type Int ?, isolate pure logic in compareGuess(), assemble human-readable hints via hintText(), and formulate contracts (“input/output/side effects/error”) so that null and toIntOrNull() work for you, not against you.
    Open
  • Main attempts loop: robust input, hints, and the final result

    Kotlin SELF
    15 level,3 lecture
    We break down the “heartbeat” of a Kotlin guessing game: how to build an attempts loop using while with an attempt counter, why the condition attempt <= maxAttempts reads more honestly, how to integrate robust input via readGuessOrNull and Int ?, where continue and break fit, and how to avoid off-by-one bugs caused by putting attempt ++ in the wrong place. At the end — a single main () and an execution-flow diagram.
    Open
  • Behavior scenarios and debugging: finding mistakes in attempts and branching

    Kotlin SELF
    15 level,4 lecture
    We break down how to turn “kinda works” into reproducible behavior: we build scenarios (input, boundaries, win/lose), lock down randomness via debug mode, add targeted println logs, catch “off-by-one” issues around attempt ++ and <= conditions, verify branching via when, add safety checks with require/ check, and use the basic debugger in IntelliJ IDEA (breakpoints, stepping, value inspection).
    Open
Learn
  • Registration
  • Java course
  • Help with tasks
  • Pricing
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Success stories
  • Activities
Company
  • About us
  • Contacts
  • Reviews
  • FAQ
  • Support
JavaRushJavaRush — is an interactive online course for learning Java programming from scratch. It contains 1200 practical tasks with one-click solution checking, the necessary minimum of theory on Java basics, and motivating features that help you complete the course: games, quizzes, interesting projects and articles on effective learning and the career of a Java developer.
Follow us
Язык интерфейса
Русский
English
Українська
"Programmers are not born" © 2026 JavaRush
MastercardVisa
"Programmers are not born" © 2026 JavaRush