472,951 Members | 2,227 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,951 software developers and data experts.

cross word puzzle cont 2dn part

have a problem with a program that does not working properly...when the program run is suppose to generate a cross word puzzle , when the outcome show the letter of the words overlap one intop of the other....how i can fix this [

B]this run the random words for the program[/b]

import javax.swing.JOptionPane;

import java.util.ArrayList;

import java.util.Random;

public class CrossWordPuzzleTester {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
CrossWordPuzzle puzzle = new CrossWordPuzzle();

Random randomNum = new Random();

boolean exit = true;

ArrayList<String> RandomWordList = new ArrayList<String>();

ArrayList<String> RandomMeaningList = new ArrayList<String>();

//Llenando las listas de palabras aleatorias

RandomWordList.add("hola");
RandomMeaningList.add("Saludo regular entre personas");

RandomWordList.add("adios");
RandomMeaningList.add("Despedida");

RandomWordList.add("bienvenido");
RandomMeaningList.add("Recibimiento");

RandomWordList.add("tu");
RandomMeaningList.add("2da persona singular");

RandomWordList.add("yo");
RandomMeaningList.add("1ra persona singular");

RandomWordList.add("otros");
RandomMeaningList.add("Los demas");

RandomWordList.add("carro");
RandomMeaningList.add("4 ruedas y abundantes en Puerto Rico");

RandomWordList.add("casa");
RandomMeaningList.add("Hogar (Techo)");

RandomWordList.add("bote");
RandomMeaningList.add("Transportacion acuatica");

RandomWordList.add("avion");
RandomMeaningList.add("Transportacion aerea");

//Menu:

String message, message2;

message = "Please, enter any of the following: ";

message2 = "Do you want to add a word?";

String[] options = new String[3];
String[] enterWord = new String[3];

options[0] = "Add Word!";
options[1] = "Generate?";
options[2] = "Solution!!";

enterWord[0] = "Yes";
enterWord[1] = "No";
enterWord[2] = "Random Word";
do
{
int choice = JOptionPane.showOptionDialog(null, message, "CrossWordPuzzle Tester - Welcome!", 0, 1, null, options, 0);

if (choice == 0)
{
int enter = JOptionPane.showOptionDialog(null, message2, "CrossWordPuzzle Tester - Add Word!", 0, 1, null, enterWord, 0);

if (enter == 0)
{
String word = JOptionPane.showInputDialog("Please, enter any word that comes to mind: ");
String definition = JOptionPane.showInputDialog("Please, supply me with a short definition of the word you choose: ");
puzzle.addWord(word, definition);
}

else if (enter == 2)
{
int index = randomNum.nextInt(RandomWordList.size());

String word = RandomWordList.get(index);

String meaning = RandomMeaningList.get(index);

RandomMeaningList.remove(index);

RandomWordList.remove(index);

puzzle.addWord(word, meaning);
}

else
{

}
}

else if (choice == 1)
{
int num = 10 - puzzle.numberOfWords();
JOptionPane.showMessageDialog(null, "Please, enter " + num + " more words (Sorry for the trouble).");
}

else if (choice == 2)
{
JOptionPane.showMessageDialog(null, "You have not entered enough words... \nPlease, do so to continue.");
}

else
{
break;
}
}
while(puzzle.numberOfWords()<10);

do
{
int choice = JOptionPane.showOptionDialog(null, message, "CrossWordPuzzle Tester - Welcome!", 0, 1, null, options, 0);

if (choice == 0)
{
JOptionPane.showMessageDialog(null, "You have enter enough words, \nThank you very much.");
}

if (choice == 1)
{
exit = false;
}

if (choice == 2)
{
JOptionPane.showMessageDialog(null, "Please, generate the CrossWord \nPuzzle first.");
}

else
{
break;
}
}
while (exit);

puzzle.generate();

do
{
int choice = JOptionPane.showOptionDialog(null, message, "CrossWordPuzzle Tester - Welcome!", 0, 1, null, options, 0);

if (choice == 0)
{
JOptionPane.showMessageDialog(null, "You have enter enough words, \nThank you very much.");
}

if (choice == 1)
{
JOptionPane.showMessageDialog(null, "You have already generated the\nCrossWord Puzzle. Thank You.");
}

if (choice == 2)
{
JOptionPane.showMessageDialog(null, "Thank You for using this program.");

JOptionPane.showMessageDialog(null, "Press \'Ok\' and look for the CrossWord\non the console. Have a good day.");

exit = false;
}

else
{
break;
}
}
while(exit);

puzzle.displaySol();

}



help please I and new to programing and does not have more solution

e mail exvb@yahoo.com/ exvazquez@hotmail.com
Oct 22 '06 #1
0 1958

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: peteyjr | last post by:
Hi I have a asp page with a database connection where I need to export adresses into a MS Word Serial Letter. Is this possible and if how?? Any help is well appreciated Peter
5
by: gelbeiche | last post by:
Is ( cont.begin() == cont.end() ) essentially equivalent to writing ( cont.empty() ) for a STL container ?
29
by: RoSsIaCrIiLoIA | last post by:
write the function int readINT(FILE* fp); that read an int from fp and return it. given the following conditions a. Do not use arrays b. Do not use any comparison function like if/then or...
1
by: xavier vazquez | last post by:
I have a problem with a program that does not working properly...when the program run is suppose to generate a cross word puzzle , when the outcome show the letter of the words overlap one intop of...
2
by: Ola K | last post by:
Hi guys, I wrote a script that works *almost* perfectly, and this lack of perfection simply puzzles me. I simply cannot point the whys, so any help on it will be appreciated. I paste it all here,...
5
by: ashish0799 | last post by:
HI I M ASHISH I WANT ALGORYTHMUS OF THIS PROBLEM Jigsaw puzzles. You would have solved many in your childhood and many people still like it in their old ages also. Now what you have got to do...
8
by: Ciaran | last post by:
Hi has anyone got a function that can detect a user pressing a key that works cross browser? I just want to redirect my visitor if they hit escape ... you'd think it would be easy! Thanks, Ciarán
4
by: honey777 | last post by:
Problem: 15 Puzzle This is a common puzzle with a 4x4 playing space with 15 tiles, numbered 1 through 15. One "spot" is always left blank. Here is an example of the puzzle: The goal is to...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.