Description

Drag to rearrange sections
Rich Text Content

Basically, JavaChess went through three versions: one using standard out, one using Gridworld, and one using a more customized GUI. All three versions use the piece classes (an abstract Piece class with subclasses representing all six types of chess pieces) and the Board class (based on Gridworld's BoundedGrid class). The pieces are responsible for determining what moves they can make, and the Board is responsible for managing interactions between the pieces. In addition, the Gridworld version uses the ChessWorld class, which subclasses Gridworld's World class so that it responds to clicks. The general GUI version uses the ChessFrame class, which also responds to clicks and allows for a more chess-like visual display.

In terms of programming concepts, JavaChess relies on a knowledge of inheritance, data structures, and GUI-building.

  • Without inheritance, this project would have taken a few millenia instead of a week; being able to recycle code already written for Gridworld and swing was especially life-saving. Inheriting from the Piece class also meant that the Board was much easier to write because it could interact with the pieces without worrying about their implementation details.
  • The use of data structures (especially ArrayLists) was one of the more challenging aspects of this project, since each Piece had to manage and manipulate, say, ArrayLists of Location objects without violating the expectations of some other Piece. This included iterating through ArrayLists, adding/removing elements, and being sure not to modify the ArrayList while I was iterating through it.
  • In order to create the GUI, I had to learn more than I ever wanted to about java swing classes. Specifically, I had to find a good layout manager and event listener to work with the chess board, figure out what component classes were most appropriate, and look up how to load and paint gifs in a GUI. (And that Oracle's APIs/tutorials are somewhere between godly and divine.)
rich_text    
Drag to rearrange sections
Rich Text Content
rich_text    

Page Comments