cross word puzzle cont 2dn part

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xavier vazquez
    New Member
    • Oct 2006
    • 3

    #1

    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.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
Working...