473,379 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 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 1984

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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.