Score Calculations & GUI Updates

Sunday, June 21, 2009 20:50
SOS Second GUI

SOS Second GUI

I am very happy with my progress so far.  Especially how I have been able to overcome obstacles along the way, in order to get to the point in my program that I am at now.  Last night I was up until 1AM working on getting some of the underlying logic to work with the GUI display.

The following is a summary of my progress this week:

  • Board:
    • added methods isEmty, getCol, getRow, checkTopBottomDiag, checkBottomTopDiag
    • changed mehtod checkForSOS to private since only needs to be called from local method setSquare, every time a play is made to see if they scored.
    • added variable sosFormed
    • added method getSOSFormed
  • BoardView:
    • method setSquareText changed to private
  • MenuBar:
    • added variables ABOUT, board, EXIT, INSTRUCTIONS, NEW_GAME, scoreCard
  • Options:
    • now observable
    • changed constructor to private
    • added getInstance, updateCurrPlayer, getCurrPlayer & getCurrChoice, statusChanged methods
    • changed setCurrPlayer to setCurrChoice
    • added choice variable
    • added variable currPlayer
  • WinnerView:
    • added variable board
  • removed OptionsView as an Observer
  • removed Options as Observable
  • created TurnView

I created the TurnView in-order to display whose turn it is based on a variable set in Board by storing the number of SOSs formed on each play.  I considered
just displaying whose turn it was as part of ScoreCardView, however, it is logically separate so I split the two in my program.  TurnView gets the variable sosFormed set in the Board class and then displays the appropriate message to the GUI based on the integer returned (ie: if it is > 0 then it is still the same persons turn, otherwise if it is 0 it is the next persons turn).

I forgot to add the ActionListeners to OptionsView, which is why other things, ie: S or O, was not displaying properly in the GUI, but that has been fixed. I also figured out how to use GridBagConstraints in my GUI, so I was able to layout OptionsView and especially PlayerView that I have been having so much trouble getting to work.  I then looked into why BoardView was not registering anything on clicks, which was because of my use of mouse listener; for mouse clicked method call I was using MouseClicked instead of overriding mouseClicked (note that it is lower case m and I was using capital m, it’s all in the small details sometimes).

In the back-end portion I have vertical and horizontal checks for an S-O-S sequence working and now just have to work on the diagonal calculations, which I am going to break into two functions, one for calculating going top to bottom and the other going bottom to top.

Next time I will provide a screenshot of my updated UML diagram to reflect the weeks past update along with any potential updates between now and the next post.

You can leave a response, or trackback from your own site.

Leave a Reply