Property.java
package edu.chl.hajo.monopoly.core.space;
import edu.chl.hajo.monopoly.core.Player;
import edu.chl.hajo.monopoly.core.visitor.IVisitor;
/**
*
* @author hajo
*/
public class Property extends Space {
private final int price;
private Player owner = Player.NONE;
private final int rent = 100; // Not final calculate
public Property(String name, int price) {
super(name);
this.price = price;
}
public void setOwner(Player player) {
this.owner = player;
}
public boolean hasOwner() {
return owner != Player.NONE;
}
public Player getOwner() {
return owner;
}
public int getPrice() {
return price;
}
public int getRent() {
return rent;
}
public boolean hasBuildings() {
return false;
}
@Override
public String toString() {
return (owner == null) ? super.getName() : super.getName() + "/" + owner.getName();
}
@Override
public void accept(IVisitor v, Player actual){
v.visit(this, actual);
}
}