This is probably a Quick Question |
Quick question, with lots and lots of passionate religious wars rhetoric of what
The True Level of Abstraction Is The Holiest.
Simple questions usually aren't, but having differing opinions to grapple is instructive and helpful.
Personally I find the C++ Core Guideline Non-Rule about multiple class source files to be overly nitpicky and pedantic without any solid explanation of why it shouldn't be done.
I've seen experienced programmers advocate yes, giving very strong opinions for the separation, and other experienced programmers say nay with equal fervor.
Ultimately, you, the programmer will have to decide what makes sense to you. What makes it easier to write, test, debug and maintain solid C++ code.
With that all said, I would create an abstract base class that has two derived classes. One for the human player, another for the computer player.
Push as much similar code for either player up into the base class. Quick, off the cuff musing the only code I'd have in the derived classes is how the player chooses where to place their symbol. All other player related code resides in the ABC.
Going to a further level of abstraction I might consider creating a game board class that has uses the player classes as data members.
I'd put the player classes in one source with a header file, the game board in another, and if abstracted well
main()
might look like this:
1 2 3 4 5 6 7
|
#include "Gameboard.hpp"
#include "Player.hpp"
int main()
{
Gameboard game;
}
|
The classes, if coded well, will handle all the game initialization, player moves and cleanup on game termination.
This is simply my personal opinion for creating a simple game, others will have differing ideas of how to make it all work.