|
-
January 23rd, 2011 02:16 PM
#1
What In This Code Is Creating The Symbols ?
Hi...
I've Found This Code Online And Would Like To Use It For My School Project, But I Do Not Understand What Part Of This Code Is Creating The Symbols...
I Will Be Using This Code For My BlackJack Game And This Code Generates The Card...
What I Don't Get Is What Part Of This Code Generates The Symbols [Hear, Spades & etc.]
Can Someone Please Explain It To Me ?
public class Tango{
public static void main ( String[] arg ) throws Exception{
String[] cards = new String[52];
int i=0,v=0;
for(int k = 0;k<52;k++){
i = k%13;
if(i==0){
cards[k]="K";
}
else if(i==1){
cards[k]="A";
}
else if(i>=2 && i<11){
cards[k]= " " + i;
}
else if(i==11){
cards[k]= "J";
}
else if(i==12){
cards[k]= "Q";
}
if(k<13){
cards[k]= cards[k]+(char)(6)+" ";
}
else if(k<26){
cards[k]= cards[k]+(char)(3)+ " ";
}
else if(k<39){
cards[k]= cards[k]+ (char)(5)+ " ";
}
else if(k<52){
cards[k]= cards[k]+(char)(4)+ " ";
}
}
for (int a=0; a<=cards.length; a++) {
System.out.print(cards[a]);
}
}
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Click Here to Expand Forum to Full Width
|
Bookmarks