473,768 Members | 2,322 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cross word puzzle cont 2dn part

3 New Member
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.JOp tionPane;

import java.util.Array List;

import java.util.Rando m;

public class CrossWordPuzzle Tester {

/**
* @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<Strin g> RandomWordList = new ArrayList<Strin g>();

ArrayList<Strin g> RandomMeaningLi st = new ArrayList<Strin g>();

//Llenando las listas de palabras aleatorias

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

RandomWordList. add("adios");
RandomMeaningLi st.add("Despedi da");

RandomWordList. add("bienvenido ");
RandomMeaningLi st.add("Recibim iento");

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

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

RandomWordList. add("otros");
RandomMeaningLi st.add("Los demas");

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

RandomWordList. add("casa");
RandomMeaningLi st.add("Hogar (Techo)");

RandomWordList. add("bote");
RandomMeaningLi st.add("Transpo rtacion acuatica");

RandomWordList. add("avion");
RandomMeaningLi st.add("Transpo rtacion 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.sho wOptionDialog(n ull, message, "CrossWordPuzzl e Tester - Welcome!", 0, 1, null, options, 0);

if (choice == 0)
{
int enter = JOptionPane.sho wOptionDialog(n ull, message2, "CrossWordPuzzl e Tester - Add Word!", 0, 1, null, enterWord, 0);

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

else if (enter == 2)
{
int index = randomNum.nextI nt(RandomWordLi st.size());

String word = RandomWordList. get(index);

String meaning = RandomMeaningLi st.get(index);

RandomMeaningLi st.remove(index );

RandomWordList. remove(index);

puzzle.addWord( word, meaning);
}

else
{

}
}

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

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

else
{
break;
}
}
while(puzzle.nu mberOfWords()<1 0);

do
{
int choice = JOptionPane.sho wOptionDialog(n ull, message, "CrossWordPuzzl e Tester - Welcome!", 0, 1, null, options, 0);

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

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

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

else
{
break;
}
}
while (exit);

puzzle.generate ();

do
{
int choice = JOptionPane.sho wOptionDialog(n ull, message, "CrossWordPuzzl e Tester - Welcome!", 0, 1, null, options, 0);

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

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

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

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

exit = false;
}

else
{
break;
}
}
while(exit);

puzzle.displayS ol();

}



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

e mail exvb@yahoo.com/ exvazquez@hotma il.com
Oct 22 '06 #1
0 2024

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

Similar topics

1
2110
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
2182
by: gelbeiche | last post by:
Is ( cont.begin() == cont.end() ) essentially equivalent to writing ( cont.empty() ) for a STL container ?
29
1862
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 switch-case c. you can use pointers only d. you cannot use any of the loops either. e. you cannot use in it any library function
1
13104
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 the other....how i can fix this the program look like this import java.util.ArrayList; import java.util.Random;
2
5098
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, the string at the beginning explains what it does: '''A script for MS Word which does the following: 1) Assigns all Hebrew italic characters "Italic" character style. 2) Assigns all Hebrew bold characters "Bold" character style. 2) Assign all...
5
4470
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 is to solve jigsaw puzzles using the computer. The jigsaw puzzle here is a square of dimension d (a puzzle with d^2 pieces) and the jigsaw pieces (all same dimensions) are of dimensions H x W (Which means the pieces have ‘H’ rows of ‘W’...
8
5535
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
19992
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 get the tiles in order, 1 through 15, from left to right, top to bottom, by just sliding tiles into the empty square. In this configuration, the goal would be to get the 14 and 15 to switch places, without affecting any of the other squares. Your...
0
10175
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10017
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9843
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8840
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6656
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5425
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3932
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3534
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2808
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.