title: Memory game does not call compare function correctly
body: <p>I have coded a simple memory game. Card values are added to two arrays and after that, a compare function is called. But there is a problem with the logic of the compare function.</p>
  
  <p>The specific problem seems related to the fact that the compare function is called on the third button click. So on first click it adds first value to first array , on second click second value to second array. But I must click for yet a third time to call the compare function to compare the match of two arrays. </p>
  
  <p>The main problem is that after all cards are inverted (10 matches in 5x4 memory game), it does not show the result. </p>
  
  <p>I have uploaded full code here : <a href="http://uloz.to/xcsJkYUK/memory-game-rar" rel="nofollow">http://uloz.to/xcsJkYUK/memory-game-rar</a> . </p>
  
  <pre><code>public class PEXESO5x4 extends JFrame implements ActionListener {
  
      private JButton[] aHracieTlactika = new JButton[20];
      private ArrayList&lt;Integer&gt; aHodnoty = new ArrayList&lt;Integer&gt;();
      private int aPocitadlo = 1;
      private int[] aTlacitkoIden = new int[2];
      private int[] aHodnotaTlac = new int[2];
      private JButton aTlacitkoExit;
      private JButton aTlacitkoReplay;
      private JButton[] aHracieTlacitko = new JButton[20];
      private int aPocetTahov = 0;
  
      public void vkladanieHodnot() {
  
          for (int i = 0; i &lt; 2; i++) {
  
              for (int j = 1; j &lt; (this.aHracieTlactika.length / 2) + 1; j++) {
                  this.aHodnoty.add(j);
              }
  
          }
          Collections.shuffle(this.aHodnoty);
      }
  
      public boolean zhoda() {
          if (this.aHodnotaTlac[0] == this.aHodnotaTlac[1]) {
              return true;
  
          }
          return false;
      } 
      public  void zapisCislaDoSuboru() {
         try(PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("Semestralka.txt", true)))) {
        out.println("haha");
      //more code
      out.println("hahahahha");
      //more code
      }catch (IOException e) {
      //exception handling left as an exercise for the reader
       }
      }
  
      public void actionPerformed(ActionEvent e) {
       int match = 0;
  
        if (this.aTlacitkoExit == e.getSource()) {
  
              System.exit(0);
  
          }
  
        if (this.aTlacitkoReplay == e.getSource()) {
          }
          for (int i = 0; i &lt; this.aHracieTlactika.length; i++) {
  
              if (this.aHracieTlactika[i] == e.getSource()) {
                  this.aHracieTlactika[i].setText("" + this.aHodnoty.get(i));
                  this.aHracieTlactika[i].setEnabled(false);
                  this.aPocitadlo++;
  
                  this.aPocetTahov += 1;
  
                  if (this.aPocitadlo == 3) {
  
                      if (this.zhoda()) {
  
                          match+=1;
                          if (match==10)
                          {
                              System.out.println("You win");
                          }
  
    this.aHracieTlactika[this.aTlacitkoIden[0]].setEnabled(false);
                          this.aHracieTlactika[this.aTlacitkoIden[1]].setEnabled(false);
  
                      } else {
          this.aHracieTlactika[this.aTlacitkoIden[0]].setEnabled(true);
                          this.aHracieTlactika[this.aTlacitkoIden[0]].setText("");
                          this.aHracieTlactika[this.aTlacitkoIden[1]].setEnabled(true);
                          this.aHracieTlactika[this.aTlacitkoIden[1]].setText("");                     
                      }
                      this.aPocitadlo = 1;    
                  }
                   if (this.aPocitadlo == 1) {
                      this.aTlacitkoIden[0] = i;
                      this.aHodnotaTlac[0] = this.aHodnoty.get(i);
                  }
                  if (this.aPocitadlo == 2) {
                      this.aTlacitkoIden[1] = i;
                      this.aHodnotaTlac[1] = this.aHodnoty.get(i);  
                  }          
          }     
      }   
      }
  }
  </code></pre>