CS 160 - Software Engineering

Cay S. Horstmann

Fall 2006


Prerequisite Quiz

Please email your prerequisite to horstmann\u0040cs.sjsu.edu. Use a subject line such as

CS160 Prerequisite Quiz Lastname, Firstname

Follow the format above exactly, that is, no space between CS and the course number, a single space separating the course number from the words Prerequisite Quiz, etc. My email filter relies on this format. Replace Lastname, Firstname with your own name, such as Smith, Harry.

If you are registered for this class, email the prerequisite no later than 23:59 of the date indicated on the schedule.

If you want to add into the class, email the prerequisite between the days indicated on the schedule. Use the subject line.

CS160 Add Request Lastname, Firstname

Question 1. This HashSet class implements a subset of the functionality of the standard java.util.HashSet class. This SetTester class runs through a simple test. Your job is to prove that you know how to use a debugger. Using your favorite debugger, run a debugging session. Trace inside the third call of iter.next()in SetTester. Then step through the next method until it has set the bucket field to the bucket containing the second element of the set. Take a screen snapshot of the debugger screen that shows the current line and the content of the bucket field. Attach your screen shot as a GIF, PNG, or JPEG file to your email.

If you need a refresher on debugging, look at the CS 46A (!) labs.

Question 2. Write a bash shell script that carries out the following task:

The script (let's call it importdiff) takes two command-line arguments that are both Java files. It reports to standard output (in any format of your choice--doesn't have to be pretty) the import directives that are present in exactly one of the files but not both. For example, running

importdiff SetTester.java com/horstmann/HashSet.java

would report 

< import com.horstmann.HashSet;
> import java.util.AbstractSet;
< import java.util.Set;
> import java.util.NoSuchElementException;

but not

import java.util.Iterator;

which is present in both.

Hint: Use the grep, sort, and diff utilities. Use grep to locate the lines starting with import. Sort the results for easy comparison. Then use diff to report the differences. Grep once more to clean up the output.

Attach your script and a screen shot of the running of your script (as a GIF, PNG, or JPEG file) to your email. (I want to see evidence that you are successfully running a shell in Cygwin, Linux, or Mac OS.)

ALSO ATTACH a photo of yourself in JPEG format, with 100 ≤ width, height ≤ 200 (similar to these mug shots), suitable for posting on the class web site. Name the photo Lastname_Firstname.jpg, e.g. Smith_Harry.jpg.

If you are trying to add as a graduating senior or an incoming graduate student who must take the course this semester, please tell me in the body of your email message.