JAva--単純な地主闘争を実現


/**
	 *                 
	 * 1.       
	 * 	a.    ArrayList      54   
	 * 	b.    String           [♠,♥,♦,♣]
	 * 	c.    String                [3,4,5,6,7,8,9,10,J,Q,K,A,2]
	 * 	d.       ArrayList   
	 * 
	 * 2.  
	 * 	          Collections         (shuffle)       
	 * 	(Collections  ,Collection   )
	 * 
	 * 3.     
	 * 	a.                
	 * 	b.  ArrayList   ,            
	 * 	         51,          
	 * 	            3  	0%3=0     1,1%3=1     2,2%3=2     3
	 * 
	 * 4.  
	 * 	     
	 * 
	 *
	 */

	 public static void main(String[] args) {
     
		
		//1.       
		List<String> poker = new ArrayList<String>();
		
		String[] colors = {
     "♠","♥","♦","♣"};
		String[] values = {
     "3","4","5","6","7","8","9","10","J","Q","K","A","2"};
		
		for(int i=0; i<colors.length; i++){
     
			for(int j=0; j<values.length; j++){
     
				poker.add(colors[i]+values[j]);
			}
		}
		
		poker.add("  ");
		poker.add("  ");
		
		//       
//		for(String l : poker){
     
//			System.out.println(l);
//		}
		
		//2.  
		Collections.shuffle(poker);
		
		//    
//		for(String l : poker){
     
//			System.out.println(l);
//		}
		
		//3.  
		List<String> play01 = new ArrayList<String>();//   
		List<String> play02 = new ArrayList<String>();//   
		List<String> play03 = new ArrayList<String>();//   
		List<String> dipai = new ArrayList<String>();//  
		
		for(int i=0; i<poker.size(); i++){
     
			if(i>=51){
     
				dipai.add(poker.get(i));
			}
			else if(i%3 == 0){
     
				play01.add(poker.get(i));
			}
			else if(i%3 == 1){
     
				play02.add(poker.get(i));
			}
			else if(i%3 == 2){
     
				play03.add(poker.get(i));
			}
		}
		
		//    
		System.out.println("   :");
		for(String p01 : play01){
     
			System.out.print(p01+" ");
		}
		System.out.println("
"
+" :"); for(String p02 : play02){ System.out.print(p02+" "); } System.out.println("
"
+" :"); for(String p03 : play03){ System.out.print(p03+" "); } System.out.println("
"
+" :"); for(String dp : dipai){ System.out.print(dp+" "); } // ( ) play01.addAll(dipai); System.out.println("
"
+" :"); for(String p01 : play01){ System.out.print(p01+" "); } } }