import { Exit } from "./Exit";
import { ExternalNode } from "./ExternalNode";

export class Border {
  private readonly firstNode: ExternalNode;
  private readonly secondNode: ExternalNode | Exit;

  constructor(firstNode: ExternalNode, secondNode: ExternalNode | Exit) {
    this.firstNode = firstNode;
    this.secondNode = secondNode;
  }

  public traverseFrom(node: ExternalNode): ExternalNode | Exit {
    if (node === this.firstNode) {
      return this.secondNode;
    }
    if (node === this.secondNode) {
      return this.firstNode;
    }
    throw Error("Unable to traverse border");
  }
}
