Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

equals() should (probably?) be symmetric #31

Open
3 tasks
hcientist opened this issue Mar 10, 2023 · 0 comments
Open
3 tasks

equals() should (probably?) be symmetric #31

hcientist opened this issue Mar 10, 2023 · 0 comments

Comments

@hcientist
Copy link

See some discussion in CS 159 planning (sorry to the folks who aren't JMU CS affiliated for posting the private link). It seems that we should likely:

  1. teach the use of Object.getClass() for use in implementing equals methods that @Override Object.equals(Object obj
  2. teach that usually implementations of equals methods should be symmetric, and so instances of a subclass should not be considered equal to instance of their superclass

Activities affected:

  1. Act11 - Designing Classes, e.g. Color.java and Point.java
  2. Act 19 - Extending Classes? Not sure about this one. The current implementation of BigInteger.equals(Object x) doesn't seem to check precisely that the paramter is specifically a BigInteger (i.e. it would permit an instance of a subclass, as explored in this activity).
  3. Act20 - Polymorphism, e.g. Person.java and Student.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant