CS 111 Syllabus - Spring 2002
Note: This syllabus is sketchy. Content
will be added as the semester progresses, so check frequently!
Text: Objects Have Class! by Poplawski
-
Jan 10
Topics: Overview and Introduction to Java
Read: Chapters 1 and 2.
-
Jan 15 - 17
Topics: First look at classes, methods, statements (commands),
parameters, and variables.
Read: Chapter 3 and Appendix D on the Animator.
Lab 1: The BlueJ Java programming environment. Graphics and
animation with the Animator.
-
Jan 22 - 24
Topics: Variables, assignment, statements, scope.
Read: Chapter 4. Don't get bogged down in the examples (4.3
and 4.7). Initially read them to get the general idea of how they use the
concepts. For the second reading, focus on those that are related to what
we do in class and lab, and those that interest you. Note: All of the examples
are on the disk that came with the text. See the comment about this on
the
CS 111 Resources page.
Lab 2: User-specified ovals: requesting and responding to user
input and to the mouse.
-
Jan 29 - 31
Topics: First serious look at objects. Programs with multiple
classes and multiple objects. More on scope.
Read: Chapter 5. This chapter is packed with important things.
You will likely need to review things in this chapter several times throughout
the semester.
Section 5.2 introduces one of the most important
concepts in the course, multiple instances (objects) of a single class.
Carefully read and compare the various "sun and cloud" examples. Example
5.2.3 is not a good example because it consists of two classes with
nearly identical code. The author suggests this at the end of the example,
and indicates that there will be a better way to do it. That better way
comes in Section 5.5.
Section 5.3 is on scope, another very important
concept. One key observation to get on the first reading is that different
variables and methods can have the same name (identifier), just as different
people can have the same name.
Section 5.4 (the cart example) is good. Note that
there are two wheels (that is, two wheel instances or objects) even though
there is only one wheel class.
Section 5.5 is on constructors, another key concept.
Every object must be constructed, and a constructor often gives an object
its initial properties that distinguishes it from other objects of the
same class.
As in Chapter 4, the examples in Section 5.6 can
be initially read more lightly than the other parts of the text just to
get the general idea of how they use the concepts.
Lab 3: Defining and using multiple classes with multiple instances.
Making figures move on their own. Use of simple conditional (if) statements
and boolean expressions.
-
Feb 5-7
Topics: Interacting objects. More on conditional statements
(if, if ... else, case) and boolean expressions.
Read: Sections 6.1 and 6.2. All of Chapter 7 except 7.5.1-3
and 7.6.1.
In Section 6.2, remember that I have renamed the
click
method to mouseClick. Note that the author's Circle class is very
similar to our Ellipse class in that a Circle "knows" its center, and diameter,
and has methods to change its center (setCoordinates) and to draw
it. Don't worry about understanding the ClickListener class. We will study
the concept it illustrates when we return to the rest of Chapter 6.
Chapter 7 is largely about conditional statements,
but note the discussion of scope in 7.7.
Lab 4: Using if/else statements, boolean variables, and boolean
functions to make decisions. Counting things. Interface documentation.
-
Feb 12-14
Topics: Introduction to Machine Architecture.
Read: Handout on Machine Architecture.
Open lab for working on Project 1. Project
1 due Feb 15, 4:30 p.m.
-
Feb 19-21
Topics: Applets, events, and event handling. Basic GUI components.
Action events.
Read: Sections 6.2, 6.3, 6.4, 6.5, 6.7, and 6.11.
In 6.2 and 6.4 the concept of listener is introduced
and used. We will not be using the ClickListener as it is described in
the text. Instead, we will use MouseListener and MouseMotionListener next
week. Whenever the author has a type of listener, he makes a separate class
for it, even if there will be only one listener of that type. It seems
to me that this is more complicated than necessary (in fact the author
makes the point in 6.11 that it may be conceptually easier not to do this),
and so my initial examples won't have this feature. However, there are
cases in which a separate listener class is useful, and we will do examples
of this next week.
Section 6.4.2 contains a particularly relevant comment.
You may not understand it fully the first time you read it, but you should
make a point of coming back to it.
Also look over the interface for the JLabel, JButton,
JTextField, and ActionEvent classes on the Java Class Libraries web site.
For each of these, look at its description, constructor summary, method
summary, and methods inherited from its parent class. In particular, look
for the constructors and methods used in the text, in class, and in this
week's lab.
Lab 5: Working with Applets. Custom colors.
-
Feb 26 - 28
Topics: More on events and event handlling. Mouse events. Review.
Midterm
exam Mar 2.
Read: Sections 6.2, 6.6, 6.8, 6.9, 6.10,
and handout on mouse listeners and mouse events.
Lab 6: Using Mouse Methods and MouseEvents
to Make Draggable Rectangles.
-
Mar 3-7 Spring break
-
Mar 12-14
Topics: Repetiton. For and While Loops.
Read: Chapter 10. This chapter has lots of good examples.
Example 10.2.2 is related to this week's lab.
Section 10.8.1 gives a particularly good programming
technique for simplifying the thought process when working with nested
loops.
Lab 7: Working with Loops to Compute Compound Interest.
-
Mar 19-21
Topics: Working with Arrays
Read: Chapter 11 through 11.2.2.
Note that the clouds example 11.1.1 would be easy
to do using our Ellipse class instead of Poplawski's Cloud class. It would
need to be rewritten slightly because the Cloud class is written assuming
it will be used in the way that it is in this example, whereas the Ellipse
class is not. It would not be good to modify the Ellipse class for this
purpose; it would simply need to be used somewhat differently than the
Cloud class is used.
Examples 11.2.1 and 11.2.2 are particularly useful.
Note that he gives an incorrect way to find the maximum element of an array
on page 321, and then gives a correct way to do it on page 322. He gives
three ways to search for an element in an array in Example 11.2.2. Of these
three I dislike the second and third for the reasons he cites. He suggests
that a drawback of the first find method is the extra if/else
statement at the end, but it's easy to get rid of it by having the counter
run backwards.
If you have seen arrays before, you may want to
read about Java's Vector class (Section 11.3) and multidimensional arrays
(Section 11.5). Vectors are similar to arrays. They have some methods that
make them more convenient than arrays for some purposes, but they are somewhat
more cumbersome to use than arrays. The name "Vector" is unfortunate, as
Java Vectors have nothing in common with vectors you may have learned about
in mathematics or physics classes. Multidimensional arrays can be used
for matrices. I will not use Vectors or multidimensional arrays in this
class, but you may use them if you like.
Break statements are bad. Don't use them.
Lab 8: Dice Simulation and Gathering Statistics
-
Mar 26-28
Topics: Queues and Simulations, Introduction to Class Extensions
Read: Parts of Chapter 16: 16.1, 16.2, 16.3, and the beginning
of 16.8 (through the middle of page 487).
In 16.1 and 16.2, understand the distinction between
abstraction and implementation. I have been making this distinction all
along, but this makes it more precise. It is the difference between what
something does (its purpose) and how it does it. You can skim the coding
details in 16.2, as long as you understand what implementation means.
Section 16.3 is a brief description of JavaDoc,
which is what we have been using to create our class interfaces.
In Section 16.8, it's important to understand the
abstraction of a queue, but not its implementation.
Lab 9: Using a Queue in a Simple Bank Simulation
-
Apr 2-4
Topics: More on Class Extensions
Read: Sections 9.1, 9.6, 15.1, 15.3, 15.8.
We used class extensions with the Animator, although
you didn't need to understand them at that point. Our first real encounter
with them was in Lab 6, in which you created a DraggableRectangle class
by extending your Rectangle class (you should review how that lab started).
In Lab 9 you worked with a more involved example in which we used the WatchedQueue
class as an extension of the Queue class. These five sections from Chapters
9 and 15 describe some of the core ideas of extension without going into
too many technical details.
Open lab for working on Project 2. Project
2 due April 5.
-
Apr 9-11
Topics: Sorting, Searching, and Algorithm Efficiency
Read: Sorting: Section 11.2.4. Searching: Sections 11.2.2
and 17.4.2.
The sorting method discussed in the text is selection
sort. In addition to this, we will cover insertion sort and bubble sort.
The discussion of binary search in the text Section 17.4.2, is done in
the context of recursion. We will not cover recursion in this class. Read
17.4.2 to understand the algorithm, but ignore how it is coded.
Lab 10: Sorting Arrays of Data.
-
Apr 16-18
Topics: Applications, Text File Input/Output
Read: Chapter 12 and Sections 13.1, 13.2, 13.3.
In Chapter 12, the important things to understand
are the differences between applications and applets. Applications are
launched and terminated differently from applets, and they have more control
over the computer they run on than applets do. An application can involve
multiple windows (or none at all), it can read and modify files on the
drives attached to the computer, it can send things to a printer (although
I think this is possible with an applet to a limited extent). On the other
hand, an application cannot be put on a web page as an applet can.
Chapter 13 is quite technical, and it will be much
slower reading. File i/o is complicated because there are many types of
files and many types of things to read and write, and there are many things
that can go wrong (called exceptions). If you plan to do any further programming
in java or another language, you should be aware that we are only touching
the surface of these areas in this course.
We will only deal with reading and writing Strings,
specifically, lines of text. Writing is easier than reading, and Section
13.2 covers this more or less in the way that we will do it. Section 13.3
deals with reading text. An InputStreamReader reads a file one character
at a time, while a StreamTokenizer reads a file one "token" at a time (a
token is a sequence of characters or digits separated by spaces, tabs,
or line feeds). Both of these are fairly complicated to use. We will not
use either of them directly, so you don't need to understand every detail
of 13.3, although you should still read it to get the main ideas of what
is involved. Instead, we will use a class that Maharry has written called
a TokenFinder. It is similar to a StreamTokenizer, but is easier to use.
One key new concept in Chapter 13 is that of exception
handling. Sections 13.2 and 13.3 include a very brief introduction to exception
handling for file i/o. Exception handling comes up in many other contexts
besides file i/o, and Java has a large collection of classes and methods
for dealing with them.
At this stage, it is more important to know that
these technicalities exist and and understand something about them
than it is to try to understand them in detail. Many of the technical details
of text file i/o will be tucked away into two classes that Maharry and
I have written, called FileReader and FileWriter, so that you won't have
to deal with them directly. On the other hand, if you look at the details
of these classes and wonder what's going on, they are using many of the
details of file i/o and exception handling discussed in the text.
Lab 11: More on Algorithm Complexity, Reading From and Writing
To Text Files, Dealing with Strings
-
Apr 23-25
Topics: Bare
Bones Language. What I did during my summer vacation.
Open lab. Project
3 due 23 April.
-
Apr 29 - May 3 Final exam week Our
exam is Tuesday, 1:30 to 4:30.