Alexandre P. Levasseur
See other posts from Programmers
or by Alexandre P. Levasseur
Published on 2013-11-05T02:40:43Z Indexed on 2013/11/05 4:12 UTC
Read the original article Hit count: 324
I am trying to build a very simple console-based game with a focus on using OOP instead of procedural programming because I intend to build up on that code for more complex projects.
I am wondering if there is a design pattern that nicely handles this use case:
- There is a
Playerclass with a
MakeMove()method interacting with the board game.
MakeMove() method has to somehow get the user input yet I do not want to code it into the
Player class as this would reduce cohesion and augment coupling.
I was thinking of maybe having some controller class handle the sequence of events and thus the calls to keyboard input. However, that controller class would need to be able to handle differently the subclasses of
Player (e.g. the
AI class does not require keyboard input).
© Programmers or respective owner