COS 212: Computer Science 2
Notes
- Exam 3 is scheduled for Monday, Dec. 7 during class.
- Exam 2 is scheduled for Wednesday, Nov. 4 during class.
- Exam 1 is scheduled for Monday, Oct. 5, during class.
-
Java Links that I use all the time:
- Package Index (faster local version) contains a detailed description of every package, class, and method in the Java language.
- (I used this to learn about subtle points in the syntax of the language.) The Java Language Specification gives every detail of the syntax and semantics of the Java language.
-
Free software that I use.
- Sun's JDK.
- NetBeans Development Environment.
- Eclipse Development Environment.
-
NTEmacs
for Windows.
Emacs help. - GNUEmacs for Unix.
- Java Development Environment (JDEE) for Emacs.
- Emacs for Windows Compilation: to install Emacs on windows, unzip this on your C:\ drive and follow the directions in README.W32. This now includes the JDEE. Try out this for a .emacs file. Be sure to put it in the directory that is the value of your HOME environment variable and be sure to rename it either .emacs or _emacs.
- Find Caps2Ctrl at System Internals.
-
My CS2 API:
- My CS2 API: You may want to install my class hierarchy on your computer. To do that, just download this file and save it in the ext folder that your JVM uses. For example, this is probably something like C:\Program Files\Java\jre\1.6.0\lib\ext. If that does not work, try c:\j2sdk1.6\jre\lib\ext or something to that effect. You should not change the value of your CLASSPATH variable. If you put this file in the right place, Java will find it automatically.
- The API for the Container hierarchy that we will use this semester. (Download the whole thing for your home computer.)
-
To use these classes, put the lines
import edu.bethel.mathcs.console.*;
and/orimport edu.bethel.mathcs.util.*;
in your code. - The source code for the CS2 API.
- The Final Exam will be in AC 305 on Tuesday, December 15 at 2:45 p.m.
- Nice, useful scope chart.
- Constructor Rules (updated!)
- Thinking Recursively
- Sound Bites
- Terminology
-
Contacting me: When you contact me by
email, please include the following information in the
email:
- Your full name.
- The class you are in.
- Lots of details about the problem you are having. For example, if you are having trouble with assignment 9, don't say "the assignment" or "the last assignment", instead, say "assignment 9".
I want to help you. The object of your email should be to make it easy for me to do that. -
Allowed references: Here is a description
of the sources that you are allowed to use in your homework
and projects.
- Other students: You are allowed to talk to other students about the ideas. When you get an idea from another student, be sure to acknowledge it. You are not allowed to look at each other's code.
- Text book: You are allowed to get ideas from the textbooks for this course without acknowledgement.
- Instructor: You are allowed to use code that I write in class or post to the web site for this course. Use of this should be acknowledged. However, ideas you get from my lectures don't have to be acknowledged.
- Other sources: You may use other sources to get ideas only with specific approval from me on a case-by-case basis. This means don't download code from Sun or any other site unless we have discussed it.
Topics to be covered
-
Review: methods, fields, inheritance,
overriding, conditional expressions including
switch, loops, static members, constructors, Strings, equals vs. ==. If any of this is not review, then we should talk in my office. -
Basic Java features: all four access levels,
instanceof, invocation stack, abstract classes, x++ vs. ++x, new keywords, scope and lifetime, StringBuilders, interning, and IO classes. - Javadoc
- Jar
- Exceptions using existing Exceptions and writing your own.
- Inner classes the four kinds of inner classes and when to use which.
- Algorithms and Correctness specifications, preconditions, postconditions, invariants, and proving correctness.
- Halting and how to prove it.
- Testing by hand and unit testing.
- Efficiency and big-O notation.
- Thinking recursively
- Generics just the basics
- Container hierarchy of interfaces and abstract classes. We will implement these interfaces with arrays and linked structures.
- Nodes and linked lists (only singly-linked lists this semester: nothing fancy)
- Iterators with an eye toward space and time efficiency
- Mutable containers adding and deleting
- Accessible containers traversing and searching
- Stacks and queues implemented with nodes and with arrays
- Maps
- Trees focusing on both recursive and iterative traversal in pre-order, post-order, in-order, and level-order. Level-order and in-order insertion. Level-order and in-order deletion. (only binary trees this semester and no balancing)
- Blocks and Predicates toward functions as objects. Implementing forEach, notEvery, collect, etc.
- GUIs and multimedia We will do a bit with JLists, buttons, text fields, and make a paint program. We will look more closely at the delegation event model.
- Threads especially in the context of GUI code.
Homework
- Due midnight the morning of Nov. 24: Lab 10.
- Due midnight the morning of Nov. 17: Lab 9.
- Due midnight the morning of Nov. 10: Lab 8.
- Due Nov. 4: Read Chapter 10.
- Due midnight the morning of Nov. 3: Lab 7.
- Due Nov. 2: Read Chapter 9.
- Due midnight the morning of Oct. 27: Lab 6.
- Due Oct. 26: Read Chapter 8.
- Due Oct. 23: Read Chapter 7.
- Due Oct. 14: Read Chapter 6.
- Due midnight the morning of Oct. 8: Lab 5.
- Due Oct. 2: Read Chapter 5.
- Due midnight the morning of Oct. 1: Lab 4.
-
Due Sept. 30: Read the first five sections
of the Generics
Trail in the Java Tutorial.
Brian Goetz' introductory articles can be found here: Generics (and Part 2) - Due Sept. 28: Read Chapter 4.
- Due Sept. 25: Read Chapter 3.
- Due midnight the morning of Sept. 24: Lab 3.
- Due midnight the morning of Sept. 17: Lab 2.
- Due midnight the morning of Sept. 10: Lab 1 IDEs, text files, and jars.
-
Due Sept. 9: Read the tool
docs on javac, java, javaw, jar, and javadoc. You should already
be somewhat familiar with some of this. Pay special
attention to the parts that are new to you.
Also, read my advice on writing javadoc comments.
Recommended reading: Chapter 2 of Gray. -
Due Sept. 4: Recommended reading: Chapters 0 and 1 of
Gray.
Read our coding standards if you aren't familiar with them already.
Projects
You may do these projects alone but I encourage you to work in teams of two. In unusual cases, I might even approve a team of three. Here are the rules.
- No member of the team can write code unless the other team member is looking over his or her shoulder. Therefore, you ought to choose a teammate you can get together with easily.
- This is obviously an exception to the "don't look at anyone else's code" rule. You must look at your teammate's code.
- Due at Midnight the morning of Sept. 19: Project 1.
- Due at Midnight the morning of Oct. 3: Project 2.
- Due at Midnight the morning of Nov. 5: Project 3.
- Due at Midnight the morning of Nov. 19: Project 4.
- Due at Midnight the morning of Dec. 10: Project 5.
Review Code for Scientific Computing Students
- Name Inheritance Code: Name.java and FullName.java.
- Shape Inheritance Code: AbstractShape.java, ColoredShape.java, Disc.java, InvalidRectangleException.java, Point.java, Rectangle.java, Shape.java, and SquareTester.java.
Example Code
- String Interning and Equality: Equals.java.
- Static Cookie example: Cookie.java.
- Exceptions code: SimpleExample1.java and SimpleExample2.java.
- Correctness and Halting: CorrectnessHalting.java.
- Big-O code: BigO.java.
- Checked vs. Unchecked Exceptions code: Bad.java.
- Console Menu code: SimpleIO.java.
- File I/O code: StudyFileStream.java.
- Recursion code: Recursion.java.
- Pass by value: PassByValueMain.java.
- Dynamic dispatch example: StaticParamsDemo.java.
- Nested Classes Code: LinkedList.java.
- Autoboxing examples: Autoboxing.java.
- Recursion code: TailRecursion.java.
- Empty Container: MyContainer.java.
- Array Mutable Container (day 1): ArrayMutableContainer.java.
- Array Mutable Container (day 2): ArrayMutableContainer.java.
- Array Mutable Container (day 3): ArrayMutableContainer.java.
- Array Mutable Container (day 4): ArrayMutableContainer.java.
- Node class (day 1): Node.java.
- Node class (day 2): Node.java.
- Node class (day 3): Node.java.
- Node class (day 4): Node.java.
- Node class with some testing (day 5): Node.java.
- Linked List Mutable Container (day 1): LinkedMutableContainer.java.
- Accessible Array Container (day 1): ArrayAccessibleMutableContainer.java.
- Accessible Array Container (day 2): ArrayAccessibleMutableContainer.java. (Updated Oct. 30!)
- Linked List Mutable Container (day 2): LinkedMutableContainer.java.
- Stack as array (day 1): ArrayStack.java.
- Stack as linked list (day 1): LinkedStack.java.
- Queue as linked list (day 1): LinkedQueue.java.
- Queue as array (day 1): ArrayQueue.java.
- Queue as array (day 2): ArrayQueue.java.
- List Array Container (day 1): ArrayList.java.
- List Array Container (day 2): ArrayList.java.
- Binary Tree Node (day 1): BinaryTreeNode.java.
- Binary Tree Node (day 2): BinaryTreeNode.java.
- Binary Tree Node (day 3): BinaryTreeNode.java.
- Binary Tree Node (day 4): BinaryTreeNode.java.
- BinaryTree implementing AccessibleMutableContainer (day 1): BinaryTreeAccessibleMutableContainer.java.
- BinaryTree implementing AccessibleMutableContainer (day 2): BinaryTreeAccessibleMutableContainer.java.
- BinaryTree implementing AccessibleMutableContainer (day 3): BinaryTreeAccessibleMutableContainer.java.