用Java模拟微信发红包的实现
大家好,又到了一周一次的分享环节,今天我分享的是模拟微信红包的实现,话不多说,见代码如下:
红包类
public class RedPacket {
/**红包ID*/
private int id;
/**红包金额*/
private BigDecimal money;
public RedPacket() {
}
public RedPacket(int id, BigDecimal money) {
super();
this.id = id;
this.money = money;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public BigDecimal getMoney() {
return money;
}
public void setMoney(BigDecimal money) {
this.money = money;
}
@Override
public String toString() {
return id+"号用户获得"+money+"元";
}
}
红包异常类
public class RedpacketException extends Exception{
public RedpacketException() {
// TODO Auto-generated constructor stub
}
public