www.webdeveloper.com
Results 1 to 7 of 7

Thread: for my friend a little piece of codness

Threaded View

  1. #1
    Join Date
    Nov 2003
    Posts
    128

    for my friend a little piece of codness

    PHP Code:

    import java
    .util.*;
    import java.lang.*;
    public class 
    poker extends Object {

        public 
    poker() {
        }
        
        static 
    java.util.Random r=new java.util.Random();
        
        public static 
    int pickcard(){
            return 
    r.nextInt(13)+1
        }
        
        public static 
    int picksuit(){
            return 
    r.nextInt(4)+1;
        }
        
        public static 
    String cardname(int cardint suit){
            
    String cardname="";
            if (
    card>1&&card<11){System.out.print(card);}
            if (
    card==1){cardname="Ace";}
            if (
    card==11){cardname="Jack";}
            if (
    card==12){cardname="Queen";}
            if (
    card==13){cardname="King";}
            if (
    suit==1){cardname=cardname " of diamonds. ";}
            if (
    suit==2){cardname=cardname " of hearts. ";}
            if (
    suit==3){cardname=cardname " of spades. ";}
            if (
    suit==4){cardname=cardname " of clubs. ";}
            return 
    cardname;
        }
        
        public static 
    void main (String args[]) {
            
    int card,suit,card1=0,suit1=0,card2=0,suit2=0,card3=0,suit3=0,card4=0,suit4=0,card5=0,suit5=0;
            
    int ran=0;
            while (
    ran<5)
            {
            
    card pickcard();
            
    suit picksuit();
            if (
    ran!=0){
             while ((
    card==card1 && suit==suit1)||(card==card2 && suit==suit2)|| (card==card3 && suit==suit3)|| (card==card4 && suit==suit4)) 
             {
             
    card pickcard();
             
    suit picksuit();
             }
            }
            
            if (
    ran==0){
                
    card1=card;
                
    suit1=suit;}
            if (
    ran==1){
                
    card2=card;
                
    suit2=suit;}
            if (
    ran==2){
                
    card3=card;
                
    suit3=suit;}
            if (
    ran==3){
                
    card4=card;
                
    suit4=suit;}
            if (
    ran==4){
                
    card5=card;
                
    suit5=suit;}
            
    String cardname=cardname(cardsuit);
            
    System.out.print(cardname);

            
    ran++;
            }
            
    card=card3;
            
    suit=suit3;
            
    String cardname=cardname(cardsuit);
            
    System.out.print(cardname);
        }


    Last edited by davey; 11-29-2004 at 02:35 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles