JNatList.tex 660 B

1234567891011121314151617181920212223242526
  1. static class JNatList { }
  2. static class JconcJNat extends JNatList {
  3. public JNat head;
  4. public JNatList tail;
  5. public JconcJNat() { head = null; tail = null; }
  6. public JconcJNat(JNat h, JNatList ntail) {
  7. head = h;
  8. tail = ntail;
  9. }
  10. public boolean isEmpty() {
  11. return (head == null && tail == null);
  12. }
  13. public boolean equals(Object o) {
  14. if (o instanceof JconcJNat) {
  15. JconcJNat obj = (JconcJNat) o;
  16. if (this.isEmpty() && obj.isEmpty()) {
  17. return true;
  18. } else if (!this.isEmpty() && !obj.isEmpty()) {
  19. return
  20. head.equals(obj.head) && tail.equals(obj.tail);
  21. }
  22. }
  23. return false;
  24. }
  25. }