Results 1 to 10 of 10
Like Tree3Likes
  • 3 Post By Fubarable

Thread: Java Help Needed to complete an assignment

  1. #1
    nishantvodoo is offline Member
    Join Date
    Jan 2012
    Posts
    6
    Rep Power
    0

    Default Java Help Needed to complete an assignment

    Guys i got an assignment for my computer class...its seems simple but considering the fact that i am new to this programming field i couldn't figure out how to do it.
    I am really counting on you guys..

    I am posting my code that i wrote and the question so please if anyone can help it will be appreciated..
    Version 1
    Create a project called Lingo1.java

    Lingo is a popular game show on the Game Show Network, with simple rules. Players are given the first letter of a randomly chosen 5-letter word, and must guess the remaining letters by guessing words. For each guess, any letters that are in the word and are in the correct position are circled. Any other letters that are in the word, but are in an incorrect position are boxed. Then the blanks are rewritten, with any circled letters included in the correct spots, and the player guesses again. If the player figures out the word within 6 guesses, they win. If they fail (or anytime they guess an invalid word) they lose.

    Version 2
    Create a project called Lingo2.java


    Modify version 1 to pick the starting word randomly from a large array of at least 50 strings which is initialized in the program source code, rather than inputing the word from a neutral player.

    Version 3
    Create a project called Lingo3.java


    Modify version 1 or 2 to use graphical output to show the sequence of guesses with correctly positioned letters shown in blue circles, and valid letters in incorrect positions shown in yellow squares. The entire sequence of guesses should be shown on a single screen.


    PS. I've put my code in a text file because we cannot upload java file...
    PLEASE HELP GUYS...
    IF YOU WRITE WITH A NEW CODE THEN THAT WILL ALSO BE ACCEPTED...
    Attached Thumbnails Attached Thumbnails Java Help Needed to complete an assignment-game-procedure.jpg  
    Attached Files Attached Files
    Last edited by nishantvodoo; 01-25-2012 at 06:41 AM.

  2. #2
    nishantvodoo is offline Member
    Join Date
    Jan 2012
    Posts
    6
    Rep Power
    0

    Default Re: Java Help Needed to complete an assignment

    Couldnt get my code posted so i am posting here in plain text.....


    import java.util.Scanner;
    import javax.swing.JOptionPane;
    public class Lingo1
    {
    public static void main(String[] args)
    {
    // Take Input from Player 1 for Player 2
    String player1_input = JOptionPane.showInputDialog(null,"Enter a 5- letter word: ","INPUT",JOptionPane.QUESTION_MESSAGE);
    // Make sure if its a Valid entry
    while (player1_input.length() != 5)
    {
    JOptionPane.showMessageDialog(null," Invalid input");
    player1_input = JOptionPane.showInputDialog(null,"Enter a 5- letter word: ","INPUT",JOptionPane.QUESTION_MESSAGE);
    }
    // Evaluate the input
    int returnvalue= evaluate(player1_input);
    if (returnvalue!=2)
    {
    JOptionPane.showMessageDialog(null, "YOU LOST" ,"SORRY", JOptionPane.INFORMATION_MESSAGE);
    }
    }
    // Method to evaluate the input
    public static int evaluate(String c)
    {
    // Conversion to Character Array
    char[] ch = c.toCharArray();
    // Declare the first and second message
    String message1=ch[0]+ "*";
    String message2="";

    for (int a=1; a<=6; a++)
    {
    String work= JOptionPane.showInputDialog(null,""+ message1 +"\n" + message2, "Guess #" + a, JOptionPane.QUESTION_MESSAGE);
    message1="";
    message2="";

    if (work.equalsIgnoreCase(c))
    {
    JOptionPane.showMessageDialog(null, "CORRECT! YOU WIN!" ," SUCCESS", JOptionPane.INFORMATION_MESSAGE);
    a= 7;
    return 2;
    }
    char[] th = work.toCharArray();
    // this is the part supposed to check the each character and add * or + or black space as shown in the picture.
    // and i cant figure out where i went wrong
    //[CODE]
    for (int count1=0; count1<=4; count1++)
    {
    if (th[count1]==ch[count1])
    {
    message1+=th[count1]+"* ";
    message2+=ch[count1]+"* ";
    }
    else
    {
    if(c.indexOf(th[count1])!=-1)
    {
    message1+=th[count1]+"+ ";
    message2+="_";
    }
    else
    {
    message1+=th[count1]+" ";
    message2+="_ ";
    }
    }
    }
    }
    return 3;

    }
    }
    Last edited by nishantvodoo; 01-25-2012 at 02:12 PM.

  3. #3
    Join Date
    Jul 2010
    Location
    India
    Posts
    58
    Rep Power
    0

    Default Re: Java Help Needed to complete an assignment

    You need to tell where exactly are u stuck or what problems you are facing.This site as far as i know is about getting help and guidance not ready-made solutions. So explain where exactly you are facing trouble and post your code within tags.. "[ CODE ]" "[ /CODE ]".

    warm regards
    Vinod M
    _______________________________________________
    give me beans .........

  4. #4
    nishantvodoo is offline Member
    Join Date
    Jan 2012
    Posts
    6
    Rep Power
    0

    Default Re: Java Help Needed to complete an assignment

    My code works and runs for the Lingo1 assignment but there are bugs....it is not running as it should ..It should run as shown in the picture but it is not....also i have no idea how to get started with the Lingo2 and Lingo3...

  5. #5
    nishantvodoo is offline Member
    Join Date
    Jan 2012
    Posts
    6
    Rep Power
    0

    Default Re: Java Help Needed to complete an assignment

    I guess i wont get help from this forum....its better to delete this thread...thank you....

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Java Help Needed to complete an assignment

    Quote Originally Posted by nishantvodoo View Post
    I guess i wont get help from this forum....its better to delete this thread...thank you....
    No, not until you ask a better question, but this skill improves with practice. Please have a look at the link in my signatures below on how to ask smart questions. The suggestions have helped me and could help you too.

  7. #7
    nishantvodoo is offline Member
    Join Date
    Jan 2012
    Posts
    6
    Rep Power
    0

    Default Re: Java Help Needed to complete an assignment

    my question is very clear....i posted my code...i mentioned the question and i mentioned the part in my code thats not acting right.....yet i have had no help from anyone...this is a very important project for me and i've been trying to do it for 3 days yet i couldnt figure out the way to do it right....if anyone can please help me.....

  8. #8
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Java Help Needed to complete an assignment

    Quote Originally Posted by nishantvodoo View Post
    my question is very clear....i posted my code...i mentioned the question and i mentioned the part in my code thats not acting right.....yet i have had no help from anyone...this is a very important project for me and i've been trying to do it for 3 days yet i couldnt figure out the way to do it right....if anyone can please help me.....

    You've posted the assignment requirements, you've posted some code unreadable without code tags, and the only description of an actual question is this:

    "// this is the part supposed to check the each character and add * or + or black space as shown in the picture.
    // and i cant figure out where i went wrong"

    Sorry for being blunt, but this tells us squat. How about putting in the effort to write a paragraph or two explaining in greater detail your actual problem, and the steps you've done to try to debug the situation? How about editing your code to use code tags as explained in the forum faq's? How about actually reading the link I've provided on code tags and on asking smart questions to see why your question is deficient in many ways?

    The basic rule of thumb is that you should put as much effort into writing your questions as you'd hope one of the volunteers here would put in trying to help you out. So far all you've done is dump your code and assignment and give 2 lines of explanation.

  9. #9
    nishantvodoo is offline Member
    Join Date
    Jan 2012
    Posts
    6
    Rep Power
    0

    Default Re: Java Help Needed to complete an assignment

    Java Help Needed to complete an assignment-my-output.jpg

    This is how mine works......

    Let me clarify the code too
    // this is the part supposed to check the each character and add * or + or black space as shown in the picture.
    // and i cant figure out where i went wrong
    //[CODE]
    // Message1 is the message in line 1
    // Message2 is the message in line 2
    // ch is the word entered by player 1 for player two that has been converted to character array
    // th is the word being guess bu player 2 that has also been converted to character array

    for (int count1=0; count1<=4; count1++)
    {
    // this checks if each character are equal
    if (th[count1]==ch[count1])
    {
    // if equal then * is added

    message1+=th[count1]+"* ";
    message2+=ch[count1]+"* ";
    }
    else
    {
    // if not equal then it is checked if the character is present in other position of word

    if(c.indexOf(th[count1])!=-1)
    {
    // if located in other position then + is added

    message1+=th[count1]+"+ ";
    message2+="_";
    }
    else
    // if not present at all in the word then _ is added

    {
    message1+=th[count1]+" ";
    message2+="_ ";
    }
    }
    }
    }
    return 3;

    }
    }

  10. #10
    Join Date
    Jul 2010
    Location
    India
    Posts
    58
    Rep Power
    0

    Default Re: Java Help Needed to complete an assignment

    Well .. Have you ever thought what will be the result if we type "RELAY" ? . As far as I can see the base mistake you are doing is not saving the state of the previous matching letters. You need to Store the row number of the previously matched words... in short all the "*" location needs to be stored and excluded when the next time you do the check.
    Say you have another array where you have saved the repetition of * (in the above example the repetition of "A" ). Then while checking for the next word match you will skip those particular position retaining the previous values at that spot. That means if A is present at point 1 and 3 in previous guess we will not check for those positions in next one .. instead just check 2,4 ,5 and join the result.
    In short you are not saving the state of previous guess successes and comparing it every time with new one ...

    hope it clears your doubt.

    warm regards
    Vinod M
    _______________________________________________
    give me beans .........

Similar Threads

  1. Help needed with class assignment.
    By DigDug in forum New To Java
    Replies: 9
    Last Post: 01-24-2012, 04:52 AM
  2. Replies: 2
    Last Post: 01-19-2012, 07:43 PM
  3. Calculator Program HELP NEEDED FAST! Homework assignment
    By SteroidalPsycho in forum New To Java
    Replies: 3
    Last Post: 03-05-2009, 04:02 AM
  4. Replies: 2
    Last Post: 03-10-2008, 12:24 PM
  5. assignment problem help needed
    By tiggz1980 in forum New To Java
    Replies: 2
    Last Post: 02-06-2008, 11:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •