• Post Reply Bookmark Topic Watch Topic
  • New Topic

Checkerboard w/ 64 squares  RSS feed

 
Ron Ingram
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello forum,

I'm working on an assignment requiring me to create a checkerboard with 64 squares. I've got three classes: A viewer, Checkerboard component, and a checkerboard which constructs the squares.

My attempt so far is to create 2 row methods in the CHeckerboard Class, one that starts a row off with a white square; the second starting with a black square

In the Checkerboard component class, I want to simply call each one four times changing the y coordinate so it lines each row up.

However, this doesn't seem to work. What am I doing wrong?

Viewer Class


Checkerboard Component Class:


Checkerboard Class
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
comment out your current CheckerBoardComponent class and replace with this to see what's happening



 
Ron Ingram
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. I see that the values are all being returned as 0. I hard-coded the values I'm trying to test and still renders the same.. I've included the code now with x replaced with the actual x value I'm looking for. Still prints out as all zeros

 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your Checkerboard constructor doesn't do anything. Passing it different values won't result in any differences in the Checkerboard objects you create.
 
Ron Ingram
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahh your right.. I wasn't using the arguments being passed..

I've fixed it and it works.. I've included the solution code for this thread's integrity:

Viewer:


Component Class:



Checkerboard class:
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You were on the right track, it was the debugging code you posted that made me want to look at the Checkerboard class and its constructor.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!