Overview

Tic Tac Toe is a well-known game that almost anyone can play. Two players place their X's and Os on a 3x3 grid in hopes of aligning three of their own in a row. The game is over when there are three-in-arow/column/diagonal of either symbol or when all open game spaces have been occupied.

Model View Viewmodel (MVVM) is the name of a popular software architectural pattern that separates the graphical user interface (the view) and the back-end business logic (the model). The viewmodel is the facilitator between the two, exposing the model in a way such that its objects are easily managed and presented on the view. This also makes automated testing much easier.

In this take-home assignment, you will be asked to take an existing .NET Core implementation of two-player Tic-Tac-Toe and refactor it to use a MVVM pattern. To spice things up, you will also be asked to expand the implementation to allow three-players and a 4x4 grid.

Requirements

  • Windows OS
  • .Net Core 3.1 - https://dotnet.microsoft.com/download/dotnet/3.1
  • An IDE such as Visual Studio or Visual Studio Code

Instructions

  • Getting started
    • Feel free to use any resources that you feel are necessary, e.g. Google, StackOverflow, etc.
    • The suggested time frame to set aside for this project is 2-3 hours.
    • Open the provided TicTacToe solution file and perform a full build.
    • Run the game and experiment with it to get a general sense of current behavior.
    • This project uses C#/.NET Core and employs WPF (Windows Presentation Framework) code.
  • Tic Tac Toe is currently implemented using a pure "view-only" approach. You will need to examine this code and determine how to refactor it to utilize a MVVM approach. In considering your design for utilizing a MVVM pattern, remember that we would like to expand the game to three-players on a 4x4 grid.
  • Previously, the code of TicTacToe was not exposed in such a way that automated testing was possible. Now that you've refactored the game using a MVVM pattern, it is now possible to test newly exposed portions of the implementation. Write any unit tests that you deem necessary.
  • Please feel free to add your unique style to this project. This can be colors, pictures, or a better UI.

Some hints are as follows:

  • "MainWindow.xaml" is the View.
  • The View has a file "behind" it called the code-behind, called MainWindow.xaml.cs.
  • You will need to create your Model and ViewModel.
  • You will need to establish the association between View and ViewModel using the DataContext.
  • Bindings are an essential part of MVVM. Consider using the INotifyPropertyChanged interface.
  • For a third player, you'll need to invent a third symbol to use; e.g. not "x" or o.
  • Inside the TicTacToe.Test project, there is an existing file named UnitTest1.cs. This file can be used as a skeleton for writing tests (using the MSTests framework).
  • The Model and ViewModel portions of the implementation can be tested. The View still cannot be tested, but fortunately, if refactored properly, it should no longer have any code logic that requires testing.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.