Feb 15: Writing Classes
Learning Objectives
After today's class, you should be able to:
- Interpret a UML class diagram and stub out the corresponding code.
- Write JUnit tests that create objects and assert non-static methods.
- Draw a memory diagram that includes variables, arrays, and objects.
Reminders¶
- By Friday 11pm: Do the Week 5 reading and take Quiz04
- By Monday 11pm: Complete Homework 4 (due Feb 19)
Lesson Outline¶
Lab04 [50 min]
Lecture [25 min]
How to draw pictures like Java Visualizer
a.k.a. "Memory Diagrams"
- Variables
- Methods
- Strings
- Arrays
- Objects
Example Code¶
Example.java | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
|
Output
A 1989 Dodge that is going 5.0 mph
A 2024 Tesla that is going 5.0 mph
A 1989 Dodge that is going 10.0 mph
Winner at index 0
A 1989 Dodge that is going 10.0 mph
Memory Diagram¶
Here is the diagram I drew on the whiteboard: