| Chap | Assignment |
1 |
Introduction to Computers, the Internet and the Web
Students are assumed to be aware of this topic generally from Computer Programming 101. However, the following
specific readings are assigned as that background is essential to understanding later material in this course.
- 1.8 History of Java (12-13)
- 1.9 Java Class Libraries (13-14)
- 1.13 Basics of a Typical Java Environment (16-19)
- 1.14 General Notes about Java and This Book (19-21)
- 1.15 Thinking About Objects: Introduction to Object Technology and the Unified Modelling Language (22-26)
- 1.16 Discovering Design Patterns: Introduction (26-28)
|
NOTE |
BRING & USE YOUR OWN EARPHONES! BRING THEM EVERY DAY!!
One of the most effective resources that we use in our lab for learning to program in Java are explanations of
the source code of programs by the author in the author's own voice. Students may listen to the explanations
while they simultaneously observe and experiment with the source code. Students may pause, backtrack and
listen again to parts of, or all of, each explanation through software control.
During a typical study session, a student may:
read a section of theory from their textbook,
launch the Java Cyber Classroom and study a sample of "live" source code by:
- listening to the author of the textbook explain the meaning of the code,
how one part relates to another, how that code and the concepts relate to elsewhere in the course.
- running the source code to experience the implementation of the finished product,
- cross-referencing the meanings and usage of packages, classes and methods with their descriptions
in Sun Microsystem's documentation.
trying one or more of the exercises at the back of the chapter for which sample solutions are posted on
this web site, and to then compare and study the differences with the sample solutions.
solving problem(s) of assigned exercises at the back of the chapter with paper and pencil and then
implementing the program with source code while referencing a model sample program
and explanations found in the chapter, found in Sun's documentation and found in other books and web sites.
|
HIST |
JAVA HISTORY
You'll find the history of Java to be fascinating. Did you know that the original designer of Java was James
Gosling from Calgary, Alberta?
Pop on your earphones and watch and listen to the following:
flash presentation from
PublicStaticVoidMain.
|
2 |
Introduction to Java Applications
Assignments
Finish reading the assignments for chapter 2 ... this sentence being the first assignment.
Overview the Chapter 2 PowerPoint Slideshow.
This just gives you the "lay of the land" for now. Later, after you read the chapter, this slide show will
be a very meaningful review.
Actively read every word in chapter 2. (Actively here means: "thinking for meaning".)
Implement and run the Chapter 2 source code.
Become familiar with The Structure of a Java Source Code File. (<-- Click on this link.)
-
Read Optional Case Study (Thinking About Objects: Examining the Problem Statement) (87-93)
This is the industry standard way of documenting source code in objected oriented languages.
We want to learn about it gradually, chapter by chapter.
Mentally review the "Self-Review Exercises" (97-99) (The section containing the answers to these
questions follow in the book itself.) This may easily alert you to potential holes in your knowledge
and skills.
There are exercises for practice and exercises that will be graded. (pp 100-104) Click on the practice
exercises for the Deitel solutions.
| Exercises For Practice | Exercises For Grades |
|
|
| Exercise 2.11: | JOptionPane.showMessageDialog( ) |
| Exercise 2.15: | System.out |
| Exercise 2.18: | IPO (Input-Process-Output) |
| Exercise 2.32: | Modulus division. |
| Exercise 2.34: | String concatenation. |
|
Screen Dumps of Dialog Boxes: Print the source code and screen dump in a Word Processor, two pages per side, double sided.
Simultaneously pressing [Alt][PrtScn] will copy the GUI output to the clipboard from whence you
can paste it just below your source code. Use a non-proportional font (example: Courier New) to
maintain the vertical alignment of the structure of your source code.
Click for instructions on making screen dumps of
textual output (System.out.print)
and graphics output.
|
X |
BONUS UP TO 10% OF COURSE GRADE
Many teachers in North America have claimed that Karel the Robot is one of the most effective and exciting ways
for students to learn to program. Find out why by doing this electronic "book" and boost your course grade by
up to 10%.
|
3 |
Introduction to Java Applets
Assignments
Read Optional Case Study (Thinking About Objects: Identifying the Classes in a Problem Statement) (135-142)
Overview the Chapter 3 PowerPoint Slideshow.
This just gives you the "lay of the land" for now. Later, after you read the chapter, this slide show will
be a very meaningful review.
Mentally review the "Self-Review Exercises" (p 145) (The section containing the answers to these
questions follow in the book itself.) This may easily alert you to potential holes in your knowledge
and skills.
Implement and run the Chapter 3 source code.
-
There are exercises for practice and exercises that will be graded. (pp 145-147) Click on the practice
exercises for the Deitel solutions.
Note: in order to execute an applet from within JCreator, you must execute an html file which, in turn,
calls the applet file. Both the html and java applet files must be part of a JCreator project!
| Exercises For Practice | Exercises For Grades |
|
|
| Exercise 3.6: | Arithmetic and I/O Operations |
| Exercise 3.20: | Output Table of Squares & Cubes |
|
Screen Dumps of Dialog Boxes: Print the source code and screen dump in a Word Processor, two pages per side, double sided.
Simultaneously pressing [Alt][PrtScn] will copy the GUI output to the clipboard from whence you
can paste it just below your source code. Use a non-proportional font (example: Courier New) to
maintain the vertical alignment of the structure of your source code.
Click for instructions on making screen dumps of
textual output (System.out.print)
and graphics output.
|
Easy Buttons |
Easy Buttons and Textfields
This handout contains explanations and exercises that will make GUI programming easier to do.
Do the exercises.
AWT and Swing are the names of the GUI (Graphical User Interface) classes in Java's standard libraries.
Because these classes and methods are powerful and extensive, students new to Java programming can feel
overwhelmed when first using them. Professor William C. Jones, Jr. from Central Connecticut State
University therefore wrote a number of easy to use and understand classes to get used to using
GUI input and output when programming in Java.
Professor Jones' "Easy" classes inherit more complicated versions of those "easy" classes from AWT and Swing.
In that way, they also inherit the power and extensibility of those classes. Professor Jones' "easy"
classes actually scale down the power and complexity of AWT and Swing so that they may be more easily
understood and used. However, because Professor Jones' "easy" classes "extend" AWT and Swing, they act in
the same way, so learning to use them will make it easier to use AWT and Swing.
Professor Jones named his classes EFrame, EButtonj, EField, ELabel, ETextArea, and ETimer (the "E" stands
for "Easy"). Students should now work through the handout created by Professor Jones that teaches students
how to use his easy classes: Easy Buttons and Textfields.
The Java source code and bytecode files associated with the handout may be accessed by clicking here:
Files For Easy Buttons.
Professor Jones has written a great (and free) online textbook that teaches Java programming with a
strong early emphasis on objects. Students should check out Java Au Natureal. Other works by Professor Jones may be considered at his website,
www.javabook.org.
|
4 |
Control Structures: Part 1
You should have already covered most the concepts and syntax of this chapter when you did Computer Science 101
with C++. Remember that both C++ and Java use the syntax of the C language. That said, unless you learned C++
from the Deitel C++ text book, you will note that this chapter is clearer and more definitive than other text
books, and so you should still read it over.
Note particularly the flow charts (pages 154-155) of the selection structures (if, if/else).
Note Java's only ternary (three part) operator, (?:) on page 156. Few books even mention it, let alone explain it.
You should be familiar with the while loop, counters, accumulators, and sentinel
values, (pages 159-178), but notice Deitel's extensive emphasis on pseudocode. Pseudocode is one tool that
virtually all programmers really do use. Use it rather than the rigorous syntax of a conventional language when
trying to think through the logic of a particularly difficult chunk of code.
Assignments
Observe and think about the Deitel PowerPoint Slideshow on Control Structures: Part 1.
Overview the Chapter 4 PowerPoint Slideshow.
This just gives you the "lay of the land" for now. Later, after you read the chapter, this slide show will
be a very meaningful review.
Read the chapter actively! Execute and tinker with the code. Draw diagrams of concepts.
Implement and run the Chapter 4 source code.
-
Read Optional Case Study (Thinking About Objects: Identifying Class Attributes) (183-187)
Mentally review the "Self-Review Exercises" (p 189-190) (The section containing the answers to these
questions follow in the book itself.)
The exercises that you are asked to do in this chapter were intentionally chosen because they implement
really important mathematical concepts.
In the machine language of a computer, you think in binary, type in hexadecimal, and report in decimal.
The Binary Number System (patterns of one's and zero's) is used at the machine language level because it
most simply represents the presence of voltage (the digit one) or absence of voltage (the digit zero).
Converting a binary number to a decimal number (Exercise 4.25) is done all the time.
Euler's (pronounced like the Edmonton Oilers) constant (Exercise 4.32) is computed by adding
1 + 1/1! + 1/2! + 1/3! + 1/4! + and so on forever! It is found everywhere just like the constant pi.
It is found in formulae dealing with population growth, radioactive decay, calculations of compound
interest and probability calculations. It's equal to approximately:
e = 2.71828182845904523536028747135266249775724709369995...
Check out The Online College for an interesting discussion of Euler's constant.
The following exercises will be graded. (pp 190-196)
| Exercises For Practice | Exercises For Grades |
|
|
| Exercise 4.25: | Convert Binary to Decimal |
| Exercise 4.32: | Factorial and Euler's Constant |
|
Screen Dumps of Dialog Boxes: Print the source code and screen dump in a Word Processor, two pages per side, double sided.
Simultaneously pressing [Alt][PrtScn] will copy the GUI output to the clipboard from whence you
can paste it just below your source code. Use a non-proportional font (example: Courier New) to
maintain the vertical alignment of the structure of your source code.
Click for instructions on making screen dumps of
textual output (System.out.print)
and graphics output.
|
5 | Control Structures: Part 2
You should have already covered most the concepts and syntax of this chapter when you did Computer Science 101
with C++. Remember that both C++ and Java use the syntax of the C language. That said, unless you learned C++
from the Deitel C++ text book, you will note that this chapter is clearer and more definitive than other text
books, and so you should still read it over.
Note particularly the flow charts (pages 205 & 214 & 217 & especially 230-233) of single-entry/single-exit control
structures. These very nicely summarize the logic and patterns of these structures. That is the stuff that you
think with, not the memorized syntax of a particular language.
Your past experience with C/C++ should have covered Boolean expressions and the Boolean operators for logical AND
( && ) and inclusive OR ( || ) that may perform short cuts. Java supports these in precisely the same way. In
addition, Java also supports logical operators for logical AND ( & ) and inclusive OR ( | ) that do not allow for
short cuts PLUS Java supports a logical operator for exclusive OR ( ^ ). C++ did not support a logical
exclusive OR operator.
Assignments
Observe and think about the Deitel PowerPoint Slideshow on Control Structures: Part 2.
Overview the Chapter 5 PowerPoint Slideshow.
This just gives you the "lay of the land" for now. Later, after you read the chapter, this slide show will
be a very meaningful review.
Read the chapter actively! Execute and tinker with the code. Draw diagrams of concepts.
Implement and run the Chapter 5 source code.
Read Optional Case Study (Thinking About Objects: Identifying Objects' States and Activities) (234-238)
Mentally review the "Self-Review Exercises" (p 239-241) (The section containing the answers to these
questions follow in the book itself.)
Exercise 5.16 is assigned just because it is fun to learn to calculate PI in a neat way.
Exercise 5.19 implements De Morgan's Laws, the most famous "rules" of Boolean algebra.
Exercise 5.22 is assigned because we didn't cover break .. continue in Computer Science 101.
Exercise 5.25 is assigned because we didn't cover the switch statement in Computer Science 101.
The following exercises will be graded. (pp 241-245)
| Exercises For Practice | Exercises For Grades |
|
|
| Exercise 5.09: | Interest Rates: for loops |
| Exercise 5.12: | Calculate Retail Prices: switch statements |
| Exercise 5.17: | Pythagorean Triples: nested for loops |
| Exercise 5.22: | continue . . . break |
|
Screen Dumps of Dialog Boxes: Print the source code and screen dump in a Word Processor, two pages per side, double sided.
Simultaneously pressing [Alt][PrtScn] will copy the GUI output to the clipboard from whence you
can paste it just below your source code. Use a non-proportional font (example: Courier New) to
maintain the vertical alignment of the structure of your source code.
Click for instructions on making screen dumps of
textual output (System.out.print)
and graphics output.
|
GUI |
Graphical User Interface
SWING ALONG WITH GUI
Java contains a wonderfully rich library of classes that supports the use of GUI (Graphical User Interface) for
doing I/O (Input/Output) in Java. We study the SWING classes extensively in Computer Science 202
(chapters 12 and 13 of the Deitel Java How To Program 4th Edition>/b> textbook. Feel free to check out those
chapters in the Deitel virtual course anytime. However, even now we are using SWING's GUI classes to do I/O.
For the time being, you may use the following snippets of code as models for various components. They are taken
from the book, Java: Your Visual Blueprint for Building Portable Java Programs. Each program demonstrates
the use of but one GUI component. By studying the source of such a small chunk of code, you will have fun
incorporating a particular component into your programs in this course before we study SWING systematically in
Computer Science 202.
|
GUI COMPONENTS
|
EVENT HANDLING
|
|
6 | Methods
Modularization is one of the most important concepts in Computer Science. It is used everywhere from hardware
to software. Breaking up large problems into ever smaller problems until we arrive at a problem that is easily
solved and then combining so many small solutions into ever larger solutions is the most used "bread and butter"
strategy that we have to deal with complexity. It is the solution that built the chip and took us to the moon.
Complexity is the most
challenging force in science and logic that we face today. Before we run, we learn to walk. Before we scale
the intricacies of quantum mechanics, let us learn the primitive art of dividing our labour. This strategy
works in finance, working out relationships with your girl friend or boy friend, solving problems of war and
peace, or simply planning a trip through Europe. It is a recognition that our minds cannot deal with a whole
lot at any one time, but our minds can deal with well with one thing at a time. We know our weaknesses and,
with that knowledge, we gain strength in doing smartly what we cannot do brutally.
BASIC uses subroutines, Pascal uses procedures, C/C++ uses functions, and Java uses methods. These are all
modules. The implementation varies somewhat, but the idea remains the same. The challenge is to make each
module (Java method) a separate chunk of code that stands by itself but has some way of receiving values and
returning the results of massaging (changing) those values to other parts of the program.
After this chapter you must forever more bundle your source code into methods. You will later learn to bundle
both data and methods into objects, but for now you must master the concepts and syntax of using methods.
Assignments
Observe and think about the Deitel PowerPoint Slideshow on Methods.
Overview the Chapter 6 PowerPoint Slideshow.
This just gives you the "lay of the land" for now. Later, after you read the chapter, this slide show will
be a very meaningful review.
Read the chapter actively! Execute and tinker with the code. Draw diagrams of concepts.
Implement and run the Chapter 6 source code.
Pay particular attention to the Craps.java program on pages 265-268, described on pages 260-274, and
clearly explained orally by the author in the Java Cyber Classroom in
6.16 Methods of Class JApplet. Craps.java is the longest
program in the textbook to this point, and one of the most complicated.
-
-
-
Read the Optional Case Study (Thinking About Objects: Identifying Class Operations) (293-296)
Mentally review the "Self-Review Exercises" (300-304) (The section containing the answers to these
questions follow in the book itself.) This may easily alert you to potential holes in your knowledge
and skills.
- Recursion = Russian Nesting Dolls
Russian nesting dolls (aka "matryoshka") may be seen as a metaphor for recursion. Can you see why?
In what way does each smaller doll represent a smaller version of the same "problem" of the larger
doll in which it was/is encased?
|
Recursion = Shockwave app of a red square tilting recursively
A neat animation of recursion (no source code) here.
- Recursion = Escher's Ascending Descending Staircase
Do Kjell tutorials 70,
71,
72,
73,
and 74
covering "Recursion".
Go to Dr. David Levine's web site.
Read and then practice his material on Role-Playing In An Object-Oriented World.
The following exercises (pp 305-312) will be graded. Note that the Towers of Hanoi puzzle is one of
the most famous exercises in programming. It is used to illustrate recursion in virtually every text
book in every programming language that covers recursion! Computer-Assisted Instruction was one of
the earliest types of applications for computers. You will enjoy 6.31-6.33 and 6.41.
| Exercises For Practice | Exercises For Grades |
|
|
| Exercise 6.28: | GCD = Greatest Common Divisor |
Exercise 6.31
Exercise 6.32
Exercise 6.33
Exercise 6.41: | 5% BONUS QUESTION = #41
|
| Exercise 6.39: | Visualizing Recursion |
| Exercise 6.37: | 5% BONUS QUESTION
Towers of Hanoi:
|
|
Screen Dumps of Dialog Boxes: Print the source code and screen dump in a Word Processor, two pages per side, double sided.
Simultaneously pressing [Alt][PrtScn] will copy the GUI output to the clipboard from whence you
can paste it just below your source code. Use a non-proportional font (example: Courier New) to
maintain the vertical alignment of the structure of your source code.
Click for instructions on making screen dumps of
textual output (System.out.print)
and graphics output.
|
7 | Arrays, Searching & Sorting
PRACTICAL TEST: Students must schedule a time with their teacher in the last week of
the course to demonstrate various sorting algorithms using stacking cups. Students who do not schedule an earlier
time must demonstrate the algorithms on the last Friday morning and/or afternoon of the course. Students
waiting until Friday afternoon may have to wait in line which may take 2-3 hours before all students are
done.
Assignments
Overview the Chapter 7 PowerPoint Slideshow.
This just gives you the "lay of the land" for now. Later, after you read the chapter, this slide show will
be a very meaningful review.
Read the chapter actively! Execute and tinker with the code. Draw diagrams of concepts.
Implement and run the Chapter 7 source code.
-
Read the Optional Case Study (Thinking About Objects: Collaboration Among Objects) (350-354)
Mentally review the "Self-Review Exercises" (356-357) (The section containing the answers to these
questions follow in the book itself.) This may easily alert you to potential holes in your knowledge
and skills.
IBO requires knowledge of how to trace and implement four searching and sorting algorithms.
Read about the four sorting algorithm's required by IB's 2000 syllabus by viewing Raksha Vasudevan's
Kyell-style tutorial, The 4 Array Sorts Required by IB.
What was a difficult and frustrating topic has become exciting because of visualizations (Java applets)
and manipulatives (stacking cups) of the algorithms. This chapter needs lots of time. Its really fun. Enjoy!
Ask Mr. Donaldson to let you view the 30 minute videotape entitled, "Sorting Out Sorting".
[Baeker, Ronald M., published by Morgan Kaufman, 1981, ISBN: 1558600302]
Check out xSortLab Lab: Sorting and the Analysis of Algorithms from David Eck's book,
The Most Complex Machine: A Survey of Computers and Computing.
Also learn to demonstrate each of the routines with Mr. D.'s stacking cups. Its fun and, incidentally,
an excellent way to visualize and internalize each of the sorting algorithms, and that is our objective!
First study the visualization of an algorithm. Then, once you have the hang of it, implement it using
a dozen stacking cups.
In the last term of 2002 the first eight students to take Computer Science 201 in Java were examined in
their application of sorting algorithms using stacking measuring cups. Judge for yourself as you watch
AVI clips of their final tests .. a physical
demonstration of each of four different sorting algorithms using a dozen toddler stacking cups.
| Algorithm | Text Pages | IBO Syllabus Objective | Resource |
| Arrays Theory: | 314-349 | 1.3, 1.4, 1.6, 5.2, 5.6 |
Richard Jones, IB Computing Home |
| Bubble Sort: | 333-335 | 1.6.7 5.6.1 |
John Morris, U. of Western Australia
Duane Jarc & Michael Feldman, George Washington U.
Sandeep Mitra, Suny Brockport U.
Richard Jones, IB Computing Home |
| Linear Search: | 335-337 | 1.6.7 5.6.1 |
Richard Jones, IB Computing Home
John Morris, U. of Western Australia |
| Binary Search: | 338-242 | 1.6.7 5.6.1 |
Richard Jones, IB Computing Home
John Morris, U. of Western Australia |
| Selection Sort: | 368, Q 7.29 | 1.6.7 5.6.1 |
Richard Jones, IB Computing Home
Sandeep Mitra, Suny Brockport U.
Duane Jarc & Michael Feldman, George Washington U. |
| Insertion Sort: | Not In Text | 5.3.6 |
Woi Ang, U. of Western Australia
Duane Jarc & Michael Feldman, George Washington U.
Sandeep Mitra, Suny Brockport U.
Richard Jones, IB Computing Home |
| Quick Sort: | 368 Q 7.37 | 5.2.1 5.6.1 |
The Animation of Recursion: QuickSort
Duane Jarc & Michael Feldman, George Washington U.
Sandeep Mitra, Suny Brockport U.
Woi Ang, U. of Western Australia
Chien Wei Tan, U. of Western Australia
Richard Jones, IB Computing Home |
| Merge Sort: | 1215 | 8.1.10 |
Duane Jarc & Michael Feldman, George Washington U. |
| Recursion Exercises: | 368-371 | 5.5 | |
The following exercises (pp 359-369) will be graded.
| Exercises For Practice | Exercises For Grades |
|
|
| Exercise 7.11: | Bubble Sort |
| Exercise 7.28: | Bucket Sort |
| Exercise 7.29: | Selection Sort |
| Exercise 7.32: | Binary Search |
| Exercise 7.37: | Quick Sort |
|
Screen Dumps of Dialog Boxes: Print the source code and screen dump in a Word Processor, two pages per side, double sided.
Simultaneously pressing [Alt][PrtScn] will copy the GUI output to the clipboard from whence you
can paste it just below your source code. Use a non-proportional font (example: Courier New) to
maintain the vertical alignment of the structure of your source code.
Click for instructions on making screen dumps of
textual output (System.out.print)
and graphics output.
Where I/O (Input/Output) inlcudes multiple GUI (Graphical User Interface) dialogue boxes, include at
least one screen shot for each of input and output dialogue box. Where are various types of
dialogue boxes and/or messages and/or types of data, include a "reasonable" number of screen shots.
Typically there will be 1-2 screen shots showing input and 1-2 screen shots showing output.
In extraordinary cases, there could conceivably be a dozen or more screen shots. What is "reasonable"
is the product of using reason (thought) and reasons (related information). BE REASONABLE!
Students must generate and/or complete trace tables of searching and sorting algorithms.
Hint To Automatically Generate A Trace Table:
- Place an output statement with the heading before the first call to the loop or recursive method
that generates the next "pass" of the sorting algorithm.
- Place an output statement in the body of the loop or recursive method which generates the next
"pass" of the sorting algorithm so it will output the values of each of the variables.
Check out an example of how to do this taken from an answer key by Gerry Donaldson to Question 16
of Paper 1 of the May, 2002 IB Higher Level final examinations: [WordPerfect file] [pdf file]
[WORD file]
Students must recognize "PURE" pseudocode representations of searching and sorting algorithms.
Editorial Comment
IBO's pseudocode (called PURE) and knowing how to trace an algorithm are two major skills that
students must use and/or demonstrate on IBO's exams. As it happens, pseudocode and tracing are
powerful analytical tools that every programming student should know about and use. The textbook
that we use does not emphasize these tools to the same extent that IBO does. Sorting algorithms
lend themselves very well to the use of both pseudocode and tracing. Ergo, we start here. We
start now!
|
An example of a PURE pseudocode fragment and the corresponding tracing of a Bubble Sort will be found
here
(pdf). The algorithm is represented in IBO's special pseudocode for use with examinations. IBO has
not standardized on one particular computer programming language. They therefore use "PURE"
(Pseudo-code Uuniversally
Readable for Examinations) to represent source code.
Students do NOT have to program in PURE, but students must be able to read PURE.
Students will be given examples of searching and sorting representations in PURE pseudocode.
The following is a "PURE" BUBBLESORT algorithm.
procedure BUBBLESORT1 (ref ARRAYOFINT is NUMARRAY, val NUMVALUES integer)
declare LAST, CURRENT, TEMP integer
for LAST <-- NUMVALUES downto 2 do
for CURRENT <-- 1 upto LAST - 1 do
if ARRAYOFINT[CURRENT] < ARRAYOFINT[CURRENT + 1] then
TEMP <-- ARRAYOFINT[CURRENT]
ARRAYOFINT[CURRENT] <-- ARRAYOFINT[CURRENT + 1]
ARRAYOFINT[CURRENT + 1] <-- TEMP
endif
endfor
endfor
endprocedure BUBBLESORT1
|
To learn more about PURE, check out the following links.
There will be three parts to the test for this chapter.
One: There will be the usual multiple choice test. Anything in the chapter is fair game.
Two: Students will "trace" changes in values, line by line, of one or more of the following
searching and sorting algorithms.
Three: Students will physically demonstrate one or more of the following
searching and sorting algorithms using 12 stacking cups.
- Linear Search
- Binary Search
- Bubble Sort
- Selection Sort
- Insertion Sort
- Quick Sort
- Merge Sort
|
|