SUNY Geneseo Department of Computer Science
{Date}
CSci 141, Spring 2004
Prof. Doug Baldwin
Amendments to student association constitution need your vote
Updated versions of
Exam 2 will be next Thursday (April 1)
Saving lists - save in internal binary format
Exceptions?
double divide( x, y ) throws InvalidArgumentException
if y != 0
return x / y
else
throw new InvalidArgumentException()
main() {
try {
double a = divide( x, 0.0 );
print a
}
catch ( InvalidArgumentException e ) {
print "I'm a fool! y = 0"
System.out.println( e );
}
catch ( Exception e ) {
System.out.println( "D'Oh!" );
}
}
class MyException extends Exception {
public MyException( String desc ) {
super( desc );
}
}
...
throw new MyException( "User Error" );
Reading files:
Section 11.1 through Section 11.3.1
Example list algorithms
// In a subclass of List:
Object second() {
return this.getRest().getFirst();
}
Continue looking at list algorithms
Mini-Assignment
// In some subclass of List...
public void delete( Object x )
...
// Postcondition: List contains no items equal to x.