001// Copyright 2002 by Basil Vandegriend. All rights reserved. 002 003package com.basilv.examples.dom4j; 004 005import java.awt.Point; 006 007/** 008 * Represents a wall on the maze. 009 */ 010public class Wall 011{ 012 013 private Point start; 014 private Point end; 015 016 public Wall(int startX, int startY, int endX, int endY) { 017 start = new Point(startX, startY); 018 end = new Point(endX, endY); 019 } 020 021 public Point getEnd() { 022 return end; 023 } 024 025 public Point getStart() { 026 return start; 027 } 028 029 @Override 030 public boolean equals(Object obj) { 031 if (!(obj instanceof Wall)) { 032 return false; 033 } 034 035 Wall other = (Wall) obj; 036 return this.start.equals(other.start) && this.end.equals(other.end); 037 } 038 039 @Override 040 public int hashCode() { 041 return this.start.hashCode() + 7 * this.end.hashCode(); 042 } 043 044 @Override 045 public String toString() { 046 return "Wall from " + start.x + ", " + start.y + " to " + end.x + ", " + end.y; 047 } 048 049}