ÿþ/ /   T h i s   p r o g r a m   s i m p l y   p l a y s   1 0 0 0 0   h a n d s   o f   9   h a n d e d  
 / /   p o k e r   a n d   d i s p l a y s   a   m a t r i x   o f   a l l   t h e   h a n d s   a n d    
 / /   h o w   o f t e n   t h e y   w o n  
  
 c l a s s   t e s t  
 {  
         p u b l i c   s t a t i c   v o i d   m a i n ( S t r i n g   [ ]   a r g s )  
         {  
 	 	 f i n a l   i n t   n u m b e r o f p l a y e r s   =   9 ;  
 	 	 f i n a l   i n t   i t e r   =   1 0 0 0 0 ;  
 	 	 d e c k   a   =   n e w   d e c k ( ) ;  
  
 	 	 c a r d   [ ] [ ]   p o c k e t   =   n e w   c a r d [ 2 ] [ n u m b e r o f p l a y e r s ] ;  
 	 	 c a r d   [ ]   b o a r d   =   n e w   c a r d [ 5 ] ;  
 	 	 c a r d   [ ]   b u r n   =   n e w   c a r d [ 3 ] ;  
 	 	 f l o a t   [ ] [ ]   w i n n e r   =   n e w   f l o a t [ 1 3 ] [ 1 3 ] ;  
 	 	 f o r ( i n t   i = 0 ; i < 1 3 ; i + + )  
 	 	         f o r ( i n t   j = 0 ; j < 1 3 ; j + + )  
 	 	 	 	 w i n n e r [ i ] [ j ]   =   0 ;  
  
 	 	 h a n d   [ ]   h   =   n e w   h a n d [ n u m b e r o f p l a y e r s ] ;  
  
 	 	 f o r ( i n t   i = 0 ; i < i t e r ; i + + )  
 	 	 {  
 	 	         f o r ( i n t   j = 0 ; j < 3 ; j + + )   a . s h u f f l e ( ) ;  
 	 	         a . c u t ( ) ; 	  
 	 	         f o r ( i n t   j = 0 ; j < 3 ; j + + )   a . s h u f f l e ( ) ;  
 	 	         a . c u t ( ) ;  
  
 	 	         / / d e a l   t h e   p o c k e t s  
 	 	         f o r ( i n t   j = 0 ; j < 2 ; j + + )  
 	 	 	 	 f o r ( i n t   k = 0 ; k < n u m b e r o f p l a y e r s ; k + + )  
 	 	 	 	         p o c k e t [ j ] [ k ]   =   a . d r a w ( ) ;  
 	 	         / / b u r n   c a r d  
 	 	         b u r n [ 0 ]   =   a . d r a w ( ) ;  
 	 	         / / d e a l   f l o p  
 	 	         f o r   ( i n t   j = 0 ; j < 3 ; j + + )  
 	 	 	 	 b o a r d [ j ] = a . d r a w ( ) ;  
 	 	         / / b u r n   c a r d  
 	 	         b u r n [ 1 ]   =   a . d r a w ( ) ;  
 	 	         / / t u r n   c a r d  
 	 	         b o a r d [ 3 ]   =   a . d r a w ( ) ;  
 	 	         / / b u r n   c a r d  
 	 	         b u r n [ 2 ]   =   a . d r a w ( ) ;  
 	 	         / / r i v e r   c a r d  
 	 	         b o a r d [ 4 ]   =   a . d r a w ( ) ;  
  
 	 	         / / m a k e   h a n d s  
 	 	         f o r ( i n t   j = 0 ; j < n u m b e r o f p l a y e r s ; j + + )  
 	 	 	 	 h [ j ]   =   n e w   h a n d ( p o c k e t [ 0 ] [ j ] , p o c k e t [ 1 ] [ j ] ,   b o a r d ) ;  
  
 	 	         / /   s o r t   t h e   h a n d s   b y   r a n k  
 	 	         f o r   ( i n t   k = 0 ; k < n u m b e r o f p l a y e r s - 1 ; k + + )  
 	 	         {  
 	 	 	 	 f o r ( i n t   j = k + 1 ; j < n u m b e r o f p l a y e r s ; j + + )  
 	 	 	 	 {  
 	 	 	 	         i f   ( h [ j ] . g e t r a n k ( )   <   h [ k ] . g e t r a n k ( ) )  
 	 	 	 	         {  
 	 	 	 	 	 	 h a n d   t e m p   =   h [ k ] ;  
 	 	 	 	 	 	 h [ k ]   =   h [ j ] ;  
 	 	 	 	 	 	 h [ j ]   =   t e m p ;  
 	 	 	 	 	 	 c a r d   t   =   p o c k e t [ 0 ] [ k ] ;  
 	 	 	 	 	 	 p o c k e t [ 0 ] [ k ]   =   p o c k e t [ 0 ] [ j ] ;  
 	 	 	 	 	 	 p o c k e t [ 0 ] [ j ]   =   t ;  
 	 	 	 	 	 	 t   =   p o c k e t [ 1 ] [ k ] ;  
 	 	 	 	 	 	 p o c k e t [ 1 ] [ k ]   =   p o c k e t [ 1 ] [ j ] ;  
 	 	 	 	 	 	 p o c k e t [ 1 ] [ j ]   =   t ;  
 	 	 	 	         }  
 	 	 	 	 }  
 	 	         }  
  
 	 	         i f   ( p o c k e t [ 1 ] [ 0 ] . i s g t ( p o c k e t [ 0 ] [ 0 ] ) )  
 	 	         {  
 	 	 	 	 c a r d   t   =   p o c k e t [ 0 ] [ 0 ] ;  
 	 	 	 	 p o c k e t [ 0 ] [ 0 ]   =   p o c k e t [ 1 ] [ 0 ] ;  
 	 	 	 	 p o c k e t [ 1 ] [ 0 ]   =   t ;  
 	 	         }  
  
 	 	         S t r i n g   b e s t h a n d   =   h [ 0 ] . g e t h a n d n a m e ( ) ;  
 	 	         S t r i n g   s p   =   " " ;  
 	 / / 	         p o c k e t [ 0 ] [ 0 ] . p r i n t c a r d ( ) ;  
 	 / / 	         p o c k e t [ 1 ] [ 0 ] . p r i n t c a r d ( ) ;  
 	 	         i f   (   h [ 0 ] . g e t r a n k ( )   = =   h [ 1 ] . g e t r a n k ( )   )   s p   =   "   . . . . . . .   s p l i t " ;  
 	 / / 	         S y s t e m . o u t . p r i n t l n ( " :   " +   b e s t h a n d   + " :   " +   h [ 0 ] . g e t r a n k ( )   +   s p ) ;  
  
 	 	         / / k e e p   t r a c k   o f   t h e   w i n n e r s  
 	 	         i n t   n u m w i n   =   1 ;  
 	 	         w h i l e   (   ( n u m w i n   < =   n u m b e r o f p l a y e r s   - 1   )  
 	                                       & &   ( h [ n u m w i n - 1 ] . g e t r a n k ( )   = =   h [ n u m w i n ] . g e t r a n k ( ) )   )    
 	 	 	 n u m w i n + + ;  
 	 	         f o r   ( i n t   j = 0 ; j < n u m w i n ; j + + )  
 	 	         {  
 	 	 	 	 i n t   i 1   =   p o c k e t [ 0 ] [ j ] . g e t v a l u e ( )   -   1 ;  
 	 	 	 	 i n t   i 2   =   p o c k e t [ 1 ] [ j ] . g e t v a l u e ( )   -   1 ;  
 	 	 	 	 w i n n e r [ i 1 ] [ i 2 ]   =   w i n n e r [ i 1 ] [ i 2 ]   +   1   /   ( f l o a t )   n u m w i n ;  
 	 	         }  
  
 	 	         / / r e t u r n   c a r d s   t o   d e c k  
 	 	         f o r ( i n t   j = 0 ; j < 3 ; j + + )   a . r e t u r n c a r d ( b u r n [ j ] ) ;  
 	 	         f o r ( i n t   j = 0 ; j < 5 ; j + + )   a . r e t u r n c a r d ( b o a r d [ j ] ) ;  
 	 	         f o r ( i n t   j = 0 ; j < 2 ; j + + )  
 	 	 	 	 f o r ( i n t   k = 0 ; k < n u m b e r o f p l a y e r s ; k + + )  
 	 	 	 	         a . r e t u r n c a r d ( p o c k e t [ j ] [ k ] ) ;  
 	 	 }  
 	 	 / / p r i n t   t h e   w i n n e r   m a t r i x  
 	 	 / / a n d   f i n d   m a x   v a l u e  
 	 	 f l o a t   m a x   =   0 ;  
 	 	 i n t   m a x i 1   =   0 ;  
 	 	 i n t   m a x i 2   =   0 ;  
 	 	 f o r ( i n t   i = 0 ; i < 1 3 ; i + + )  
 	 	 {  
 	 	         f o r ( i n t   j = 0 ; j < 1 3 ; j + + )  
 	 	         {  
 	 	 	 	 i f   ( w i n n e r [ i ] [ j ]   >   m a x )    
 	 	 	 	 {  
 	 	 	 	         m a x   =   w i n n e r [ i ] [ j ] ;  
 	 	 	 	         m a x i 1   =   i ;  
 	 	 	 	         m a x i 2   =   j ;  
 	 	 	 	 }  
 	 	 	 	 S y s t e m . o u t . p r i n t   ( "   "   +   w i n n e r [ i ] [ j ]   +   "   " ) ;  
 	 	         }  
 	 	         S y s t e m . o u t . p r i n t l n ( " " ) ;  
 	 	 }  
 	 	 S y s t e m . o u t . p r i n t l n ( " m a x :   " +   m a x   + " a t   " + ( + + m a x i 1 ) + " , " + ( + + m a x i 2 ) ) ;  
         }  
 }  
 
