Object Oriented Programming and Design in Java
Session 4 Instructor: Bert Huang
Object Oriented Programming and Design in Java Session 4 - - PowerPoint PPT Presentation
Object Oriented Programming and Design in Java Session 4 Instructor: Bert Huang Announcements ACM competition Homework 1 officially out due Feb. 17 th 11 AM Image inverted for projection Homework 1 Battleship against computer
Session 4 Instructor: Bert Huang
Image inverted for projection
interface
ideas off the TAs and me
sequence diagram, state diagram
Analysis Design Implementation (common sense) (object-oriented) (actual programming)
Todayʼs material
design decisions:
have?
see?
No encapsulation
MyClass int data String name OtherClass thing void doSomething() int getSomething()
The rest of your program...
Encapsulation
MyClass int data String name OtherClass thing void doSomething() int getSomething()
The rest of your program...
/* interface methods */
updating
what code is affected
BufferedReader(new InputStreamReader(System.in))
accurately
yield same result
“contracts” detailing responsibilities
postconditions, and invariants
method is called
must not be null
executing on bad input using assertions
assert (boolean) : “explanation”;
exits and displays explanation
method runs
elements are sorted by due date
effects
class that are always true
when building the class
using the class
breached? Crash?
can be breached
@throws IndexOutOfBoundsException
+ “ when size = ” + A.length());
named itemName (?)