2012-04-23 248 views
0

我一些問題的,如果else語句,請其支持誤差如果else語句

if (btn1.getText().toString().equals(myString[6]) &&    
        (btn1.getText().toString().equals(myString[6]) || (btn1.getText().toString().equals(myString[7]) || (btn1.getText().toString().equals(myString[8]) || (btn1.getText().toString().equals(myString[9]) || (btn1.getText().toString().equals(myString[10]) || (btn1.getText().toString().equals(myString[11]) || (btn1.getText().toString().equals(myString[12]) || (btn1.getText().toString().equals(myString[13]) || (btn1.getText().toString().equals(myString[14]) || (btn1.getText().toString().equals(myString[15])|| 
          (btn2.getText().toString().equals(myString[6]) || (btn2.getText().toString().equals(myString[7]) || (btn2.getText().toString().equals(myString[8]) || (btn2.getText().toString().equals(myString[9]) || (btn2.getText().toString().equals(myString[10]) || (btn2.getText().toString().equals(myString[11]) || (btn2.getText().toString().equals(myString[12]) || (btn2.getText().toString().equals(myString[13]) || (btn2.getText().toString().equals(myString[14]) || (btn2.getText().toString().equals(myString[15])|| 
            (btn3.getText().toString().equals(myString[6]) || (btn3.getText().toString().equals(myString[7]) || (btn3.getText().toString().equals(myString[8]) || (btn3.getText().toString().equals(myString[9]) || (btn3.getText().toString().equals(myString[10]) || (btn3.getText().toString().equals(myString[11]) || (btn3.getText().toString().equals(myString[12]) || (btn3.getText().toString().equals(myString[13]) || (btn3.getText().toString().equals(myString[14]) || (btn3.getText().toString().equals(myString[15])|| 
              (btn4.getText().toString().equals(myString[6]) || (btn4.getText().toString().equals(myString[7]) || (btn4.getText().toString().equals(myString[8]) || (btn4.getText().toString().equals(myString[9]) || (btn4.getText().toString().equals(myString[10]) || (btn4.getText().toString().equals(myString[11]) || (btn4.getText().toString().equals(myString[12]) || (btn4.getText().toString().equals(myString[13]) || (btn4.getText().toString().equals(myString[14]) || (btn4.getText().toString().equals(myString[15])|| 
                (btn5.getText().toString().equals(myString[6]) || (btn5.getText().toString().equals(myString[7]) || (btn5.getText().toString().equals(myString[8]) || (btn5.getText().toString().equals(myString[9]) || (btn5.getText().toString().equals(myString[10]) || (btn5.getText().toString().equals(myString[11]) || (btn5.getText().toString().equals(myString[12]) || (btn5.getText().toString().equals(myString[13]) || (btn5.getText().toString().equals(myString[14]) || (btn5.getText().toString().equals(myString[15])|| 
                  (btn01.getText().toString().equals(myString[6]) || (btn01.getText().toString().equals(myString[7]) || (btn01.getText().toString().equals(myString[8]) || (btn01.getText().toString().equals(myString[9]) || (btn01.getText().toString().equals(myString[10]) || (btn01.getText().toString().equals(myString[11]) || (btn01.getText().toString().equals(myString[12]) || (btn01.getText().toString().equals(myString[13]) || (btn01.getText().toString().equals(myString[14]) || (btn01.getText().toString().equals(myString[15]) 


        ))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) 
      { 
      Toast.makeText(getBaseContext(), "something wrong", Toast.LENGTH_SHORT).show();   
      } 

      else if (btn1.getText().toString() == (btn2.getText().toString()) 
       (btn1.getText().toString() == (btn3.getText().toString())|| 
         (btn1.getText().toString() == (btn4.getText().toString())|| 
           (btn1.getText().toString() == (btn5.getText().toString())|| 
             (btn1.getText().toString() == (btn01.getText().toString())|| 
               (btn2.getText().toString() == (btn3.getText().toString())|| 
                 (btn2.getText().toString() == (btn4.getText().toString())|| 
                   (btn2.getText().toString() == (btn5.getText().toString())|| 
                     (btn2.getText().toString() == (btn01.getText().toString())|| 
                       (btn3.getText().toString() == (btn4.getText().toString())|| 
                         (btn3.getText().toString() == (btn5.getText().toString())|| 
                           (btn3.getText().toString() == (btn01.getText().toString())|| 
                             (btn4.getText().toString() == (btn5.getText().toString())|| 
                               (btn4.getText().toString() == (btn01.getText().toString())|| 
                                 (btn5.getText().toString() == (btn01.getText().toString())))))))))))))))) 
      { 
       Toast.makeText(getBaseContext(), "something same", Toast.LENGTH_SHORT).show();   
      } 
      else (btn1.getText().toString().equals(myString[0])|| 
        (btn1.getText().toString().equals(myString[1])||(btn1.getText().toString().equals(myString[2])||(btn1.getText().toString().equals(myString[3])||(btn1.getText().toString().equals(myString[4])||(btn1.getText().toString().equals(myString[5]))))))) 
      { 
       Toast.makeText(getBaseContext(), "test", Toast.LENGTH_SHORT).show(); 
      } 
     } 

如果語句執行只出現「一樣的東西」。我應該從上面的代碼中添加什麼?

+4

人......沒有違法假裝,但你的代碼很糟糕。 – Cristian 2012-04-23 04:09:42

+0

我的代碼有什麼問題?我試圖用很多按鈕來製作一個謎題,如果還有其他聲明。:D – adig 2012-04-23 04:15:34

+2

如果你看看你的代碼並且沒有感到寒戰,那麼你應該去看醫生。 – Cristian 2012-04-23 04:20:17

回答

3

第一.... else if (btn1.getText().toString() == (btn2.getText().toString())....

使用.equals()比較String..and使用否則,如果代替ledder其他人如果當時你可以檢查一些問題...

+0

好吧,我會嘗試它。 – adig 2012-04-23 04:13:55