Skip to content
Advertisement

I can’t seem to figure out why I keep getting true when I clearly overridden the equality method

I’m trying to figure this out but I can’t seem to get it to compare correctly.

As I try to setup the code whenever I run it the result would end up becoming True when I need it to produce a false test as well. Extensive testing shows it to be always true and I have no idea how to produce a false on it.

JavaScript

Advertisement

Answer

The best example for a confusing & ironically erroneous comment:

JavaScript

The program works much better, when you:

  1. (Really) Introduce instance variables:

    JavaScript
  2. Fix compiler problems in main method (by declaring local variables with the same identifier ..no good style but quick):

    JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement