|
This page documents what we do in class. It contains Java programs that we will discuss in class, reading assignments from our textbook, simple homework exercises that you can work on for practice and exam preparation (not for credit), links to other sources of information, etc.
The reading assignments and practice problems are listed by the date on which they were assigned. The sample program files are listed by the date on which they were used. When you are viewing a source code page, you can use your browser's "File -> Save As..." menu item to save a copy of the code on your computer. It is a good idea for you to "play" with these example programs; compile them, run them, make simple changes to them and compile and run them again.
|
- Monday, December 3.
- Here is a list of exercises from the end of Chapters 6, 7, and 9 in the textbook. This list is meant to give you an idea of what kind of problems can be on the next midterm exam.
- Chapter 6: R-6.1, R-6.3, R-6.5, R-6.6, R-6.16, C-6.7, C-6.8.
- Chapter 7: R-7.1, R-7.5, R-7.8, R-7.10, R-7.11, R-7.12, R-7.14, R-7.19, R-7.20, R-7.25, C-7.4.
- Chapter 9: R-9.4, R-9.5, R-9.6, R-9.14
- Wedneday, November 28.
- For Monday, read Sections 9.1 and 9.2 (pages 368-388) from the textbook.
- Here is a program that provides a reasonable way to create binary tree objects.
- Monday, November 26.
- See the homework page for your ninth homework assignment.
- For Wednesday, read Sections 7.3.4 (pages 287-295) and 7.3.6 (pages 298-304) from the textbook.
- Here is a zip file containing all the Java files about trees from Chapter 7.
- Monday, November 19.
- For next Monday, read Sections 7.1, 7.2, and 7.3.1-7.3.3 (pages 266-286) from the textbook.
- Here is a zip file containing some examples of recursive functions.
- Wednesday, November 14.
- See the homework page for your eighth homework assignment.
- Wednesday, November 7.
- Read Section 3.5 (pages 134-148) from the textbook.
- Here are inheritance diagrams for the LinkedList and ArrayList collections from the Java Collection Framework.
- Here are two tutorials, from Sun, about the Java Collections Framework. The first one is a "Trail" from Sun's Java Tutorials. The second one is not about the generic version of the Collection Framework, but it is still a useful tutorial.
- Monday, November 5.
- See the homework page for your seventh homework assignment.
- Read Section 6.4 (pages 249-252) from the textbook.
- Here is more information about iterators.
- Monday, October 29.
- The midterm exam will be this Wednesday, October 31.
- Monday, October 22.
- Read Sections 6.2 (pages 231-241) and 6.3 (pages 242-248) from the textbook.
- Here is a list of exercises from the end of each chapter in the textbook. This list is meant to give you an idea of what kind of problems can be on the midterm exam.
- Chapter 1: R-1.7, R-1.8, R-1.10, R-1.11, C-1.1, C-1.2.
- Chapter 2: R-2.1, R-2.5, R-2.9, R-2.10, R-2.11, R-2.15, C-2.5.
- Chapter 3: R-3.5, R-3.7, R-3.8, R-3.14, C-3.2, C-3.7, C-3.8, C-3.9.
- Chapter 4: R-4.6, R-4.7, R-4.12, R-4.21, R-4.34.
- Chapter 5: R-5.3, R-5.6, R-5.9, R-5.10, R-5.11, C-5.1, C-5.4, C-5.9.
- Wednesday, October 17.
- Read Sections 5.3 (pages 213-216) and 6.1 (pages 222-230) from the textbook.
- Here is a zip file containing the example programs from Chapter 5 of the textbook.
- A good exercise to help you understand the stack, queue and deque interfaces is to look at the way different libraries define them. Here are links to the documentation for stacks from several different libraries.
- Here are links to the documentation for queues from several different libraries.
- Here are links to the documentation for deques from several different libraries. Notice that several of the above stack and queue implementations are subclasses of these deques.
- The deque object from the Python library.
- The Deque Interface from our textbook.
- The Deque Interface from the Java JDK.
- The deque class from the C++ STL (here is another way to document this class).
- The deque class from Microsoft's implementation of the STL.
- A Deque class written in C#.
- Monday, October 15.
- See the homework page for your sixth homework assignment.
- Read Section 5.2 (pages 204-212) from the textbook.
- Wednesday, October 10.
- Read Sections 4.2 (pages 162-175) and 5.1 (pages 188-203) from the textbook.
- Here is a zip file containing the permutation algorithms that we looked at in class.
- Wednesday, October 3.
- See the homework page for your fifth homework assignment.
- Read Sections 3.4 (pages 128-133) and 4.1 (pages 154-161) from the textbook.
- Here is a zip file containing the linked list code for Chapter 3.
- Wednesday, September 26.
- See the homework page for your fourth homework assignment.
- Read Sections 3.2 and 3.3 (pages 115-127) from the textbook.
- Monday, September 24.
- Here is a program that demonstrates a simple example of a parameterized "generic function".
- Wednesday, September 19.
- Here is a program that demonstrates a simple example of a (non-parameterized) "generic function".
- Monday, September 17.
- Read Sections 3.2 and 3.3 (pages 115-127) from the textbook.
- Wednesday, September 12.
- See the homework page for your third homework assignment.
- Read Section 3.1 (pages 96-114) from the textbook.
- Here are three programs that motivate and demonstrate some basic ideas of "generic programming".
- Here are two lessons, from Sun's The Java Tutorials, about Java Generics. The first lesson is an introductory one and the second lesson is more advanced.
- Wednesday, September 5.
- See the homework page for your second homework assignment.
- Read Section 2.5 (pages 85-90) from the textbook.
- Wednesday, August 29.
- Read Section 2.4 (pages 80-84) from the textbook.
- Monday, August 27.
- Be sure to look at the homework assignment page. Your first assignment is already listed there.
- We will not go over in class Chapter 1 from the textbook. You should use this chapter as a reference (along with your CS 123 Java textbook) for basic Java concepts.
- Read Sections 2.1, 2.2 and 2.3 (pages 58-79) from the textbook.
- The following five groups of files give an extended example of how implementation can be separated from the public interface of a class. (There are a lot of files here. If you wish, you can download them all as a zip file).
- The next two files give two different implementations of a Hat class. Both of the implementations provide the exact same public interface. The third file uses the Hat class, and it can use either implementation since the two implementations have the same public interface.
- The next file defines an abstract Hat class and the two files after it give two different implementations of the abstract Hat class. The UseHat program shows how the two implementations of the Hat class can be used at the same time.
- The following six files give an example of using both inheritance for specialization and inheritance for implementation. The AbstractHatItem and AbstractGloveItem classes extend the OrderItem class and they provide two different kinds of items that can be ordered. The HatItemA and HatItemB classes provide two different implementations of the AbstractHatItem class, and the GloveItem class provides an implementation of the AbstractGloveItem class.
- The following example redoes the last example but it uses interfaces to define the public interface of a hat and a glove item (instead of abstract classes). So now the HatItemA and HatItemB classes both extend OrderItem and they both implement the HatInterface. And the GloveItem class extends OrderItem and implements the GloveInterface.
- The following example redoes the last example to show that classes can implement multiple interfaces (but classes can only inherit from one parent class). In this example we add a Returnable interface that an OrderItem can implement and we make the GloveItem class implement this interface. So now the HatItemA and HatItemB classes both extend OrderItem and they both implement the HatInterface. And the GloveItem class extends OrderItem and implements both the Returnable interface and GloveInterface. (Only the files that need to be changed for the last example are given below.)
|
|
|
|