Click here to see future expected lectures and labs.
Lecture 24. 19 Apr (Thursday). Exceptions.
An "Exception" is an event
like division by 0,o r a subscript out of range Java has a nice facility for
ahdnling and recovering from Exceptions. pdf powerpoint
Lab 12. Matlab. In this Lab, you will practice with Matlab for one hour, getting used to the programming environment and learning about assignment, expressions, etc. pdf rtf
Lecture 23. 17 Apr (Tuesday). Matlab.
We
start our four-lecture discussion of Matlab, a programming language that
is used heavily in some engineering disciplines. We do not require you to
get a textbook for the Matlab portion of the course. Instead, we provide
some very brief notes. And, in teaching Matlab, we focus on the part that
makes it different from most other programming languages and useful in engineering:
its use of various operations on arrays and ability to produce graphs easily. pdf powerpoint MATLAB.pdf
Lecture 22. 12 Apr (Thursday). Applications
and Applets.
A stand-alone Java program
--one that can be executed outside of DrJava-- is either an "application" or
an "applet". An application can be executed from a command line in
a "terminal" or "DOS" window. Applets can be executed from a conventional html
web page. We show you how to make a Java program into an application and into
an applet. pdf powerpoint
Lab 11. Exercises with loops. This lab asks you to develop loops from specifications and given invariants, giving you practice with our methdology for developing loops. pdf doc
Lecture 21. 10 Apr (Tuesday). Listening
to GUIs.
We show how to listen to mouse
clicks on buttons, mouse clicks in on components, and keystrokes.
pdf file powerpoint
file java files
used in class (zip file) other examples of gui-listeners:
Look in Chapter 17 of the CD ProgramLive.
Lecture 20. 05 Apr (Thursday). Placing
components in a GUI
We discuss GUIs and show how
components can be placed on them. We discuss the kinds of components that exist.
We show how to lay out components on a JFrame (with layout manager BorderLayout),
JPanel (with layout manager FlowLayout), and Box (with layout manager BoxLayout).
After the lecture, listen to lectures on the CD ProgramLive in chapter 17 --that's
the best way to learn the stuff. pdf powerpoint
Lab 10. Timing execution. We show you how to time execution of a method call and ask you to compare times for various searching and sorting methods. pdf html Sorting.java TestArrays.java
Lecture 19. 03 Apr (Tuesday). Sorting.
Arrays of arrays.
Pascal's triangle.
We first introduce 2-3 sorting
algorithms. We then turn to a discussion of two-dimensional
arrays and describe how they are created and stored, leading us to talk
about "ragged" arrays,
in which different rows can contain different numbers of elements. pdf powerpoint
Lecture 18. 29 Mar (Thursday). Develop
loops: important algorithms.
We develop more algorithms
that manipulate arrays. pdf powerpoint Sorting.java
Lab 09. Formating in Locales loops. A "locale" is a country and language. Different countries and languages have different ways of writing numbers, percentages, and currencies. This lab shows how JavJava class Locale makes it easy to use the formats of many countries. pdf html JLiveWindow.java MyJLiveWindow.java
Lecture 17. 27 Mar (Tuesday). Finding
an invariant: important algorithms.
We look at how to combine
diagrams for pre- and post-conditions of an algorithm into an invariant
for a loop and use it to develop some interesting algorithms,
including the dutch national flag problem and the partition algorithm
of quicksort. pdf powerpoint Sorting.java
Lecture 16. 15 Mar (Thursday). The
while loop and the four loopy questions.
We review the while loop and
introduce the four loopy questions. We develop a few loops, including
calculating b**c, and we begin looking at how to combine pre- and post-condition
to form an invariant. IMPORTANT. The important point in this lecture is the
development process, using the four loopy questions. This does not come across
in the slides, because they show the result and not the steps that got the result. pdf powerpoint
Lab 08. Reading files. We show you how to read a file that is on your harddrive. Reading a keyboard and writing as file is jsut as easy. pdf html Lab08.java
Lecture 15. 13 Mar (Tuesday). Arrays.
We begin talking about arrays. pdf powerpoint
Lecture 14. 08 Mar (Thursday). Method
calls and testing
We discuss the while
loop and look at assertions. We also introduce the four loopy questions,
used in developing or understanding a loop. pdf powerpoint assignment
on method calls (don't hand in)
Lab 07. Loops and assertions. This lab deals with some paper-and-pencil exercises on ranges, assertions, and for-loops. It also asks you to write four functions whose bodies contain for-loops. pdf rtf Lab07.java
Lecture 13. 06 Mar (Tuesday). Assignment A5;
more on loops.
We
introduce assignment A5 to you, which deals with turtle graphics. We hope
you find this as interesting as an exciting as we do. We then talk about
developing for-loops, using postconditions and invariants. We end with
a short introduction to while loops. pdf powerpoint
Lecture 12. 01 Mar (Thursday). Loops.
We then
began our discussion of the for-loop, showing how it can be used to "process" a
range of integers. We discuss an effective way of developing such a loop. pdf powerpoint
Lab 06. Recursion. You will write at least 5 recursive functions. pdf html Rec.java
Lecture 11. 27 Feb (Tuesday). Casting about
You know about casting from
int to double and double to int, e.g. (int) 3.4. We now show you how to cast
from one class-type to another and discuss why this is useful. This is the
last lecture on classes. pdf powerpoint
Lecture 10. 22 Feb (Thursday). Recursion!
We
develop a few more recursive procedure, including the mind boggling on to
tile Elaine's kitchen. We also look carefully at how recursive calls are
executed. pdf powerpoint Silly
quips on jobs Demo.java:
recursive methods from class.
Lab 05. Class Vector. An instance of class Vector can contain a list of objects, and the list can expand and shrink. In this lab, we study this class. pdf html Lab05.java
Lecture 09. 20 Feb (Tuesday). Recursion!
We
introduce recursion: a method calling itself. This provides power and
flexiblity that we haven't had yet, and you will (should) be amazed at
how simple it will be to do neat things. pdf powerpoint
Lecture 08. 15 Feb (Thursday). Odds and ends
on classes
Interlude: A discussion by
Senior Joseph Nelson on his RFID work.
We review some material about classes
and make some points about overriding, method equals, and constructors in
subclasses. We also finish method anglicize from last lecture and talk about
stepwise refinement.
pdf
powerpoint two
classes to anglicize: Ang Anglicize
Lab 04. Writing functions. You will practice writing functions. These have to do with manipulating Strings, a topic that you will have to know for prelim 1. An important point should become clear: a value of String is an object (manilla folder), so a test s1 == s2 where s1 and s2 are Strings tests whether they are the same folder or not. Method sa.equals(s2) should be used to test whether two Strings have the same value. pdf html Methods.java
Lecture 07. 13 Feb (Tuesday). Inside-out, super-this,
and stepwise refinement
We illustrate the inside-out
rule for referencing variables and methods that is in most programming
languages. We show a problem and introduce this and super to
solve it. (Another use of super and this,
which you need to know for the prelim, will be shown on Thursday.) And
we talk about stepwise refinement as a way to think about the development
of methods from their specifications. pdf powerpoint Anglicize.java
Lecture 06. 08 Feb (Thursday). Methods
We look more closely at how a method call is executed.
We show the four steps involved in executing a method call. We introduce
conditional statements and return statements. We also introduce local variables.
We now have four kinds of variable: parameter, static variable, field, and
local variable. You should know where and how each is declared and what
its scope is. pdf powerpoint
Lab 03. Two topics: testing and static variables. You will practice creating and test class to test and help find bugs in a class that we give you. Also, we give you some things to do to make clear to you when methods can be made static. pdf html ThreeDimPoint.java
Lecture 05. 06 Feb (Tuesday). The class hierarchy;
static variables; more on testing.
We talk about the
class hierarchy and show you the superest class of them all: Object. We
discuss function toString. We introduce static variables. We end with
a second discussion of testing. pdf powerpoint Chapter.java ChapterTester.java
Lecture 04. 01 Feb (Thursday). Customizing a
class (continued) and testing
(1) We discuss fields and getter and setter methods
for them. (2) We introduce the constructors, whose purpose is to initialize
(some) fields of a newly created object. (3) We show you how to test the
methods in a class using a JUnit tester. pdf powerpoint
Lab 02. Objects and classes. You will practice creating and manipulating JFrame objects using DrJava's interactions pane. Then, you will write your first class definition —a subclass of JFrame, and experiment with it. pdf html
Lecture 03. 30 Jan (Tuesday). Customizing a class
We introduce the class definition, which describes
the format of all manila folders (object, instances) of a class and defines
its methods. This is illustrated using a "subclass" of JFrame
to customize it to our needs. We also show how to create a "specification" of
the class using the javadoc facility. And we talk about null. pdf powerpoint
Lecture 02. 25 Jan (Thursday).
We define what an object (manilla folder) is and demo
the creation and manipulation of objects in DrJava. This material, in Sect.
1.3 of the text, is the basis for the next lecture, so study the material
and practice using DrJava. Look at the self-study exercises
in the text and do some of them. The more you practice, the easier it will
seem. pdf powerpoint
Lab 01. Java expressions. This lab gave you practice with Java expressions and the assignment using the DrJava Interactions pane. pdf html
Lecture 01. 23 Jan (Tuesday). Java expressions
We discuss evaluating Java expressions, as discussed
in Secs. 1.1 and 1.2 of the text. We cover types int, double, boolean, and
String. We show how to cast between int and double. And we introduce the
assignment statement. Lab 01 gives you practice with these features of Java.
Lecture handout: pdf powerpoint
Below is a list of the expected topics of future lectures and labs.
Lecture 28. 03 May (Thursday). Conclusion.
We talk about the course, about the
history of programming languages, about the final, and about anything else you
want to talk about.
Lab 13. Work on Matlab assignments. Use this lab to work on the Matlab assignment. You can get help from the TA and the consultants. A7 pdf file
Lecture 27. 01 May (Tuesday). Matlab.
This lecture introduces you
to array operations in Matlab and to plotting. Using them, you will see
how to calculate and plot succesive approximations to pi, without having
to write a loop or use recursion! This illustrates some of the power of
Matlab. pdf powerpoint Euler.m darts.m minmax.m
Lecture 26. 26 Apr (Thursday). Matlab.
Lab 12. Free Lab. To be defined later.
Lecture 25. 24 Apr (Tuesday). Matlab.
In place of this lecture, we
ask that you spend several hours this week practicing Matlab. Learn
how to us the "Help" facility. Learn about the different panes in the
Matlab window and practice writing expressions and assignments. Write
a few m-files --both script files and some simple functions-- and test
them. Figure out how to write if statements and loops, and write and test
a few. Your ability to use Matlab will depend not on listening to lectures
but on practising.