Download presentation
Presentation is loading. Please wait.
1
CSE 115 Week 5 February 11 - 15, 2008
2
Monday Announcements Exam 3 today Exam 3 today Lab 3 due this week Lab 3 due this week Exam 4 Monday 2/18 Exam 4 Monday 2/18 Exam Reviews this week Tuesday and Thursday for Exams 1 & 2 – see Schedule Page. Exam Reviews this week Tuesday and Thursday for Exams 1 & 2 – see Schedule Page. SWIF Take 2 on 2/26 and 2/27 – see Announcements page. SWIF Take 2 on 2/26 and 2/27 – see Announcements page.
3
Wednesday Announcements Lab 3 due this week Lab 3 due this week Exam 4 Monday 2/18 Exam 4 Monday 2/18 Exam Reviews this week Thursday for Exams 1 & 2 – see Schedule Page. Exam Reviews this week Thursday for Exams 1 & 2 – see Schedule Page. SWIF Take 2 on 2/26 and 2/27 – see Announcements page. SWIF Take 2 on 2/26 and 2/27 – see Announcements page.
4
Friday Announcements Exam 4 Monday 2/18 Exam 4 Monday 2/18 Exam Reviews next Tuesday and Thursday for Exam 3 – see Schedule Page. Exam Reviews next Tuesday and Thursday for Exam 3 – see Schedule Page. SWIF Take 2 on 2/26 and 2/27 – see Announcements page. SWIF Take 2 on 2/26 and 2/27 – see Announcements page.
5
Week’s Notes When we create a class we are actually creating a new type. It is a user-defined type that we are adding to the base language. When we create a class we are actually creating a new type. It is a user-defined type that we are adding to the base language.
6
Week’s Notes Another type we can add to our programs is called an interface. Another type we can add to our programs is called an interface. An interface is defined in a file, just like a class was and the name of the file corresponds to the name of the interface defined inside. These files also have the.java extension. An interface is defined in a file, just like a class was and the name of the file corresponds to the name of the interface defined inside. These files also have the.java extension.
7
Week’s Notes Interface header Interface header public interface Identifier public – keyword (same as before) public – keyword (same as before) interface – keyword that indicates that an interface is being defined interface – keyword that indicates that an interface is being defined Identifier – style: starts with an I, like IFlower, or ends in “able”. Identifier – style: starts with an I, like IFlower, or ends in “able”.
8
Week’s Notes Interface body contained in { } Interface body contained in { } –No instance variables in interfaces –No method definitions, only method declarations Method declarations: Method headers followed by a ; Method declarations: Method headers followed by a ;
9
Week’s Notes Interfaces can help us define roles for classes Interfaces can help us define roles for classes Illuminate common functionality Illuminate common functionality Frameworks Frameworks Libraries Libraries Facilitates Decoupling of specification from implementation Facilitates Decoupling of specification from implementation
10
Week’s Notes Keyword implements at the end of class header shows us that a class implements an interface Keyword implements at the end of class header shows us that a class implements an interface public class Name implements Interface
11
Week’s Notes A class can implement more than one interface. A class can implement more than one interface. When a class says it implements an interface, it is signing a contract indicating that the class must provide a definition for every one of the methods declared in the interface. If not, the code will not compile. When a class says it implements an interface, it is signing a contract indicating that the class must provide a definition for every one of the methods declared in the interface. If not, the code will not compile.
12
Week’s Notes Interfaces are used to handle events in the Java Swing graphics library. Interfaces are used to handle events in the Java Swing graphics library. Each graphical component (button, menu, etc) can be created and put on the screen, but does not react when clicked upon until you register its ActionListener (an interface) Each graphical component (button, menu, etc) can be created and put on the screen, but does not react when clicked upon until you register its ActionListener (an interface)
13
Week’s Notes Graphical programs required a JFrame (remember that it is hidden and very small when you create one, so you have to set those properties). Graphical programs required a JFrame (remember that it is hidden and very small when you create one, so you have to set those properties). JFrames can only hold onto one thing, so we make that thing a container that can hold lots of other graphical components. JFrames can only hold onto one thing, so we make that thing a container that can hold lots of other graphical components.
14
Week’s Notes Some useful containers: Some useful containers: –Row – organizes things horizontally –Column – organizes things vertically We can put columns inside of rows inside of columns to get the overall look and feel we would like for a user interface. We can put columns inside of rows inside of columns to get the overall look and feel we would like for a user interface.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.