?? gold.java
字號:
import java.awt.*;
/**
* 定義豆子的類
*/
public class Gold{
private int xPos, yPos;
private Rectangle gold;
private int goldSpecies;
/**
* 根據x、y和豆子的類型構造一個豆子的對象
*/
public Gold(int a, int b, int c){
xPos = a;
yPos = b;
goldSpecies = c;
gold = new Rectangle(xPos - 2, yPos - 2, 5, 5);
}
/**
* 根據x、y和豆子的類型構造一個豆子的對象
*/
public void draw(Graphics g){
g.setColor(Color.yellow);
//普通的小豆子
if(goldSpecies == 1){
g.fillOval(xPos - 2, yPos - 2, 4, 4);
}
//可以使敵人失去防抗能力的大豆子
if(goldSpecies == 2){
g.fillOval(xPos - 4, yPos - 4, 9, 9);
}
}
public Rectangle getBorder(){
return gold;
}
/**
* 判斷是否是大豆子
*/
public boolean bigGold(){
return goldSpecies == 2;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -