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.
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