WEEK 2
- Review HW
- Talk about O(…)
- Have someone show solution
- Quiz?
Classes
- Objects
- Abstract data types
- Members
- Methods
- Invoking, sending a message
- Accessor (read, test), Modification
- Private, public
- Constructors
- With, without parameters, overloading
- Creating new objects
- Reference variables
- Null references
- Assignment statements
- Show picture of two object references pointing to same
thing vs. different
- Definition of “equals”
- Testing equality
- == what it does
- write a method to test var.isequal(var2);
- Accessing members and invoking methods
Packages
Static Methods
- A class method, not an object method
- E.g. Location.distance(p65-66);
Parameters
- Call by value
- Call by reference
- Objects as parameters
- Parameters vs. arguments
- What happens in methods to these
Return values
- Value, reference
- Objects as return values
The Object type
- A “super type” of objects
- Test a parameter
- E.g. equals(Object obj)
- (obj instanceof Class)
- then need to cast to use: e.g. Class var = (Class)
obj;
- see p. 76
Introduce Finite State Machines
- Example of three-way light switch
- Example of simple radio (buttons for 2 stations and set)
- implementing using switch statements