By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,874 Members | 1,028 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,874 IT Pros & Developers. It's quick & easy.

cross word puzzle cont 2dn part

P: 3
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
Share this question for a faster answer!
Share on Google+

Post your reply

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