问题:没有显示出错误,但是输不出自己想的要结果。
import java.math.*;
public class Card1{
int suit,face;
public Card1(int s,int f){
suit=s;
face=f;
}
public String display(){
String suitString= " ";
if(suit==0) suitString= "方块 ";
if(suit==1) suitString= "梅花 ";
if(suit==2) suitString= "红桃 ";
if(suit==3) suitString= "黑桃 ";
String faceString= " ";
if(face==0) faceString= "A ";
if(face> 0&&face <10) faceString= " "+(face+2);
if(face==10) faceString= "J ";
if(face==11) faceString= "Q ";
if(face==12) faceString= "K ";
return (suitString+faceString);
}
public static void main(String[] args){
//抽出一张牌;
Card1 a=new Card1((int)(Math.random()*4),(int)(Math.random()*13));
a.display();
}
}
------解决方案--------------------lz只是返回了String 但没输出阿。。。。。应该是System.out.println(a.display());