📄 player.java
字号:
package com.xmu.typot.domain;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import com.xmu.typot.constant.Constants;
/**
* Player类
* @author typot
*
*/
public class Player {
private String name;
private Piece piece;
private int index;
private int money;
private int[] house = new int[4];
private int stopTime = 0;
private int stopType = 0;
public int getStopType() {
return stopType;
}
public void setStopType(int stopType) {
this.stopType = stopType;
}
public int getStopTime() {
return stopTime;
}
public void setStopTime(int stopTime) {
this.stopTime = stopTime;
}
public Player(String name,int index,Square square)
{
this.setName(name);
this.setIndex(index);
try {
BufferedImage bf = ImageIO.read(new File("image/"+index+"player.gif"));
piece = new Piece(square,bf);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
for(int i = 0; i < 4 ; i++)
house[i] = 0;
money = Constants.MAX_MONEY;
}
public void buyHouse(int houseType,int price)
{
house[houseType - 1] ++;
this.money -= price;
}
public void payRent(int price)
{
this.money -= price;
}
public int payTaxt()
{
int total = 0;
for(int i = 0; i < 4; i ++)
{
total += house[i]*(1000+500*i);
}
total *= 0.5;
this.money -= total;
return total;
}
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
public int getMoney() {
return money;
}
public void setMoney(int money) {
this.money = money;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Piece getPiece() {
return piece;
}
public void setPiece(Piece piece) {
this.piece = piece;
}
public void run()
{
this.piece.setLocation(this.piece.getLocation().getNextSquare());
}
public int[] getHouse() {
return house;
}
public void setHouse(int[] house) {
this.house = house;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -