This repository acts as a personal archive for my solutions to EdX course *Data Structures and Software Design* from PennX.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
745 B

  1. public class Edge {
  2. private final Node source;
  3. private final Node destination;
  4. public Edge(Node source, Node destination) {
  5. this.source = source;
  6. this.destination = destination;
  7. }
  8. @Override
  9. public boolean equals(Object obj) {
  10. if (!(obj instanceof Edge)) {
  11. return false;
  12. }
  13. Edge otherEdge = (Edge) obj;
  14. Node otherSource = otherEdge.getSource();
  15. Node otherDest = otherEdge.getDestination();
  16. return (otherSource.equals(source)
  17. && otherDest.equals(destination));
  18. }
  19. @Override
  20. public int hashCode() {
  21. return source.hashCode() + destination.hashCode();
  22. }
  23. public Node getSource() {
  24. return source;
  25. }
  26. public Node getDestination() {
  27. return destination;
  28. }
  29. }