ground.java

来自「一个java写的大富翁游戏」· Java 代码 · 共 87 行

JAVA
87
字号
package rich;

import javax.swing.ImageIcon;

public class Ground {
	int cost=0;
	int lvl=0;
	int profit=0;
	int address;
	ImageIcon icon = new ImageIcon(getClass().getResource("picture/lvl0.gif"));
	Character Owner;
	int x,y;
	String groundType;
	
	Ground(int cost,int profit,int address,int x,int y){
		this.cost = cost;
		this.profit = profit;
		this.address = address;
		this.x = x;
		this.y = y;
		Owner = null;
		groundType = "house";
	}
	
	public void levelUp(){
		lvl++;
		switch(lvl){
			case 1:
				icon = new ImageIcon(getClass().getResource("picture/lvl1.gif"));
				break;
			case 2:
				icon = new ImageIcon(getClass().getResource("picture/lvl2.gif"));
				break;
			case 3:
				icon = new ImageIcon(getClass().getResource("picture/lvl3.gif"));
				break;
			case 4:
				icon = new ImageIcon(getClass().getResource("picture/lvl4.gif"));
				break;
			case 5:
				icon = new ImageIcon(getClass().getResource("picture/lvl5.gif"));
				break;
			case 6:
				icon = new ImageIcon(getClass().getResource("picture/lvl6.gif"));
				break;
			case 7:
				icon = new ImageIcon(getClass().getResource("picture/lvl7.gif"));
				break;
			case 8:
				icon = new ImageIcon(getClass().getResource("picture/lvl8.gif"));
				break;

				
		}	


	}
	
	public boolean gotOwner(){ 
		if(Owner == null){
			return false; 
		}
		else{
			return true;
		}
	}
	
	
	public void setIcon(ImageIcon icon){ this.icon = icon;}
	public ImageIcon getIcon(){ return icon; }
	public int getLevel(){ return lvl; }
	public int getAddress(){ return address; }
	public int getCost(){ return cost; }
	public int getProfit(){return profit+(lvl*500); }
	public void setOwner(Character name){ this.Owner = name; }
	public Character getOwner(){ return Owner; }
	public void setX(int x){ this.x = x;}
	public int getX(){ return x;}
	public void setY(int y){ this.y = y; }
	public int getY(){ return y; }
	public int getIconHeight(){	return icon.getIconHeight(); }
	public int getIconWidth(){	return icon.getIconWidth(); }
	public void setGroundType(String groundType){ this.groundType = groundType;}
	public String getGroundType(){ return groundType; }
	
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?