Although I made a separate class to make all the decisions as to whether or not a move is legal, the way I have the program set up, I still need to change a bunch of variables to pass into the methods from this rulebook class every time I try to make a move (I keep track of the pieces with several arrays, one that holds the actual jlabels and thus icons, one that holds which pieces are at which squares on the board, but stored in such a way that I can actually access the data for processing, and finally, one that holds the position of each piece (named based on original position) so that I can easily loop through all the pieces locations to do things like check and checkmate. As a consequence, in my main class, the method for handling when the board clicked is almost a thousand lines long, and as a consequence, is really hard to troubleshoot.
Jeanne Boyarsky wrote:It sounds like your program isn't object oriented...
Louis Lewis wrote:Maybe I just don't understand OOP design then. My impressioin of it was just that it was using classes methods and objects to break parts of a larger program into chunks and then finally to make the actual implimentation of all these methods via objects fairly readable/understandable in the main class.
Perhaps you guys could elaborate on what an object oriented chess program might be designed, at least in terms of checking move legality?
Louis Lewis wrote:Perhaps you guys could elaborate on what an object oriented chess program might be designed, at least in terms of checking move legality?
…that is the way to make progress in coding.
Winston Gutkowski wrote: . . . I've been thinking about this a bit since I posted, and . . .
Louis Lewis wrote:I understand the business of creating classes and objects analogous to real life, but I don't quite understand how this actually translates to displaying things that the user can see. For example, I don't think I would have a problem creating a class that stores information for a type of piece, and then creating an instance that represents a specific piece on the board, but I don't understand how the information stored in the object's class would be used to validate its move ( I don't really get where this code would actually go).
Louis Lewis wrote:Alright, thanks for all the help, I think I am going to get going on trying to rewrite this program in an object oriented fashion.