• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Checkerboard w/ 64 squares

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic