• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • 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

 
Sheriff
Posts: 27235
87
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
Sheriff
Posts: 27235
87
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.
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic