Program Examples

15-212, Spring 1998


Date Example
12-Feb-1998 Function: Read one line of input and accept it iff the 5th letter from the end is an a, and the 3rd digit from the letter is a 0. (Classes: Stack and NthFromEnd.) To compile this program, type: javac NthFromEnd.java. Note that the compiler automatically compiles class Stack as well, since it sees that class NthFromEnd uses that class. javac has an inbuilt make function!!
To run it, type: java NthFromEnd (Do not use these as style guides!!)
19-Feb-1998 Function: Simple demonstration of inheritance and polymorphism. (Classes: GenericNode and IntegerNode that extends the former. Test exercises the two classes. (Do not use these as style guides!!)
24-Feb-1998 Sample solutions to programming project 1, from:
Sal Desiano and Tom Kang. Note the use of exceptions.
5-Mar-1998 SimpleException: A simple demonstration of exception handling. (Do not use this exclusively as a style guide!!)
8-Mar-1998 Sample solution to programming project 2 (the Lexer) (from Adam Berger).
10-Mar-1998 AWTDemo: A simple demonstration of the Abstract Windowing Toolkit or AWT. (Do not use this exclusively as a style guide!!)

Ravishankar Mosur
Last modified: Thu Mar 12 17:58:34 EST 1998