How docesforg/kursovay-ygadai-chislo- works
Project type and purpose
• This is a single-form desktop GUI application built with C++Builder (Borland/Embarcadero VCL).
• It implements the classic “Guess the Number” game: one player enters a secret number, the other makes guesses, and the app provides positional hints, tracks attempts, enforces limits, and logs results.
File structure
• Top-level build files: Project2.bpr (project file), Project2.cpp (auto-generated main), Project2.res, Project2.obj, Project2.exe.
• Unit1.*: the form definition and implementation (Unit1.dfm holds the VCL form, Unit1.cpp / Unit1.h contain event handlers and game logic).
• No frontend/backend split or external services—everything lives in one process.
Main components
a. UI Layer (Form1)
• Input fields and buttons for “set secret” and “make guess”
• Areas for hints, previous guesses, error messages, turn count
b. Game Engine (Business Logic)
• Secret-number storage
• Guess validation (range 0–1000, digit count ≤4, numeric only)
• Turn counter (max 10 turns)
• Hint generator (calculates correct digit positions)
• Error/validation routines
c. Session Manager
• Role selection (setter vs. guesser)
• State transitions (waiting for secret → guessing → game end)
d. Persistence / File Writer
• On game end (win/lose), write timestamped record to output.txt: secret, guesses, turn count, date/time
e. Auxiliary
• Error dialog service (pop-ups for invalid input)
Relationships and data flows
• User → UI Layer: clicks buttons and types numbers
• UI Layer → Game Engine: invokes validation and hint calculation on each guess
• Game Engine → UI Layer: returns hint strings, updates turn count, signals win/lose
• UI Layer → Session Manager: updates game state and role switching
• On game end: UI Layer / Session Manager → File Writer: dispatch a write-record operation
Architectural patterns and principles
• Lightweight MVC/MVP flavor:
• View (VCL Form) handles rendering and event capture
• Controller/Presenter (in Unit1.cpp) orchestrates validation and business rules
• Model (game state variables, guess history) lives in memory
• Single cohesive module—no microservices or external APIs
• Separation of concerns: UI, validation, core logic, and persistence each in distinct logical units
Relevant technologies
• Embarcadero C++Builder / Borland VCL framework
• Windows native dialogs and controls
• Standard C++ file I/O for output.txt