Queen's Logo

CISC 124: Introduction to Computing Science II

(Fall 2002)

Slides and Examples

(last modified  )

[Home] [Schedule & Readings] [Exams & Grading] [Assignments] [Slides & Examples
[Announcements] [Resources] [Java] [WebCT] [photos]

I will be using this area to post the slides & example code I use for my lectures.

The slides are posted in PDF format: a full-size version fo viewing online and one compressed to four slides to a page for printing.  I believe any public labs you may be using will have PDF readers.  If you don't have a PDF reader on your home machine, you can install a free one from Packman or directly from Adobe.

Along with each set of slides will be the source code for most of the example programs I use in my lectures.  Please feel free to download, run, and experiment with
these.  I've made every effort to debug my examples thoroughly, but if you find a bug please tell me.

I try to have my slides finished and posted a day before I actually use them, but that's not always possible.  If you don't see the topic you're looking for yet,
remember to refresh your screen before you give up; you may be looking at an old version.  Topics are listed in reverse chronological order, so the most recent is first.  The dates for each topic are only guesses when I post them ahead of time; it's often difficult to predict exactly how long a set of slides will take.
 

date(s)
topic 
full-size PDF 
4-up PDF 
example code
28 Nov Cloning set 22 PDF set 22 4-up PDF Cloning Examples
25 Nov Packages set 21 PDF set 21 4-up PDF Package Examples
18 - 21 Nov I/O
(complete)
set 20 PDF set 20 4-up PDF I/O Examples
7 - 13 Nov Collections set 19 PDF set 19 4-up PDF Collections Examples
5 Nov Graphics set 18 PDF set 18 4-up PDF Graphics Examples
4 Nov Swing, part 6
(calculator example)
set 17 PDF set 17 4-up PDF Calculator.java
last year's Swing assignment:
    description
    sample solution
31 Oct Swing, part 5
(other components)
set 16 PDF set 16 4-up PDF TextFieldDemo.java
TextAreaDemo.java
MenuDemo.java
28 & 31 Oct Swing, part 4
(button actions)
set 15 PDF set 15 4-up PDF button action examples
24, 28 Oct Swing, part 3
(layouts)
set 14 PDF set 14 4-up PDF layout examples
22, 24 Oct Swing, part 2 
(buttons & labels)
set 13 PDF set 13 4-up PDF  
21, 22 Oct Swing, part 1
(intro)
set 12 PDF set 12 4-up PDF Swing examples 1
15, 17 Oct
(more slides added
 16 Oct)
Iterators set 11 PDF set 11 4-up PDF Iterator examples
8 Oct midterm 1 review Midterm1Review.pdf Midterm1Review-4up.pdf ReviewExamples.java
(more or less covers all 
the examples we did in class)
3, 7 & 8 Oct Exceptions set 10 PDF set 10 4-up PDF set 10 examples
30 Sept & 1Oct Generic Code set 9 PDF set 9 4-up PDF set 9 examples
26 Sept 02 Inner Classes set 8 PDF set 8 4-up PDF LinkedList.java
26 Sept 02 short extra set set 7 PDF set 7 4-up PDF  
24 & 26 Sept 02 Abstract Classes
& Interfaces
set 6 PDF set 6 4-up PDF Stacks, version 1
Employee, version 2
example of abstract class
19 & 23 Sept 02
(examples at end 
changed 22 Sept)
Polymporphism set 5 PDF set 5 4-up PDF Exercise1.java
Exercise2.java
Exercise3.java
16-19 Sept 02
(typos corrected 17 Sept)
Inheritance set 4 PDF set 4 4-up PDF Inheritance examples
10&12 Sept 02 Basic Classes part 2 set 3 PDF set 3 4-up PDF Student2.java
TestMystery.java
Aliasing.java
9&10 Sept 02
(typos corrected 11 Sept)
Basic Classes part 1 set 2 PDF set 2 4-up PDF Student.java
 9 Sept 02 Introduction set 1 PDF set 1 4-up PDF  

Cloning Examples
I made 4 different versions of the examples to illustrate different ways of copying and/or aliasing.
    Version 1: aliasing
        Time.java   Appointment.java   Datebook.java
    Version 2: shallow copy
        Time.java   Appointment.java   Datebook.java
    Version 3: deep copy
        Time.java   Appointment.java   Datebook.java
    Version 4: deep copy using clone() and Cloneable:
        Time.java   Appointment.java   Datebook.java

Package Examples
        UsesStacks.java: simple test program that uses the Stacks package
        The Stacks package consists of the following 4 files.  They must be put in a folder called "Stacks", as explained in the lecture:
           Stacks.java
           ArrayStack.java
           LinkedStack.java
           StackException.java

I/O Examples
        OutputStreamDemo.java
        PrintWriterDemo.java
        FileClassTest.java
        BufferedReaderDemo1.java
        BufferedReaderDemo2.java
        Employee.java: new version with binary I/O added
        Company.java

Collections Examples
        HashSetDemo.java
        TreeSetDemo.java
        SetAliasing.java
        LunchTesterSetSolution.java
        HashMapDemo.java
        MapIteratorDemo.java

Graphics Examples
        PaintDemo1.java
        PaintDemo2.java
        PaintDemo3.java
        PaintDemo4.java
        PaintDemo5.java
        PaintDemo6.java

Button Action Examples
     This series of programs are different stages or versions of the demos done in class:
        ButtonAction1.java
        ButtonAction2.java
        ButtonAction3.java
        ButtonAction4.java
        ButtonAction5.java
        ButtonAction6.java

Layout Examples
    These three are approximations to the demos I will do in class.
        BorderDemo.java
        FlowDemo.java
        GridDemo.java
    The panel demonstration -- we looked at pieces of this on the slides
        PanelDemo.java

Examples For Swing, Part 1
        My "baby swing" examples.  The first few represent stages in the demo I did in class.  The rest are from the slides.
           BabySwing1.java
           BabySwing2.java
           BabySwing3.java
           BabySwing4.java
           BabySwing5.java
           BabySwing6.java
           BabySwing7.java
           BabySwing8.java
           BabySwing9.java
       Savitch's simple window listener class:  WindowDestroyer.java

Iterator Examples:
        yet another version of stacks, using iterators:
           Stack.java
           ArrayStack.java
           LinkedStack.java
           IteratorDemo.java (uses the stack iterators)
       Matrix.java
      Practice problem reference: doubly-linked list code from CISC 121.
           IntDLList.java (doubly-linked list class)
           IntDLLNode.java (nodes for doubly-linked lists)

Inheritance Examples:
        Employee.java: basic class describing plain employees
        Salesperson.java: subclass of Employee for salespeople who receive commissions
        Executive.java: subclass of Employee for executives who receive bonuses
        Unionized.java: subclass of Employee for unionized workers who get overtime pay
        PayrollDemo.java: demo program for all of the above classes

Stacks, version 1:
        Stack.java: interface
        ArrayStack.java: array implementation
        LinkedStack.java: linked list implementation
        StackDemo.java: test/demo program

Employee, version 2:
        New version of the inheritance example, with equals and compareTo added:
           Employee.java
           Salesperson.java
           Executive.java
           Unionized.java
           TestEquals.java: short test program, just testing equals and compareTo

Abstract Class Example:
        The first assignment from last fall's CISC 124 is a good example of a program using an abstract class.  Follow links from that term's assignment page to assignment 1 and its solution.

Set 9 Examples:
        updated version of Employee.java: I added a toString to make some of the demos easier to write
        Generic Stacks:
           Stack.java: interface
           ArrayStack.java, LinkedStack.java: two implementations
           StackDemo.java: demo program
        ShuffleClass.java: generic "shuffle" method
        SeqSearch.java: generic sequential search method
        GenericSort.java: a generic selection sort plus demos of API sorting with and without Comparators
        NameComparator.java, WageComparator.java: two Comparators for use with Employee objects
        VectorDemo.java: a simple demonstration of Vectors

Set 10 Examples:
        Another version of Stack example, this time adding exceptions:
           Stack.java
           ArrayStack.java
           LinkedStack.java
           StackDemo1.java, StackDemo2.java: two different demo programs with different exception-handling strategies
        Versions of the demo I did in class:
           NumExcept1.java
           NumExcept2.java
           NumExcept3.java
           NumExcept4.java
        Other examples from the slides:
           CatchLevels.java
           FileInputExample.java
           MultCatch.java

This page created by Margaret Lamb, Queen's University, Kingston, Ontario.  Last modified  .