如题,上代码:
什么地方有待改正求指点!
public class String001 {
public static void main(String[] args) {
// TODO 自动生成的方法存根
system sys=new system();
pokecompare Pc=new pokecompare();
player p1=new player("玩家1");
p1.setPokes(sys.fapai());
player p2=new player("玩家2");
p2.setPokes(sys.fapai());
player pp=Pc.comparepoke(p1,p2);
System.out.println("========================\n\t"+pp.getName()+"\t胜!");
}
}
class poke
{
private int num;
private int number;
private int color;
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
public int getColor() {
return color;
}
public void setColor(int color) {
this.color = color;
}
}
class pokecompare //implements tonghua,
{
player comparepoke(player p1,player p2)
{
System.out.println("玩家1:");
paixu(p1.getPokes());
System.out.println("玩家2:");
paixu(p2.getPokes());
if(p1.getPokes()[0].getNumber()==p1.getPokes()[1].getNumber()
&&p1.getPokes()[0].getNumber()==p1.getPokes()[2].getNumber()
&&p2.getPokes()[0].getNumber()==p2.getPokes()[1].getNumber()
&&p2.getPokes()[0].getNumber()==p2.getPokes()[2].getNumber())
{
if(p1.getPokes()[2].getNum()>p2.getPokes()[2].getNum())
{
return p1;
}
else
{
return p2;
}
}
else if(p1.getPokes()[0].getNumber()==p1.getPokes()[1].getNumber()
&&p1.getPokes()[0].getNumber()==p1.getPokes()[2].getNumber())
{
return p1;
}
else if(p2.getPokes()[0].getNumber()==p2.getPokes()[1].getNumber()
&&p2.getPokes()[0].getNumber()==p2.getPokes()[2].getNumber())
{
return p2;
}
else if(p1.getPokes()[0].getColor()==p1.getPokes()[1].getColor()
&&p1.getPokes()[0].getColor()==p1.getPokes()[2].getColor()
&&(p1.getPokes()[0].getNumber()+1)==p1.getPokes()[1].getNumber()
&&(p1.getPokes()[1].getNumber()+1)==p1.getPokes()[2].getNumber()
&&p2.getPokes()[0].getColor()==p2.getPokes()[1].getColor()
&&p2.getPokes()[0].getColor()==p2.getPokes()[2].getColor()
&&(p2.getPokes()[0].getNumber()+1)==p2.getPokes()[1].getNumber()
&&(p2.getPokes()[1].getNumber()+1)==p2.getPokes()[2].getNumber())
{
if(p1.getPokes()[2].getNum()>p2.getPokes()[2].getNum())
{
return p1;
}
else
{
return p2;
}
}
else if(p1.getPokes()[0].getColor()==p1.getPokes()[1].getColor()
&&p1.getPokes()[0].getColor()==p1.getPokes()[2].getColor()
&&(p1.getPokes()[0].getNumber()+1)==p1.getPokes()[1].getNumber()
&&(p1.getPokes()[1].getNumber()+1)==p1.getPokes()[2].getNumber())
{
return p1;
}
else if(p2.getPokes()[0].getColor()==p2.getPokes()[1].getColor()
&&p2.getPokes()[0].getColor()==p2.getPokes()[2].getColor()
&&(p2.getPokes()[0].getNumber()+1)==p2.getPokes()[1].getNumber()
&&(p2.getPokes()[1].getNumber()+1)==p2.getPokes()[2].getNumber())
{
return p2;
}
else if(p1.getPokes()[0].getColor()==p1.getPokes()[1].getColor()
&&p1.getPokes()[0].getColor()==p1.getPokes()[2].getColor()
&&p2.getPokes()[0].getColor()==p2.getPokes()[1].getColor()
&&p2.getPokes()[0].getColor()==p2.getPokes()[2].getColor())
{
if(p1.getPokes()[2].getNum()>p2.getPokes()[2].getNum())
{
return p1;
}
else
{
return p2;
}
}
else if(p1.getPokes()[0].getColor()==p1.getPokes()[1].getColor()
&&p1.getPokes()[0].getColor()==p1.getPokes()[2].getColor())
{
return p1;
}
else if(p2.getPokes()[0].getColor()==p2.getPokes()[1].getColor()
&&p2.getPokes()[0].getColor()==p2.getPokes()[2].getColor())
{
return p2;
}
else if((p1.getPokes()[0].getNumber()+1)==p1.getPokes()[1].getNumber()
&&(p1.getPokes()[1].getNumber()+1)==p1.getPokes()[2].getNumber()
&&(p2.getPokes()[0].getNumber()+1)==p2.getPokes()[1].getNumber()
&&(p2.getPokes()[1].getNumber()+1)==p2.getPokes()[2].getNumber())
{
if(p1.getPokes()[2].getNum()>p2.getPokes()[2].getNum())
{
return p1;
}
else
{
return p2;
}
}
else if((p1.getPokes()[0].getNumber()+1)==p1.getPokes()[1].getNumber()
&&(p1.getPokes()[1].getNumber()+1)==p1.getPokes()[2].getNumber())
{
return p1;
}
else if((p2.getPokes()[0].getNumber()+1)==p2.getPokes()[1].getNumber()
&&(p2.getPokes()[1].getNumber()+1)==p2.getPokes()[2].getNumber())
{
return p2;
}
else if((p1.getPokes()[0].getNumber()==p1.getPokes()[1].getNumber()
||p1.getPokes()[1].getNumber()==p1.getPokes()[2].getNumber())
&&(p2.getPokes()[0].getNumber()==p2.getPokes()[1].getNumber()
||p2.getPokes()[1].getNumber()==p2.getPokes()[2].getNumber()))
{
if(p1.getPokes()[1].getNumber()>p2.getPokes()[1].getNumber())
{
return p1;
}
else if(p1.getPokes()[1].getNumber()<p2.getPokes()[1].getNumber())
{
return p2;
}
else
{
if(p1.getPokes()[0].getNumber()==p1.getPokes()[1].getNumber()
&&p2.getPokes()[0].getNumber()==p2.getPokes()[1].getNumber())
{
if(p1.getPokes()[2].getNum()>p2.getPokes()[2].getNum())
{
return p1;
}
else
{
return p2;
}
}
else if(p1.getPokes()[0].getNumber()==p1.getPokes()[1].getNumber()
&&p2.getPokes()[2].getNumber()==p2.getPokes()[1].getNumber())
{
if(p1.getPokes()[2].getNum()>p2.getPokes()[0].getNum())
{
return p1;
}
else
{
return p2;
}
}
else if(p1.getPokes()[1].getNumber()==p1.getPokes()[2].getNumber()
&&p2.getPokes()[0].getNumber()==p2.getPokes()[1].getNumber())
{
if(p1.getPokes()[0].getNum()>p2.getPokes()[2].getNum())
{
return p1;
}
else
{
return p2;
}
}
else
{
if(p1.getPokes()[0].getNum()>p2.getPokes()[0].getNum())
{
return p1;
}
else
{
return p2;
}
}
}
}
else if(p1.getPokes()[0].getNumber()==p1.getPokes()[1].getNumber()
||p1.getPokes()[1].getNumber()==p1.getPokes()[2].getNumber())
{
return p1;
}
else if(p2.getPokes()[0].getNumber()==p2.getPokes()[1].getNumber()
||p2.getPokes()[1].getNumber()==p2.getPokes()[2].getNumber())
{
return p2;
}
else
{
if(p1.getPokes()[2].getNum()>p2.getPokes()[2].getNum())
{
return p1;
}
else
{
return p2;
}
}
}
poke[] paixu(poke[] pokes)
{
for(int i=0;i<3;i++)
{
for(int j=i;j<3;j++)
{
if(pokes[i].getNum()>pokes[j].getNum())
{
poke p;
p=pokes[i];
pokes[i]=pokes[j];
pokes[j]=p;
}
}
switch(pokes[i].getColor())
{
case 0:System.out.print("\t方块");break;
case 1:System.out.print("\t草花");break;
case 2:System.out.print("\t红桃");break;
case 3:System.out.print("\t黑桃");break;
}
switch(pokes[i].getNumber())
{
case 0:System.out.print("2");break;
case 1:System.out.print("3");break;
case 2:System.out.print("4");break;
case 3:System.out.print("5");break;
case 4:System.out.print("6");break;
case 5:System.out.print("7");break;
case 6:System.out.print("8");break;
case 7:System.out.print("9");break;
case 8:System.out.print("10");break;
case 9:System.out.print("J");break;
case 10:System.out.print("Q");break;
case 11:System.out.print("K");break;
case 12:System.out.print("A");break;
}
}
System.out.println();
return pokes;
}
}
class player
{
private String name;
private poke[] pokes= new poke[3];
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public poke[] getPokes() {
return pokes;
}
public void setPokes(poke[] pokes) {
for(int i=0;i<3;i++)
{
this.pokes[i] = pokes[i];
}
}
player(String s)
{
this.setName(s);
for(int i=0;i<3;i++)
{
pokes[i]=new poke();
}
}
}
class system
{
int[] N=new int[6];
int k=0;
poke[] pokes=new poke[3];
poke[] fapai()
{
for(int i=0;i<3;i++)
{
boolean bool=true,bool1=true;
int num=(int)(Math.random()*52);
for(int j=0;j<k;j++)
{
if(num==N[j])
{
bool1=false;
}
bool=bool&&bool1;
}
if(bool==true)
{
pokes[i]=new poke();
pokes[i].setNum(num);
pokes[i].setNumber(pokes[i].getNum()/4);
pokes[i].setColor(pokes[i].getNum()%4);
N[k]=num;
k++;
}
else
{
i--;
}
}
return pokes;
}
}
什么地方有待改正求指点!