"Correct" OOP

L

Luc The Perverse

I haven't actually written this yet, I'm just making some plans. This will
be my second or third "real" project in Java (I don't count tutorials,
experiments, etc.)

Where I get confused is where to put the intelligence, where to put the
drawing algorithms.

CCheckersStyleGameBoard inherits CGameBoardStyle
CChessGame inherits CGameManager
CChessPiece inherits CPiece

(Same thing for COthelloStyleGameBoard, CPenteGame, CPentePiece.)

Obviously the GameManager is going to create the CGameBoardStyle and give it
parameters, Black And White Squares 8 by 8. It is going to create the
CChessPiece objects and "place" them on the board somehow.

The CGameBoardStyle derived class is going to draw itself, and based on
coordinated determine the size and location of the pieces to be placed on
the board. Abstract function CPiece.Draw will be called for each piece,
with size and location information passed from the calling CGameBoardStyle
class. (I feel semi confident about this.)

Now I read that Java doesn't support multiple inheritance. Does this mean a
class cannot be derived from both JPanel and CGameBoardStyle? Or is this
where the "implements" keyword comes into place. (If so it would seem Java
~does~ support some form of multiple inheritance, but only one class can
contain functions which are not purely virtual.)

Well that is my plan - any advice is welcome :)
 
R

Roedy Green

Now I read that Java doesn't support multiple inheritance. Does this mean a
class cannot be derived from both JPanel and CGameBoardStyle? Or is this
where the "implements" keyword comes into place. (If so it would seem Java
~does~ support some form of multiple inheritance, but only one class can
contain functions which are not purely virtual.)

see http://mindprod.com/jgloss/multipleinheritance.html

Just make sure you don't muddle in one class the code to draw a pawn
to do logic about pawn move abilities etc.

Make sure you understand the Model/View/Controller design pattern
before you launch into this project. It will be a very good thing if
you can nicely separate your design logic.

http://mindprod.com/jgloss/designpatterns.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,888
Messages
2,569,964
Members
46,293
Latest member
BonnieHamb

Latest Threads

Top