6.170 Laboratory in Software Engineering 
Spring 2000 
Problem Set 1: Getting started with Java 
Due: February 10, 2000 
Handout 5

Guidelines

To do this assignment as efficiently as possible, and to benefit the most from it, we recommend that you: To hand your solution in, follow the standard instructions, which state in part:
Each assignment should be handed in as hardcopy to your TA or to the course secretary (Kincade Dunn, NE43-529) by 4:30 PM on its due date. It is usually most convenient to give the assignment to your TA at the end of class on that day. Additionally, the source and compiled code for each problem set should be made available on Athena...
You should put your solution to this problem set in ~/6.170/ps1.
See the general information sheet (handout 1) for more details.

Purpose

This problem set will familiarize you with working in Java. You will get started with the development environment, write a few simple functions in Java, and get used to writing and compiling code for 6.170.

Background

In this problem set and the next, you will write a program that performs various transformations on text. In problem set 1 you will write some functions that do transformations. In problem set 2 you will write more functions and then use them to provide an application that transforms text files under the control of the user.

The three different functions that you will write for Problem Set 1 are reverse, compress, and uncompress.

You might find the Java StringBuffer class helpful, though it isn't necessary.

Problem 1: Text Conversions

(a)

(b)

(c)

 
When a procedure specification requires something, the implementation may assume it. The implementation does not need to check that fact. The implementation is free to crash, return garbage, or loop forever if invoked with an argument that violates a requires clause.

Problem 2: Testing your functions

Compile your file Transforms.java by typing javac Transforms.java in your working directory.  Make sure your CLASSPATH variable is set properly, as described below.  Now, you will test your implementation with the class ps1.PS1 which we have provided for you.

(a)

(b)

 
A word about CLASSPATH: you must set your CLASSPATH environment variable so the Java compiler and virtual machine can find the ps1 package.  For example, if you are working on Athena, one of the entries in CLASSPATH must be ~/6.170. This must be set before running either javac or java

Reminder: If you use another computer besides Athena, you must move your code to Athena.