CPSC 225: Introductory Programming


   Department of Mathematics and Computer Science
   Hobart and William Smith Colleges

   Spring, 2002.

   Instructor:  David J. Eck  (eck@hws.edu)

   Monday, Wednesday, 11:15 -- 12:10.
   Room Lansing 300.

   Course Handout:  http://math.hws.edu/eck/courses/cpsc225_s02.html


General Information


Assignments and other information about this
course, will be posted on this page as it is taught
during the Spring term of 2002.


Fifteenth Week: End of Term and Final Exam

The last day of class is Monday, April 29. The final exam will take place on Saturday, May 4, at 7:00 PM in our regular classroom. An information sheet is available with more information about the exam and a list of my office hours.

Enjoy the summer!


Fourteenth Week: April 22, 24, and 26

As we finish the term, we turn to one of the most important aspects of C++, its implementation of inheritence and polymorphism. The reading on this material is Chapter 14 and Chapter 15 in the text.

Changes in assignments: As we discussed in class on April 19, Assignment 8 is now due at 4:00 on Thursday, April 25, instead of on April 23. It can be turned in with a 20% penality until 4:00 PM on Sunday, May 5. The final project (a program of your choosing) has been made optional. If you do it, it will replace one of the assignments 1 through 7 on which you have a low grade. (It will not under any circumstances replace Assignment 8, which is not optional.) You should consider doing a final project if you have not done one on one of the earlier assignments. It can be turned in, with no penality, any time up to 4:00 PM on Sunday, May 5.


Thirteenth Week: April 15, 17, and 19

The C++ standard includes a large libray of templates called the Standard Template Library (STL). The STL includes both class templates for things like stacks and queues and function templates for algorithms such as sorting. We will be looking at the STL this week. The reading is Chapter 19.

The eighth programming assignment is due next Tuesday, April 23, at 4:00 PM. We will spend some time this week on finite automata, which are used in Part 2 of the assignment.

The final quiz of the term is coming up next week, on Monday, April 22. It will cover templates, stacks, postfix expressions, queues, and whatever parts of the standard template library we have time to cover this week.


Twelfth Week: April 8, 10, and 12

This week, we will be talking about templates. You should read Chapter 16, which introduces templates. We will be looking at template classes for stacks and queues. You can read the book's version of this in Section 17.2. However, the versions that I cover in class will not use namespaces.


Eleventh Week: April 1, 3, and 5

The second midterm test is on Friday. An information sheet is available.

We will spend Monday and Wednesday reviewing for the test, if necessary and talking about the Genetic Algorithm. You should be sure to read the handout from the book Artificial Life. We will discuss the type of program that you will write for the next programming assignment, which will use the Genetic Algorithm.


Tenth Week: March 25, 27, and 29

On Monday, we will continue to discuss binary trees and look at binary sort trees. Assignment 7 deals with binary sort trees. This material is covered in Section 17.4 of the text, but that section uses material on templates that we haven't covered yet. The plan is to cover template classes later, using trees and lists as examples.

On Wednesday, we will look at one more example of recursion: evaluation of arithmetic expressions such as 2*(3.1+4)/((7.99-2)*3). After that, we will be spending some time on more advanced features of classes from Chapters 14, 15, and 16. You can begin reading Chapters 14 and 15. We will also be looking at something called the genetic algorithm, which will be the topic of the next programming assignment.

There is a test coming up on Friday of next week.

Final Project: As I mentioned in class, the final assignment for this class is to come up with an idea for a programming project and to do it. It will only count for 30 points, and it does not have to be much longer than the rest of the assignments for the class. The main point is for you to design a project that you want to do. I might throw out ideas for projects in class, but I will not specify any details. The project can be either a program or a small library of classes that could be useful in a variety of programs. You are encouraged to discuss your ideas with me. The project can be turned in any time up to the day after the final exam. (The exam is on Saturday, May 4.)


Ninth Week: March 18, 20, and 22

We will spend the week talking about linked data structures and recursion. Chapter 13 of the text covers recursion, but not its application to linked data structures. Read Chapter 13, but also pay attention to the examples I do in class.

I will hand out a fairly short assignment on Monday, which will be due next Monday.

There is a quiz on Wednesday of this week, March 20. It will cover operator overloading, pointers, and simple linked lists. The material is from Section 8.1, Chapter 10, and Section 17.1 (pages 690 to 710 only).


Eighth Week: March 4, 6, and 8

We will finish Chapter 10 on Monday and then turn to the first part of Chapter 17 (up to page 709). The rest of Chapter 17 depends on "templates", which we haven't covered yet, so you should not read it at this time. However, I will talk about a non-template version of binary trees. Even though binary trees are only covered briefly in the text, we will use them in several examples and assignments.

Next week is Spring break. There will be a quiz on the Wednesday after Spring break, March 20. You have a programming assignment due this week. There will be no new assignment until after break. The next assignment, which will probably used linked lists, will be posted before the end of break.


Seventh Week: February 25 and 27; March 1

We will move right along to Chapter 10, which introduces pointers, and we will begin Chapter 17 before the end of the week. We will cover only three chapters during the next four weeks, but we will do some examples and applications that are not in the text. I might also fill in some details that we glossed over in earlier chapters.

Programming Assignment 5 is available.

My answers to Test 1 are available.


Sixth Week: February 18, 20, and 22

There will be a test on Friday of this week. An information sheet is available.

The fourth programming assignment is due on Wednesday of this week (but I will accept it on Thursday and count it as being on time). You can use my solution for Assignment 3 as a basis for Assignment 4, if you want. You will find it in the file /home/cs225/life/life_without_files.cc.

I will finish talking about strings and files on Monday. After that, we will move on to some material from Chapter 8. The Chapter 8 material will not be on the test. Although you should probably read it, I will not cover everything in Chapter 8.


Fifth Week: February 11, 13, and 15

The reading for the week is Chapter 9 (on strings) and Section 12.1 (on files). On Monday, we will finish up Chapter 7 and (hopefully) do a brief introduction to strings. We will jump to Section 12.1 on Wednesday, so you will have the information on files that you need to do the next programming assignment. On Friday, we will return to Chapter 9 for a more detailed look at strings.

Programming assignment will to complete the Game of Life program by implement the Save and Load commands. I will give you more information about the assignment in class on Wednesday.

Your third programming assignment is due on Wednesday. Don't forget to put a copy in your homework directory. If the assignment is done by Thursday at noon, I will accept it. There is a quiz on Monday this week, and there is a test coming up next week.

The fourth programming assignment will be due next Wednesday.


Fourth Week: February 4, 6, and 8

This will be the last week of the course in which you will simply be learning the C++ version of material that you already know from Java.

The reading for the week consists of Chapters 6 and 7. This covers the basic of using classes in C++. There are many differences between classes in Java and classes in C++, and C++ classes have several features that have no corresponding feature in Java. However, the material in these first two chapters on C++ classes is pretty basic, and if you understand Java classes, you should have little trouble with it. The more difficult features will come later.

There is no programming assignment due this week. There will be a quiz next Monday, February 11.


Third Week: January 28 and 30; February 1

There is a quiz on Monday of this week. It covers everything we have done in class so far, that is up to about page 150 in the textbook. You should expect to be asked to write some C++ code and to answer a few short "essay-type" questions. The quiz is one page long and counts for 2% of your final grade in the course. (Note: The next quiz will be in two weeks, on February 11.)

We will begin the week by finishing up the discussion of functions in C++, then we will turn to the topic of arrays and the next programming assignment. The reading assignment for the week is Chapter 5.

Your second programming assignment is due on Wednesday. Don't forget to put a copy of the source code and executable in your homework directory.

The third programming assignment will be to add an implementation of the so-called "Game of Life" to the Curses menu from assignment two. The Game of Life is described in the textbook as Programming Project 9 of Chapter 5, page 220. However, I will be handing out more details about the assignment on Wednesday, when the second programming assignment is due.

Information about the third programming assignment can be found at

                http://math.hws.edu/eck/cs225/s02/assg3.html

Second Week: January 21, 23, and 25

For this week, you should read Chapters 3 and 4 in the textbook. (In class, we will begin this material on Wednesday and carry it over into the beginning of next week.) These chapters cover C++ subroutines, except that in C++ they are always referred to as functions, whether or not they return a value.

The major new idea in this reading is passing parameters by reference. This is covered in Section 4.1, pages 137--145. Another useful feature is default arguments (page 159--161). A C++ technicality that you have to be aware of is function prototypes (page 104). The book uses them in all its examples, but I will not use them so consistently.

Programming Assignment Two: Write a "curses" program that does the same thing as the curses_menu program in the directory /home/cs225. Define several helper functions and use them in your main routine. This assignment is due in class next Wednesday, January 30. Please make a printout using a2ps, and put your program in your homeword directory so that I will be able to find it easily and try it out.


First Week: January 16 and 18

For your first reading assignment, you should read Chapters 1 and 2 of the textbook. Note that the book includes many short self-test exercises throughout each chapter. It is a good idea to do these exercises as you work through the reading. The answers are at the end of the chapter. It's also a good idea to write, compile, and run some short sample programs to solidify your knowledge of the material.

The reading covers "programming in the small" in C++. Much of this is the same in C++ as in Java. However, you will find a few major differences. Console input and output (done with System.out and TextIO in Java) is very different in C++. You should read Section 1.3 carefully to learn about it. Also, C++ has free-floating subroutines and variables, which are not contained in any class. In particular, the main() routine of a program cannot be a member of a class. See the sample program in Section 1.1 for the basic format of a C++ program. Also see Section 1.5 for the #include directive and the idea of namespaces. Most of the rest of Chapter 1, which covers types, variables, and expressions, will be familiar to you from Java. Note that the name for the Boolean type in C++ is bool rather than boolean, and that an int value can be used where a bool is expected. Also note that the char type is only 8 bits and represents ASCII, not Unicode, characters. Although there are many primitive types, you should probably stick to int, double, bool, and char in your programs.

Chapter 2 deals with control structures, such as if statements and while loops. You might want to skim quickly through most of this chapter, since this material is essentially identical in Java and in C++. However, there is one item that is completely new: enumeration types, which are introduced on page 64.

The first programming assignment is Programming Project 2 from Chapter 2 of the textbook (page 89). This is due in class on Wednesday, January 23. Make a printout of your program using the a2ps command, and turn it in in class.