Homework and Helpers
Lab Quiz
- We will provide test class
- Constructor
- Fields
- Getter
- Mutator
- If statement
- Submit to dropbox
Homework Comments
- Two solutions: work in constructor, work in getter
- Don't do redundant tests
- Next homework:
- Use proper indentation
- Include javadoc
- Instance variables should be private
- Only use instance variables for object state
Redundant Tests
if (a < b)
something();
else if a >= b
more();
Do this:
if (a < b)
something();
else // a >= b
more();
Or maybe this:
if (a < b)
something();
else if a > b
more();
else
evenMore();
Instance Variables
- Don't use instance variables where you can use locals
- Instance variables should represent the state of the object
Helper methods for class Card