//目标:判断5张牌是否是一条龙(即5张连续点数的牌)
//运行可以 ,但是不打印showStatus()的内容了//用方法getValue的值实例化数组valueArray 
for(int i=0;i<5;i++)
valueArray[i]=getValue(dealt[i].face);
//将valueArray中的元素排序(冒泡排序)
//for1开始         
  for(int i=0;i<4;i++){
   //for2开始  
    for(int j=0;j<4;j++){
 if(valueArray[j]>valueArray[j+1]){
int temp=valueArray[j];
 valueArray[j]=valueArray[j+1];
valueArray[j+1]=temp;
}//if结束
 }//for2结束
      }//for1结束
 //判断是否是连续点数的牌
     boolean a=false;
     for(int i=0;i<4;i++){
     if((valueArray[i]-valueArray[i+1])==-1)
a=true;
         else{
showStatus("今天手气不好!!");
a=false;
break;
      }
 }//for结束
    if(a=true)
  showStatus("恭喜!!你有一条龙!!!"); //以下是getValue的实现
public int getValue(String mem){
for(int i=0;i<13;i++)
  if(faces[i].equals(mem))
return i;
         return -1;  
}

解决方案 »

  1.   

    学习一下 showStatus()的函数在哪儿???直接println("******");不可以吗??
      

  2.   

    这里有问题:
    if(a=true){
    }
    上述情况if永远成立!修改为:
    if(a==true){
    }
      

  3.   

    这个符号错误已经修改了 但是还是出现以下信息!Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
      

  4.   

    要看看java.lang.NullPointerException在哪里发生,是不是忘了new出来还是怎么!
      

  5.   

    你是不是new了个Canvas 还是createImage(w,h),这里可能会发生NullPointerException
      

  6.   

    Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
    at DeckOfCards.getValue(DeckOfCards.java:125)
    at DeckOfCards.action(DeckOfCards.java:50)
      

  7.   

    晕,就给
    Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
    at DeckOfCards.getValue(DeckOfCards.java:125)
    at DeckOfCards.action(DeckOfCards.java:50)
    这个东西能怎么帮你!!!!拒绝查看没有代码的错误!!!!
      

  8.   

    晕,就给
    Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
    at DeckOfCards.getValue(DeckOfCards.java:125)
    at DeckOfCards.action(DeckOfCards.java:50)
    这个东西能怎么帮你!!!!拒绝查看没有代码的错误!!!!
    *******************************
    老兄 代码上面不是有吗?!
      

  9.   

    java,asp,.net,技术讨论群14401742,现在缺管理员,欢迎高手加入。