Lecture 5 -- Primitive Types, More Conditionals
Laundry Lab
- For lab next Monday/Tuesday, you will implement a
program to simulate the exciting pastime know as sorting your
laundry. See demo here.
- To prepare for this lab, we expect you to:
- Read appropriate material in the text and lecture notes
- Understand all of the examples in the text and lecture
- read the handout carefully before coming to lab,
- sketch out as much of the code as you can (see handout
for details)
- Do not come in and start typing in Eclipse before
your lab period. We want you to do your thinking away
from the computer!
Primitive Types
We've seen int, double, boolean
We discussed how arithmetic operations using ints and
doubles works.
How do we determine if two values are the same?
- For primitive types, use "=="
- For object types, use "==" only if you want to know they
are the same object. Use the "equals" method if you
want to know if they have the same characteristics.
You may want to play around with the
AssignmentVisualization
demo.
- For strings, be sure to only use ".equals" rather than "==" as it is possible
to have different string representing the same sequence of characters.
More Conditionals
- Our first attempt at writing Pong. Unfortunately, the paddle
doesn't stay in the boundaries.
Click on PongUnbounded to show the
example.
- Our second attempt at writing Pong. This time the paddle
stays in the boundaries.
Click on PongPaddleBounded to show the
example.
Classes
We briefly discussed the ClassyBasketball example.