Mastermind Game Algorithm
<p>I have to make a Mastermind Game for an assignment. I am stuck on the part where I have taken user input and need to compare them with the random numbers. Then I need to put the (user input) numbers in correct spots on the grid (bottom up). </p>

<p>Also, I have to show if the number is:</p>

<ul>
<li>right and in right position by showing 4,</li>
<li>right but wrong position by showing 2, </li>
<li>wrong by showing 0</li>
</ul>

<p>Further, I need to keep asking for user input until they have reached the maximum tries of 10 or have guessed the right answer.</p>

<hr>

<h2>Here is my code</h2>

<pre><code>...
        public static void main(String[] args) {

             PlayMasterMind.computerNum();
             PlayMasterMind.printBoard();
             PlayMasterMind.userInput();
             PlayMasterMind.compare();
            }

        public void printBoard(){
            System.out.println(" _______________________");
            System.out.println("|  " + gotIt + "  |  " + gotIt + "  |  " + gotIt + "  |  " + gotIt + "  |  ");
            System.out.println(" _______________________    ____");
            for (j = 0; j &lt; 10; j++) {
                for (int k = 0; k &lt; 4; k++) {
                    guess[j][k] = "    ";
                    answer[k] = " ";
                }
                System.out.println("| " + guess[j][0] + "| " + guess[j][1] + "| " + guess[j][2] + "| "
                        + guess[j][3] + "|==|" + answer[0] + answer[1] + answer[2] + answer[3]
                        + "|");
                System.out.println(" _______________________    ____");
            }     
}



    }
</code></pre>

<p>I am having a problem in the above section, where I need to put user input in the grid from bottom up. </p>

<p>At this point what I get is that:</p>

<p>Enter 4 numbers: 2342 </p>

<hr>

<p>| 2342 | 2342 | 2342 | 2342 | 
 ___________________________    ____ 
|      |      |      |      |==|    | 
 ___________________________    ____ 
|      |      |      |      |==|    |
 ___________________________    ____<br>
...</p>

<p>But I actually need the numbers in the following order: </p>

<ul>
<li><strong>| 2 | 3 | 4 | 2|</strong> </li>
</ul>

<p>and if these are the right numbers. I would like to output them the following way: </p>

<ul>
<li><strong>| 2 | 3 | 4 | 2|==|4444|</strong> </li>
</ul>

<p>if 1 number is wrong, 2 numbers are right and at right position and 1 right but wrong position (<em>right and wrong numbers order does NOT matter</em>. Say if the <strong>right number <em>is</em> 2342, <em>but</em> user puts in <em>1242</em></strong>) then I would to show it this way: </p>

<ul>
<li><strong>| 2 | 3 | 4 | 2|==|4420|</strong></li>
</ul>

<p>but don't get anything in the boxes below. it keeps overwriting the "X" OR the information at the place of the "X'. </p>

<p><em>Any help would be much appreciated.</em></p>

<p><strong>Thank you in advance!!!</strong></p>