CS100J Fall 2003. Summary of lectures

 

Lecture 19. Nov 13.
There will be a quiz. You have to know the algorithms: linear search, finding the minimum, and binary search.
.

Lab 10. Nov 11-12. Exercises with loops and the required array algorithms. pdf file

Lecture 20. Nov 11. Reading/writing files.
This material is covered in Secs. 5.7 and 5.8.

Lecture 19. Nov 06. Arrays --sorting.   Powerpoint slides     pdf file
Quiz 04 will be on Nov 06, not in this lecture. We developed a "partition algorithm", insertion sort, and selection sort. You have to KNOW these algorithms. Memorize the pre- and post-conditions, write down the invariant. And then develop the loop from this. The slides for this lecture contains (1) one page that gives the preconditions, postconditions, and invariants for linear search, finding the minimum, and binary search and (2) one page that does the same for the three algorithms of this lecture.

Lab 09. Nov 03-05. Formatting in different locales.    lab assignment    pdf file      files are obtainable from this page
This lab introduces you classes in Java called "locales". A locale is a country together with a language. Java has almost 150 locales in its API package. For each locale, you can get function that format decimals, currencies, and percentages the way that locale does it.

Lecture 18. Nov 04. Arrays. Powerpoint slides      pdf file
We look at algorithms for searching/manipulating arrays (linear search, finding the minimum value, binary search, partitioning an array based on the pivot value). You have to KNOW these algorithms, in the following sense. If we ask you what the algorithm is for doing a linear search of an array, you are able to state the precondition, postcondition, and loop invariant and then DEVELOP the loop from those three. In this way, the algorithms become MEMORABLE: you know them forever. Not by memorizing code but by memorizing what they do (precondition-postcondition) and how they work (invariant) and then developing the algorithm using the four loopy questions.

An algorithm that is essentially a loop can be learned in a three-step process. (0) Practice writing down the precondition (if any) and postcondition. (1) Practice writing down the loop invariant. Often, it need not be memorized because it is a simple modification of the pre- and post-conditions. (2) Practice developing the algorithm.

Lecture 17. Oct 30. Arrays. Powerpoint slides     pdf file
We developed an algorithm to find the length of the longest prefix of equal values in an array. Prelim II question 1 did the same thing for Strings. We developed an algorithm a method to determine whether two arrays are equal (i.e. they have the same number of elements, and corresponding elements are equal). We then looked at the notion of storing a table of values in an array (Sec. 8.4). We began looking at basic algorithms for manipulating arrays (Sec. 8.5).

Lab 08. Oct 28-29. Abstract classes.    lab assignment    pdf file      files are obtainable from this page
This lab introduces you to the concepts of an abstract class and an abstract method and shows you the reason for using each one. It gives you practice with abstract classes using a set of classes that deal with shapes --parallelograms, rectangles, squares, rhombuses, etc.

Lecture 16. Oct 28. Arrays. There are no slides for this lecture. The guest lecturer, TA Jay Henniger, spent about 10 minutes reviewing the basics of arrays (how to draw an array object in the case of primitive type arrays and class base-type arrays, the length field, etc). He covered all of 8.2, using the examples in the text. Hewent through the development of the procedure to print out part of an array and discussed how it generalized to the schema on p. 244. Then, he used the schema to write a function to return a copy of an array (simplified to just return a copy of the whole array rather than a specified part of an array).

Lecture 15. Oct 23. Arrays. powerpoint slides    pdf file
We discussed the results of Prelim II and looked at the answers to 2 questions. We then began an introduction to arrays. This topic is covered in Chapter 8 of the text. In this lecture, we covered the basics: The fact that an array b is an object that contains a number of elements of the same type, which are numbered 0, 1, 2, ..., b.length. We looked at how to declare an array variable, as opposed to hot wo assign it a value (an object of an array type). We looked at the new-expression, e.g. new int[10] and new String[n]. And we showed how useful arrays were by showing how we could process an array of any size using a for-loop.

Lab 07. Oct 21-22. Practice with loops.    lab assignment    pdf file    java file
In this lab, you will develop four loops and test them using DrJava.

Lecture 14. Oct 21. Loops. powerpoint slides      pdf file    java file of demo
We introduce for-loops. Read Secs. 7.5 and 7.6. The java file for the demo contains a number of loops that we developed.

Lecture 13. Oct. 16. Loops. powerpoint slides    pdf file       java file of demo
We worked further with loops, talking about "loop patterns". We looked carefully at two loops to calculated b**c, for some c>=0. The ssecond loop, which was really fast, did its work by manipulating the binary representation of c. Read Sects. 7.1--7.4.

Oct 14-15. No formal lab (fall break). However, the lab will be open on Wednesday, 15 October, from 12:20 to 16:25, and TAs and consultants will be there to help you work on assignment A5, about bowling frames. You can also see a consultant in Carpenter basement or see Gries in his office during this time.

Oct. 14. No lecture (fall break).

Lecture 12. Oct 09. Loops. text file
We explain while loops again, going over the four loopy questions. We focus on the questions "How does it fix the invariant", meaning, how does the repetend keep the invariant true?

Lab 06. Oct 7-8. Loops. lab assignment    pdf file
This is a pencil-and-paper lab, where you get some practice with the four loopy questions concerning loops.

Lecture 11. Oct. 07. Loops. powerpoint slides    pdf file       java file of demo
We introduced loops, showing the syntax of the while loop and how the while loop is executed. We illustrated execution of the while loop using DrJava's debugger feature. We turned debugging on. We set a breakpoint at the initialization of a loop, and we then single-stepped through execution of a call on the method that had the breakpoint. We also turned on the line number display, and we "watched" variables. We then discussed how to understand a loop in terms of an invariant and the four loopy questions. Read Secs. 7.1 and 7.2.

Lecture 10. Oct 02. Miscellaneous. We covered apparent and real classes again. We saw how to draw a frame for a constructor call and visited again evaluation of a new expression. We were supposed to discuss object-oriented design but we did not get to it. Read: 4.2.1 again, as well as Sec. 2.7.

Lab 05. Sep 30-Oct 1. Class Vector. lab assignment    pdf file     skeleton program for lab
An instance of class Vector contains a list of Objects. (Remember that Object is the "superest" class of them all). This introduces ou to Vectors. Read Sec. 5.3.

Lecture 9. Sep 30. A model of execution. powerpoint slides    pdf file
We gave the format of a frame for a method call, we talked about the call stack of method calls that had not yet completed. And we showed how to execute method calls. Read Secs. 2.7, 3.5, and 4.6 --the last two are manly repetition of the first.

Lecture 8. Sep 25. Constructors. powerpoint slides    pdf file
This lecture discussed constructors in detail, both in normal classes and in subclasses. This called for a final explanation of how a new-expression is evaluated. The reading for this lecture is Secs. 3.1.3 and 4.1.3.

Lab 04. Sep 23-24. Writing methods. lab assignment    pdf file     skeleton program for lab
In this lab, we wrote some methods that played a guessing game. This gave you practice in writing methods and introduced you to random-number generation (see Sec. 5.6 of the text).

Lecture 7. Sep 23. More on methods. powerpoint slides    pdf file    methods for anglicizing integers
We finished talking about methods: rediscussed again functions vs. procedures, the return statement in a function, and static vs. non-static components. We then talked about topdown design (stepwise refinement). The example used was anglicizing integers. Sec. 2.4 discusses static vs. non-static methods. Sec. 2.5 discusses stepwise refinement.

Lecture 6. Sep 18. Discussion of methods. powerpoint slides   pdf form
The reading for this lecture and the next is sect. 2.3 of the text. We studied methods, defining parameter of a method, scope of parameter, and argument of a method call. We looked at how a method call is executed: drawing variables for the parameters, assigning the values of the arguments to the parameters, executing the statements in the body one by one, and then erasing the parameters. We introduced the condition astatments (if and if-else) and the block.

Lab 03. Sep 16-17. Strings and wrapper classes. lab assignment in pdf file
This lab will help you bceome familiar with class String and the methods in it. The wrapper classes are needed when we want to treat values of primitive types as objects. The wrapper classes also have some useful methods. The wrapper classes are discussed in Sec. 5.1. Strings are discussed in Sec. 5.2.

Lecture 5. Sep 16. Customizing a class to suit our needs. powerpoint slides. pdf file
There will be a short quiz! Everyone should get 100 out of 100! It is quiz 02. In order to help people with the having fields of class JFrame in classes FramingFrame and CrossFrame of the assignment A1, we looked at a class Person, which gave information about a person. One piece of information in a folder of class Person was the name of the folder tor the Person's mother. We then turned to the main topic of the day: static components of a class and the reason for having static components. Read the section on static components in Chapter 1 of the course text. Finally, we began our study of methods. Read Section 2.1 and start section 2.2 for next time.

Lecture 4. Sep 11. Customizing a class (cont). powerpoint slides. in pdf The .java file for the class that was developed in the 11:15 lecture.
We showed how to add a field to a class, by declaring a variable in the class. The variable had access modifier private so that it could not be accessed outside the class. We also discussed the value null, which represents the ABSENCE of the name of a folder. Finally, you saw your first method definition that contains a parameter declaration.

For this lecture, study Sects 1.6 and 1.8 of the text.

Lab 02. Sep 09-10.Creating objects, calling their methods, writing subclasses. lab assignment in pdf form
You get practice in creating manilla folders of class JFrame and other classes as well, and calling the methods in the manilla folders to do some tasks. Then, you write your first class definition in order to customize a class to suit your needs.

Lecture 3. Sep 09. Customizing a class to suit our needs. powerpoint slides. in pdf
There will be a short quiz! Everyone should get 100 out of 100!
We show how to customize a class to suit our needs. That is, we define a class that "inherits" all the methods and fields of a given class and then add a method or two to do some specific thing that we want done. As usual, we demonstrate all this in Dr. Java. Read Section 1.5 on "Customizing a class to suit our needs".

Lecture 2. Sep 04. Objects and classes. power point slides
We introduced the concept of a class as a file drawer of manilla folders (called objects or instances of the class), all with the same kind of information. We followed Section 1.4 quite closely, although we used JFrames and not URLs as the example. A manilla folder contains two things (a) fields, which are just variables, and (2) methods, which are descriptions of the processes or tasks that can go on inorder to deal with the folder. We created a few folder of class JFrame and showed how to write "method calls" in order to get something done. Methods fall into two categories. A function call is an expression and returns a value; a procedure call is a command to do something.

Lab 01. Sep 02-03. Java expressions. lab assignment in pdf form
The lab was devoted to practice in having our IDE, DrJava, evaluate Java expressions

Lecture 1. Sep 02. Java expressions. power point slides
The major part of this lecture was devoted to going over Java expressions, as discussed in Secs. 1.2 and 1.3 of the text. We introduced the notion of a type and types int, double, and boolean. We covered casting between int and double, and we also looked at function calls. We did not cover type String, but the basics of type String are covered in lab 1. We discussed variables and their declaration, as well as assignments to them. By the next lecture, you should have read Secs. 1.1, 1.2, and 1.3 of the text and looked at related activities in the CD ProgramLive.

Gries is happy with the way the lecture went. If any student has problems or constructive criticisms about the lecture, please email Gries. Especially students who have not had previous programming experience, please let Gries know on a continual basis how you are doing and what the problems are with the course and your learning the material.

Lecture 0. Aug 28. Introduction and Overview
We explained the difference between CS100J and CS100M and also discussed CS 99. We gave an overview of the course.