Package shuffle;
public class Shuffle {//Portal
public static void Main (string[] args) {
Ppoker a=new Ppoker ();
System.out.println ("Please check the card ************");
A.getpokerpoint ();
System.out.println ();
System.out.println ("Shuffle in");
A.shuffleone ();
A.getpokerpoint ();
System.out.println ();
System.out.println ("Shuffle in");
Ppoker b=new Ppoker ();
B.shuffletwo ();
B.getpokerpoint ();
System.out.println ();
System.out.println ("Shuffle in");
Ppoker c=new Ppoker ();
C.shufffethree ();
C.getpokerpoint ();
}
}
Package shuffle;
public class Poker {//card (data type),
public String Point;
public String color;
Public Poker (String x,string y)
{
Point=x;
Color=y;
}
}
Package shuffle;
public class Ppoker {//Shuffle people, shuffle people to achieve the specific operation of shuffling
Private poker []poker=new poker[54];
Private String []point;
Private string[] color;
Public Ppoker ()
{
Point=new String [] {"A", "2", "3", "4", "5", "6", "7", "8", "9", "Ten", "J", "Q", "K"};
Color=new String []{"♥", "♣", "♦", "♠"};
int k=0;
for (int i=0;i<13;i++)
{
for (int j=0;j<4;j++)
{poker[k]=new Poker (point[i],color[j]); k++;}
}
Poker[52]=new Poker ("JOKER", "small");
Poker[53]=new Poker ("JOKER", "big");
}
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;
}
}
}
}
Java Shuffle (Shuffle) simple algorithm (three implementations)