Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Compliant Solution

Wiki Markup
"ThereIt is simplycurrently nonot waypossible to extend an instantiable class (as opposed to an {{abstract}} class) and add an aspecta value or field in the subclass while preserving the equals contract." This implies that composition must be preferred over inheritance in this case.. This technique does qualify as a reasonable workaround \[[Bloch 08|AA. Java References#Bloch 08]\]. ThisIt can isbe doneimplemented by giving the {{XCard}} class a private {{card}} field and providing a a public {{viewCard}} method. 

...