Author: Russell Reagan
Date: 02:22:40 07/23/02
Go up one level in this thread
On July 23, 2002 at 04:45:23, Bo Persson wrote: >Why don't you do it like > >squares[move.to()] = move.promotedPiece(); > >That looks pretty OOP to me :-) To remain OOPish we can't have parts of one object being dependent upon other objects. So the only solution that will work here is if I have a Square class that makes up the squares[] array, and then if move.promotedPiece() returns a Square object. That's basically the same as doing it the "fast" way in a non-OOP approach like: squares[move.to] = move.promotePiece; Here is a problem that I see though. How are you going to initialize that Square object that you return from promotedPiece()? I think you will have to do the if(pieceType == QUEEN) ... else if (pieceType == ROOK)... and so on somewhere down the line, because there is no way to initialize the Square object without doing that unless you allow it to be initialized by setting it's private data to an unsigned int that you pass it, which seems to be bordering on maintaining encapsulation. What do you think? Is that still acceptable OOP or should I continue searching for a better way? It seems that some things don't translate well to an object-oriented model. Russell
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.