Week 3 — Decisions, Methods, and Contracts
Apr 13 – Apr 17 · 6 lessons · Labs 5, 6, 7
- 3-a Conditionals, Looked At Closely Chain ordering, braces, short-circuit
- 3-b Static Methods — A First Look Headers, parameters, returns, scope
- 3-c Preconditions and Input Validation IllegalArgumentException and the guard pattern
- 3-d switch Statements case, break, default, fall-through, String switch
- 3-e Ternary Operator condition ? a : b — when it helps, when it hurts
- 3-f for Loops — A First Look Definite iteration, counter + accumulator patterns
Objectives
- Trace nested and chained conditionals by hand
- Combine conditions with && and ||; use short-circuit safely
- Write a static method with parameters and a return
- Document and enforce a precondition with IllegalArgumentException
- Use switch for discrete dispatch; recognize fall-through
- Use ternary for two-outcome value selection
This Week
- Quiz
- If/else tracing — practice set
- Lab 5
- Chat With a Bot — due Wed 4/15 at 11pm
- Lab 6
- Eligibility Checker — due Fri 4/17 at 11pm
- Lab 7
- Choose Your Path — due Mon 4/20 at 11pm