Card game simulator

  • Type of project: Console application
  • Role: Developer
  • Languages & tools: C#, .NET
  • Published: 11/06/2019


This project was an assignment in a university course called “Object-oriented programming”. The task was to design a console application in C# that simulated the classic card game Twenty-One (similar to Black Jack) and outputted the response to the console. The game should not contain any user interaction, instead, the different “players” should have programmable behavior using an algorithm that lets them have individual strategies for playing the game.

Under the hood

The application is written in C#, on the .NET Core, using an object-oriented programming style. The main file (program.cs) instantiates the objects needed and then starts the game. The different classes used in this application is illustrated in the class diagram below.

The classes are simply instantiated as objects in the Program.cs file and are then run using the Game.Play() method, as illustrated in the source code below.

class Program
        static void Main(string[] args)
            // Sets encoding to UTF8 to allow the use of unicode characters.
            Console.OutputEncoding = System.Text.Encoding.UTF8;

            // Instantiates the objects necessary to play a game.
            PlayTable table = new PlayTable();
            Dealer dealer = new Dealer("Mickey Sharp-Eyes", 17, table);
            Player playerOne = new Player("Stacey the Snake", 16, table);
            Player playerTwo = new Player("Joey Spades", 15, table);
            Player playerThree = new Player("Shelly Shark", 8, table);
            Player playerFour = new Player("Eric McBigmoney", 21, table);
            Player playerFive = new Player("Davey Dontgetthegame", 1, table);

            Game gameOne = new Game(table, dealer, playerOne, playerTwo, playerThree, playerFour, playerFive);
Visit GitHub repository