bullet.java
来自「本程序是用多线程实现了打飞鸟游戏程序」· Java 代码 · 共 43 行
JAVA
43 行
/*
* bullet.java
*
* Created on 2007年12月28日, 下午2:19
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package shoot_birds;
/**
*
* @author open
* 子弹类
* 主要用于子弹计数,初始值为100
* 这里用到单身设计模式
*/
class Bullet {
private Bullet() {//构造器是私有的
}
public static Bullet getInstance()//得到单身模式的实例
{
if(bullet==null)
bullet=new Bullet();
return bullet;
}
//得到子弹的数目
public int getNum()
{
return num;
}
//射击的时候,也就是鼠标单击,子弹数目减减
public void setNum()
{
num--;
}
private static Bullet bullet;
private int num=100;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?