A console-based Tic-Tac-Toe game built with modern C# and .NET 9, featuring clean architecture, beautiful terminal UI with Spectre.Console, user authentication, and game history tracking.
- ๐ Description
- ๐ ๏ธ Technologies
- ๐ Project Structure
- โ๏ธ Installation
- ๐ Usage
- ๐ค Contribution
MyCourseWork is a classic Tic-Tac-Toe game implemented as a console application with a modern terminal interface. The project demonstrates clean architecture principles by separating concerns into distinct layers:
- Presentation Layer - Beautiful console UI powered by Spectre. Console
- Business Layer - Contains game logic and authentication services
- Data Layer - Manages data persistence with repository pattern
| Feature | Description |
|---|---|
| ๐ User Authentication | Register and login functionality with validation |
| ๐ฏ Play vs Bot | Challenge the AI opponent in Tic-Tac-Toe |
| ๐ Rating System | Track your performance with ELO-like rating (starts at 1000) |
| ๐ Game History | Record and view past games |
| ๐จ Beautiful UI | Interactive menus with Spectre.Console |
| ๐๏ธ Clean Architecture | Three-layer architecture with Dependency Injection |
| ๐ฅ User Management | List all registered users |
| Technology | Version | Description |
|---|---|---|
| C# | 12 | Primary programming language |
| .NET | 9.0 | Framework and runtime |
| Package | Version | Purpose |
|---|---|---|
Spectre.Console |
0.49.1 | Beautiful console UI components |
Spectre.Console.Cli |
0.49.1 | Command-line interface builder |
Microsoft.Extensions.DependencyInjection |
9.0.0 | Dependency Injection container |
CourseWork/
โโโ ๐ MyCourseWork/ # ๐ฅ๏ธ Presentation Layer (Console App)
โ โโโ ๐ Commands/ # Command pattern implementations
โ โโโ ๐ Extensions/ # DI extension methods
โ โโโ ๐ CommandManager.cs # Command dispatcher
โ โโโ ๐ GameFactory.cs # Game instance factory
โ โโโ ๐ GameLogic.cs # Core game mechanics (3x3 board)
โ โโโ ๐ ICommand.cs # Command interface
โ โโโ ๐ MyCourseWork.csproj # Project configuration
โ โโโ ๐ Program.cs # Application entry point & menu
โ
โโโ ๐ MyCourseWork. Business/ # ๐ผ Business Logic Layer
โ โโโ ๐ Service/ # Service implementations
โ โ โโโ ๐ AuthService.cs # Registration, login, password update
โ โ โโโ ๐ GameService.cs # Game recording logic
โ โโโ ๐ Extensions/ # DI extensions
โ โโโ ๐ IAuthService.cs # Auth service contract
โ โโโ ๐ IGameService. cs # Game service contract
โ โโโ ๐ MyCourseWork.Business.csproj
โ
โโโ ๐ MyCourseWork.Data/ # ๐พ Data Access Layer
โ โโโ ๐ Entity/ # Domain entities (User, GameRecord)
โ โโโ ๐ Interfaces/ # Repository contracts
โ โโโ ๐ InMemoryUserRepository.cs # In-memory user storage
โ โโโ ๐ InMemoryGameRepository.cs # In-memory game storage
โ โโโ ๐ MyCourseWorkDbContext.cs # Database context
โ โโโ ๐ MyCourseWork.Data.csproj
โ
โโโ ๐ MyCourseWork.sln # Solution file
โโโ ๐ . gitignore # Git ignore rules
โโโ ๐ README.md # This file
- . NET 9 SDK or later
-
Clone the repository
git clone https://github.com/kovalllllll/CourseWork.git cd CourseWork -
Restore dependencies
dotnet restore
-
Build the solution
dotnet build
dotnet run --project MyCourseWorkWhen you start the application, you'll see an interactive menu:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Menu: โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ > Register โ
โ Login โ
โ List Users โ
โ Exit โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
| Option | Description |
|---|---|
| Register | Create a new user account with username and password |
| Login | Authenticate and access game features |
| List Users | View all registered users and their ratings |
| Exit | Close the application |
- ๐ Register or login to your account
- ๐ฎ Start a new Tic-Tac-Toe game
- โ๏ธ Choose your symbol (
XorO) - ๐ Enter coordinates (0-2) for row and column to place your mark
- ๐ Try to get three in a row before the bot does!
- The board is a 3x3 grid
- Players take turns placing their symbol
- First to align 3 symbols horizontally, vertically, or diagonally wins
- If all cells are filled with no winner, it's a draw
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch
git checkout -b feature/amazing-feature
- Commit your changes
git commit -m 'Add some amazing feature' - Push to the branch
git push origin feature/amazing-feature
- Open a Pull Request
- โ Follow C# coding conventions and . NET best practices
- โ Write meaningful commit messages
- โ Add XML comments for public APIs
- โ Keep the clean architecture structure
- โ Update documentation as needed
- Add difficulty levels for the bot (Easy/Medium/Hard)
- Implement minimax algorithm for unbeatable AI
- Add multiplayer mode (player vs player)
- Persist data to a database (SQLite/PostgreSQL)
- Add unit tests
Made with โค๏ธ by @kovalllllll