Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Java (http://www.programmingforums.org/forum17.html)
-   -   Generating a crossword puzzle (http://www.programmingforums.org/showthread.php?t=13978)

Wizard1988 Sep 16th, 2007 10:39 PM

Generating a crossword puzzle
 
I am working on a crossword puzzle game. I have to read in a file with the clues, the answers and the direction (horizontal | vertical). I have no problem doing that.. What I am having a hard time with is generating the actuall crossword diagram. What would be the best way to generate the crossword board?

So far I am able to create the row columns for the user to select which word they are trying to solve

:

    1 2 3 4 5
    _ _ _ _ _
A |
B |
C |
D |
E | _ _ _ _ _

What I need to do is have the words displayed as:

:

    1 2 3 4 5
    _ _ _ _ _
A | t r u e
B | o 
C | r 
D |
    _ _ _ _ _

Now I am stuck on aligning the words within the "Board". What would be the best way to figure out and keep track of how the words interesct and where they should be displayed.

I know that first I have to find the longest words horizontally and vertically and that is how I can figure out the width and height of the board.

Im looking forward to any ideas you guys have, oh and I am not allowed to use arrays...

ReggaetonKing Sep 16th, 2007 11:01 PM

This might be a little help to you. Java has System.out.printf() method. It works the same way as C and C++'s printf() function. You could align the chars perfectly with the 'Board'. I don't know the exact way to do it but I've done it before when I made a checkout program in C. I can not find the source code where I've done it so I can't really help you there. :(

BTW, What the hell is up with your teacher and arrays? Does he/she really hate them that much?

Wizard1988 Sep 16th, 2007 11:15 PM

Aligning the characters isn't the problem.... I have a list of words which some should go horizontally and some should go vertically. I am not sure about how to figure out where the words cross each other and what their positions should be.

LOL, We haven't covered arrays in class yet.. thats why.

lectricpharaoh Sep 17th, 2007 2:53 AM

Quote:

Originally Posted by Wizard1988
LOL, We haven't covered arrays in class yet.. thats why.

Your teacher sounds like an idiot. Not only does he forbid you from getting ahead of what he's covered, but he expects you to do something without the proper tools.


All times are GMT -5. The time now is 2:55 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC