tags:

views:

51

answers:

1

Hey,

So I'm working on a small TicTacToe application over the holidays to improve some of my skills. I have a two layered approach right now where there is a project for the presnetation and a project for the business end of the game.

My question is what is the best way for the State.cs class to tell the WinUI that we have had nine turns and there is no winner or to tell that yes there is a winner after each move?

The easiest thing I can think of would be to raise a custom event and have the WinUI listen for it?

My source is on Google Code. I've just checked it in so you can take a quick browse.

Classes of interest for this question would probably be state.cs and Form1.cs.

If you have any other suggestions for my code/design I'm all ears!!

CODE IS HERE

Cheers,

Mike

+1  A: 

You are trying to remove the UI logic from the Game logic, Yes?

Typically this would either be bound to the game iterface, or you could try using callbacks.

I would not recomend this for a single player game. If you wish to create an interactive gaming interface, that would make the feedbacks a little more complex, but you are thinking in th correct direction. Let the engine indicate when the UI needs to update events.

I would also recomend having a look at some of the old dogs (As the old saying goes, if you think you are the first to ask the QUESTION, think again)

c# tic tac toe game

astander
Ya you are assuming correct. So really events would be a decent idea.. Let the logic determine if there is a winner or if there are no more possible moves.. If this is correct that we will NOTIFY the UI to tell the user about the situation.
Mike