Space.java

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

import edu.chl.hajo.monopoly.core.Player;
import edu.chl.hajo.monopoly.core.visitor.IVisitor;

/**
 *
 * This is where the player piece is located (streets, railroads, corners, jail,
 * etc..) Base class for spaces
 * @author hajo
 *
 */
public abstract class Space {

    private final String name;

    public Space(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }
    
    // TO b implemented by all subclasses, part of visitor pattern
    public abstract void accept(IVisitor v, Player actual);

    @Override
    public final int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((name == null) ? 0 : name.hashCode());
        return result;
    }

    @Override
    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        Space other = (Space) obj;
        if (name == null) {
            if (other.name != null) {
                return false;
            }
        } else if (!name.equals(other.name)) {
            return false;
        }
        return true;
    }

}