package shuffle;
public class shuffle {//入口

    public static void main(String[] args) {
    pPoker a=new pPoker();
    System.out.println("请验牌************");    
    a.getPokerPoint();
    System.out.println();
    System.out.println("洗牌中");
    a.shuffleOne();
    a.getPokerPoint();
    System.out.println();
    System.out.println("洗牌中");
    pPoker b=new pPoker();
    b.shuffleTwo();
    b.getPokerPoint();
    System.out.println();
    System.out.println("洗牌中");
    pPoker c=new pPoker();
    c.shufffeThree();
    c.getPokerPoint();
    }
}

package shuffle;

public class poker {//牌(数据类型),
    
         public String point;
         public String color;
         public poker(String x,String y)
         {
             point=x;
             color=y;
         }
    
}

package shuffle;

public class pPoker {//洗牌人,洗牌人实现洗牌具体操作    }
    public poker[] getPokerPoint()
    {
        for(int i=0;i<54;i++)
        {
            System.out.print(poker[i].color+poker[i].point);
        }
        return poker.clone();
    }
    public void shuffleOne()
    {
        String []temC=new String[54];
        String []temP=new String[54];
        for(int j=0;j<3;j++)
        {
        for(int i=0;i<54;i++)
        {
             temC[i]=poker[i].color;
             temP[i]=poker[i].point;
        }
    
        for(int i=0;i<27;i++)
        {
             poker[2*i].color=temC[i+27];
             poker[2*i].point=temP[i+27];
             poker[2*i+1].color=temC[i];
             poker[2*i+1].point=temP[i];
        }
        }
    }
    public void shuffleTwo()
    {
        for(int i=0;i<53;i++)
        {
            int t=(int)(Math.random()*(53-i));
            poker tem=poker[t];
            poker[t]=poker[53-i];
            poker[53-i]=tem;
        }
        
    }
    public void shufffeThree()
    {
        
        for(int i=0;i<54;i++)
        {
            int r=(int)(Math.random()*54);
            if(poker[i]!=poker[r])
            {
                poker temp=poker[i];
                poker[i]=poker[r];
                poker[r]=temp;
            }
        }
    }
}

相关文章:

  • 2022-12-23
  • 2021-11-17
  • 2022-12-23
  • 2021-07-21
  • 2021-10-06
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-03
  • 2021-11-17
  • 2022-12-23
  • 2021-05-16
  • 2022-01-12
相关资源
相似解决方案