初来乍到求指教,极度简陋版双人随机扎金花;给点意见谢谢!

如题,上代码:
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;
}
}

什么地方有待改正求指点!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值