大家好,欢迎各位前辈看小弟写的一个网络版的斗地主程序,下面是小弟用了两个多星期的心血写成的,请各位前辈多指教!使小弟我能够得到前辈的指点,更上一层楼,谢谢支持!
下面是我写的项目分析和讲解:
由于我装的eclipse没有装UML插件,所以就没有设计UML图,但是我的源码当中大部分有注解讲解。
在此程序当中,我的主要抽象对象是牌这个对象
Puker.java代码如下:
/*
*这是一个牌对象的抽象类
*是为了表现牌这个对象
* */
import java.awt.*;
public class Puker
{
public int P_x,P_y;//表示牌X,Y坐标的属性
private final int P_w=60,P_h=80; //表示牌宽,高的属性
public Puker_num puker_num=null; //表示牌的牌值的属性
public Puker_hushe puker_hushe=null; //表示牌的花色的属性
public String puker_n=null;//表示画牌时用到的一个属性
public int puker_num1,puker_hushe1; //用整数形式表示牌的牌值和花色的属性
public int puker_dx;//表示牌的大小的值
public boolean bUp=false; //表示牌是否被选中的属性
/*
*用于构造用户自己的牌的构造方法
* */
public Puker(int P_x,int P_y,Puker_num puker_num,Puker_hushe puker_hushe)
{
this.P_x=P_x;
this.P_y=P_y;
this.puker_num=puker_num;
this.puker_hushe=puker_hushe;
this.BPuker_num();
}
/*
*用于构造54张牌组的构造方法
* */
public Puker(int puker_num1,int puker_hushe1)
{
this.puker_num1=puker_num1;
this.puker_hushe1=puker_hushe1;
}
/*
*用于画牌这个对象的方法
* */
public void paint(Graphics g)
{
Color c=g.getColor();
g.setColor(Color.WHITE);
g.fill3DRect(this.P_x, this.P_y, this.P_w, this.P_h, true);
g.setColor(Color.BLACK);
g.draw3DRect(this.P_x, this.P_y, this.P_w, this.P_h, true);
g.drawString(this.puker_n, this.P_x+5, this.P_y+20);
if(this.puker_n.e