Tweaks and First Run

Sunday, June 14, 2009 16:31
SOS UML Diagram v3

SOS UML Diagram v3

I have made some more progress on my program this week, although I would have made some more progress on my program this week, although I did not get to spend as much time as I would have liked because of things I had to do including capturing home videos.

At this point, although it can easily change as I discover new tweaks that are required, I am tentatively done the classes Choice, GridBagConstraintsExt, Move, MoveHistory, Options, Player, Position, ScoreCard, and UndoView.  I thought I was going to be able to include ScoreCardView as well; however, I am getting an IllegalStateException.  I believe this has something to do with how I am laying out or grouping the components.

The following is a summary of my modifications:

  • added class ScoreCard (Singleton)
  • added class Options (Singleton)
  • ScoreCardView
    • added functions createComponents(), layoutComponents()
    • removed variable update
    • removed function getCurrPlayer()
    • renamed p(One/Two)ScoreLabel to p(One/Two)Score
    • added variable scoreCard
    • added variable constants PLAYER_ONE and PLAYER_TWO storing default player names
  • Board:
    • added isFull() so can check if board is full (game done)
    • added variable occupiedSquares so can keep track of how many squares are occupied, used in isFull calculation
  • OptionsView:
    • added variable constants OPTION_O and OPTION_S
    • removed variable done
  • Updated classification of classes (ie: Observer(able), Singleton)

I broke up ScoreCardView into ScoreCardView and ScoreCard and OptionsView into OptionsView and Options in order to separate the GUI from the underlying logic, which keeps things consistent across the rest of the program.  I am not entirely happy with my excessive use of the Singleton pattern, however, at this point I cannot seem to think of a better way of communicating between classes and I am also deep into the program.  I removed the note regarding the variable done because the variable is no longer part of my program.

I tried running the program for the first time, without winner view, and boy she ran head first into runtime errors.  This was partly caused because I forgot to make the getInstance methods static.  Managed to get it to run, so long as I did not include ScoreCardView, however, the only thing that actually displayed was a disabled undo button.  I think that is because my other views are not done yet, namely BoardView does not draw a grid yet, and OptionsView doesn’t place anything on the panel yet.

To fix the issue of how to use the IntroPanel creating another class which uses the CardLayout may be my answer, from what I have read .  This would involve making the PlayerView a JPanel which would contain everything it does now (minus the IntroView) and then making another class that would contain the PlayerView JPanel and the IntroPanel JPanel, and start button along with the main function and the new class would extend JFrame instead of PlayerView.  I have spent quite a bit of time last week playing with the CardLayout to familiarize myself with how it works.

I now have the classes organized into the following categories:

Observers:
-BoardView
-OptionsView
-ScoreCardView
-UndoView
-WinnerView
Observable:
-Board
-MoveHistory
-Options
-Player
Singelton:
-Board
-MoveHistory
-Options
-ScoreCard
Enumeration:
-Choice
You can leave a response, or trackback from your own site.

Leave a Reply