Week 6 Notes

Download Report

Transcript Week 6 Notes

CSE 115
Week 6
February 18 - 22, 2008
Announcements

Software Installation Fest – Take 2
– Tuesday 2/26 4-7
– Wednesday 2/27 4-7
– Baldy 21

CSE Mentors Lunchtime Chat
– Wednesday 3/5 at noon in Bell 224
– Panel discussion with upper-level CS/CEN
majors
Announcements




Lab 4 due this week
Lab 5 assigned this week
Exam 4 (2/18), Exam 5 (2/25), Exam
6 (3/3)
Resign Deadline 3/28
Week’s Notes


Continued on discussion of graphical
organization and implemented some
buttons to start and stop the ball.
See code in repository for final
start/stop ball example.
Week’s Notes


Note that the method
addActionListener takes as a
parameter something of the type
java.awt.event.ActionListener.
This is an interface.
Week’s Notes


Our classes implement that interface,
so Java is able to resolve an instance
of the subtype as acceptable when the
supertype (or interface type in this
case) is asked for.
This is a difference between a
variables’ declared type and its actual
type.
Week’s Notes

Java allows a difference between a
variable’s declared type and its actual
type only when the declared type is a
supertype of the actual type.
Therefore, a declared type can be an
interface and an actual type can be a
class that implements that interface.
Week’s Notes

When the declared type and the actual
type are different, we have the setup
for a feature of object oriented
programming called Polymorphism.