Versions Compared

Key

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

...

A word of explanation:  A big deal was made in class and lab about how one should never have public fields because they allow uncontrolled mutations to occur.  You've problaby noticed the public garment field in some of the Command subclasses here.   For convenience's sake, we're exploiting the fact that Commands never need to be mutated (so far as we know).   The garment field in the Receive, Lose and Change commands is marked final, which makes it immutable.  So, we can get away with a public field because the field is immutable.   That said, in general, using an accessor method to explicitly control access to a class's data is still the preferred technique.

...