BuyVisitor.java

package edu.chl.hajo.monopoly.core.visitor;

import edu.chl.hajo.monopoly.core.Player;
import edu.chl.hajo.monopoly.core.space.Space;
import edu.chl.hajo.monopoly.core.space.Property;
import edu.chl.hajo.monopoly.core.space.Tax;

/**
 *
 * @author hajo
 */
public class BuyVisitor implements IVisitor {

    @Override
    public void visit(Space a, Player actual) {
    }

    @Override
    public void visit(Property p, Player actual) {
        if (!p.hasOwner() && actual.getBalance() >= p.getPrice()) {
            p.setOwner(actual);
            actual.withDraw(p.getPrice());
        }
    }

    @Override
    public void visit(Tax t, Player actual) {
    }

}