CS100J Spring 2003. Summary of lectures

 

Section 12.03 April 22-23. This recitation is devoted to helping you learn Matlab. You can start on assignment 10, the Matlab assignment, during the recitation.

Lecture 25. 03 April 22. Matlab. We look at constructing and saving Matlab programs.

Lecture 24. 03 April 17. Matlab. We demonstrated matlab. We showed what most of its windows are for and spent most of the time demonstrating various Matlab expressions. Here is a handout on Matlab.

Section 11. 03 April 15-16. Abstract classes and review for prelim. If you missed material on abstract classes, review ProgramLiev lesson page 4-5 (on Abstract classes).

Lecture 23. 03 April 15. Brief look at Exceptions and Errors in Java

Lecture 22. 03 April 10. Multi-dimensional arrays.

Section 10. 03 April 08-09. Preparation for the prelim. Executing method calls, drawing folders.

Lecture 21. 03 April 08. We cover the concept of a Java application and the command-line commands java (for executing a Java aapplication), jar (for manipulating jar files), javac (for compiling java programs), and javadoc (for creating javadoc documentation. See this handout. As an example, we use the next assignment, which is to maintain statistics on a collection of bowling games. Here is the program (as a jar file) bowling.jar, which you can download and try. You also need the file of games. We also discuss the test and review a bit for it. There is a typo on the handout. It says that to execute a java program type "jar -jar ...". It should read "java -jar ...".

Lecture 20. 03 April 03.We studied multi-dimensional arrays, building a table of interest values (a rectangular array) and writing a program to compute n rows of Pascal's triangle. We discussed building a frame for a method call and exhorted everyone to memorize the steps in doing it.

What to do for the next lecture. Study Lesson pages 9-1 through 9-4 of ProgramLive.

Section 10. 03 April 01-02. We gave individual help (up to five students per instructor) on writing the next assignment, class Game.

Lecture 19. 03 April 01. We looked at selection sort and insertion sort and compared their running times --based on the number of comparisons they make-- in the best and worst cases. We stated what their average or expected cases were. We also looked a bit at multi-dimensional arrays.

What to do for the next lecture: Study slection sort and isnertion sort on Lesson page 8-6 of ProgramLive. You should be able to write down these algorithms --memorize the invariants, and be able to develop the algorithms from them.

Lecture 18. 03 March 27. We developed several algorithms that manipulate arrays, e.g. linear search, finding the minimum of an array segment, partitioning a segment. The emphasis was on developing a loop from its invariant. We ended with selection sort.

What to do for the next lecture: Watch on ProgramLive many of the activities on developing these algorithms, on Lesson page 8-5. You should memorize the postcondition and invariant of each of these algorithms on this page and then be able to develop them yourself. This take practice.

Section 9. 03 March 25-26. The normal recitations are scrapped. Instead, we have individual sessions with at most five students. We went over some definitions, and we had hands-on development of part of the next assignment.

Lecture 17. 03 March 25. More on arrays. We looked at array initializers. We rewrote the function from the dates project that returned the month name given the month, and we wrote a function to give the month number given a month. We wrote a function to produce a string giving the values in an array. We wrote a function to test whether to arrays are equal. See this file for the programs.

We also discussed class java.lang.Class.Class, which allows you to find out information about an instance of a class --what class it is, what fields it has, and so on. The file linked to in the previous paragraph has a method classes that illustrates its use.

What to do before the next lecture. Study the method in the file for this lecture. Execute a call on method classes and analyze the output. Study lesson pages 8-3 and 8-4 of ProgramLive.

Lecture 16. 03 March 13. Reading and writing files. In order to explore arrays, we need a way of populating them with useful values. In preparation for that, we show how to read from a file. If time permits, we'll show how to write a file as well. This material is covered on lesson pages 5-7 and 5-8 of ProgramLive. Here's class IO, which we used during lecture.

What to do before the next lecture. Study the material on input/output. But you won't internalize this I/O stuff until you write some Java programs that actually write a file. So, please, write some programs that write a sequence of values on some new file. You need PRACTICE!

PRELIM. 03 March 13. Uris Auditorium, 7:30 -- 9:30 PM.

Section 8. 03 March 11-12. Review for prelim (which is in the evening of 13 March).Don't miss the section. It will give you a perspective on the exam and show you what we consider to be important.

Lecture 15. 03 March 11. Arrays. We introduced arrays, as done on Lesson page 8-1 of ProgramLive. We used GUI JLiveWindow in statements to declare an array, create and array, read in 7 values and store them in the array, and print them in reverse order. We looked at notations for describing arrays, as discussed on lesson page 8-2.

What to do before the next lecture. Study the material on arrays mentioned above. Practice in DrJava with creating and using arrays.

Lecture 14. 03 March 06. Loops. We developed two algorithms for computing a**b for integer b>=0. One took time proportional to b, the other took time proportional to the base 2 logarithm of b. We saw how to time execution of an algorithm, using the time given by class Date. We introduced the for loop and wrote a number of for-loops.

What you should do before th next lecture. Watch activity 7-2.3 of ProgramLive, on exponentiation. Look at Lab 2 in lesson 8 of ProgramLive, which shows you how to use class Date to time execution. Watch the activities on lesson page 7-4. Watch the activities on lesson page 7-6. You should also practice writing loops. Besides the assignment you had, do some of the exercises in the third lab in lesson 7 of ProgramLive. The algorithm to computer a**b can be obtained from ProgramLive.

Section 7. 03 March 04-05. Review for prelim (which is in the evening of 13 March).Don't miss the section. It will give you a perspective on the exam and show you what we consider to be important.

Lecture 13. 03 March 04. Loops. We introduced the idea of a schema for processing natural numbers h..k-1, where h<=k. We discuss why we use a loop conditon h != k instead of h < k --the answer is surprising to most.

We use it to develop a loop to count the number of w's in a String and to write a function that tests whether an integer is prime. We also look at schemas for processing the numbers h..k and for processing h..k in reverse. We also look at a function to compute x**y. If time permits, we move on to the for-loop and show how it can be viewed as an abbreviation of a while-loop.

What to do before the next lecture. Study pages 7-2 and 7-3 of ProgramLive. Also, watch activity 7-5.2, "On the loop condition k !+ n".

Lecture 12. 03 February 27. Loops. We looked at or developed four loops

(1) A loop that drew 2000 lines, creating beautiful lines depending on the angle at which adjacent lines are drawn. Here's the program, and you can find a lecture on it in ProgramLive, page 7-1: Spiral.java   JLiveWindow.java.    MyJLiveWindow.java.

(2) The loop in the roach problem. See lesson page 7-1 of ProgramLive.

(3) Two loops in methods of a previous assignments on dates. We don't show that here.

What you should do for the next lecture. Memorize the checklist for understanding a loop. Practise developing a loop invariant from a postcondition and then developng the loop on problems you have seen before; this will build confidence in your ability and get them methodolegy into your system. Then do the homework for Tuesday. Remember, check out these loops in DrJava to make sure they are right.

Section 6. 03 February 26-27. Loops. This section reinforces material on loops that waas introduced in lecture 11.

Lecture 11. 03 February 25. Loops. We will spend several lectures studying loops, as discussed in lesson 7 of ProgramLive. This first lecture will introduce while loops. An important part of being able to develop loops is the use of an invariant, to describe the variable used within the loop.

After the class, study lesson pages 7-1 and 7-2 of ProgramLive. Also, you have a paper-and-pencil assignment, to be handed in at the beginning of lecture on Tuesday, 4 March: labs 1 and 2 of lesson 7 of ProgramLive.

Lecture 10. 03 February 20. Object-oriented design. This lecture will discuss the design of programs that use classes, and subclasses, giving an overall idea of how one goes about it. A bunch of classes/subclasses will be designed that illustrate the approach. The lecture should firm up for students their understanding of inheritance, overriding, and casting.

After the class, study lesson page 4-4 of ProgramLive.

Section 5. 03 February 18-19. Class Vector . Class Vector allow one to create and maintan a list of objects. The object can be of any class-type, and objects can be added to and deleted from the list at any time.

After attending this lecture, you should study ProgramLive lesson page 5-5, on class Vector.Then, start DrJava on your computer and practice creating an instance of class Vector and using it. Practice using all the methods in it, so that you have a good feel for how Vectors work.

Lecture 9. 03 Feb 18. More on frames for calls and program development. .

For next time, you should study in ProgramLive:

After the lecture, if we have time to develop a method, we will place a link to it here.

Lecture 8. 03 Feb 13. Method bodies and stepwise refinement. We develop several method bodies, using the method of "stepwise refinement", or "top-down development". Particular emphasis is laid on the definitions of local variables that are used throughout the method body. The technique we develop in the roach-explosion problem can be used in assignment 4 in writing several functions.

Some important points:

Here's the roach program that we wrote. A version of the anglicize program can be found on lesson page 2-5.

For next time, you should study in ProgramLive:

Section 4. 03 February 11-12. Casting about . This section dicusses:

You should study:

The recitation may deal with a few classes Employee, VIP, and Salaried. You can download them. Also, here are some rules about casting and all.

Lecture 7. 03 Feb 11. Method bodies. We begin to look more closely at

For next time, you should study in ProgramLive:

Lecture 6. 03 Feb 06. Superclasses, subclasses, constructors. We discussed:

For next time, you should:

Section 3. 03 February 04-05. Wrapper classes. We discussed:

You should study lesson pages 5-1 and 5-2 of ProgramLive.

Lecture 5. 03 Feb 04. Static methods and fields. We discussed:

Before the next lecture, you should:

Lecture 4. 03 Jan 30. Putting fields in classes. We discussed:

Before the next lecture, you should:

Section 2. 03 Jan 29-30. Discussion of class String.You should read ProgramLive lesson page 5-3.

Lecture 3. 03 Jan 28. Extending a class to do more. We discussed:

Before the next lecture, you should:

Lecture 2. 03 Jan 23.Writing method calls and using classes. We discussed:

What you should do this weekend.

Section 1. 03 January 22-23. DrJava and type boolean. We discussed:

You should download DrJava and practice using its interactions pane. You should also study Lesson page 6.6 on type boolean.

Lecture 1. 03 Jan 21.Expressions in Java. We discussed:

By the next lecture, you should have spent some time playing with DrJava and memorized: