I am going to create a class Player and AI Players (AIBasicPlayer, AINormalPlayer and AIHardPlayer) for my card game (gin rummy). What would be the best OOP approach or design pattern for creating these classes? I tested some of the open source card games and compared their approaches, the following approaches I have compiled:
***Classes** 1. player class only public class player{ } public class AIPlayer{ } 2. base class player public abstract class player{ } public class HumanPlayer extends player{ } public class APlayer extends player{ } 3. interface player public interface IPlayer{ } public class Player implements IPlayer{} public class AIPlayer implements IPlayer{} *** Methods** takeTurn() doDiscard() doDraw()
I understand the use of the above codes, but I could not decide which one to apply or implement. I am new to OOP or design pattern, and your advice and sample code will be of great help.
source share