CS 154 (Section 1 and 2): Formal Languages and Computability, Spring 2009

1st Programming Assignment: Due 4/2 at 8 a.m.

The first programming assignment will involve programming in java. You will have two very simple tasks to program. Due to the philosophy of final learning outcome of this assignment, no style rules need be followed for your program. That is, you need not follow any naming conventions, indentation, documentaion, javadoc, etc, beyond what is needed and specified below so that I can test your code. (Of course, you are allowed to follow standard conventions, but specifically for this assignment, you are not forced to. Just don't try to crash my machine, etc.)

I will provide you with an arbitrary class called Helper. It will have two (static) methods you can call: mysteryFunction and loop. They are documented in the API for the class. If you like, I am even including a sample java file for the class, but the java specifics may change during my testing.

You are to write a single class called Halting. It must have the following two public (static) methods in it:

  1. Write a static boolean method called opposite(string s1, string s2) which, given two string inputs, returns the opposite value of Helper.mysteryFunction(s1, s2). You should not use the code for mysteryFunction for this, just make a subcall to the mysteryFunction method.
  2. Write a static boolean method called repeater(string s1) which, given a single string input, does the following: if Helper.mysteryFunction(s1, s1) returns false, repeater returns true. Otherwise, repeater calls Helper.loop(). It has been commented on that a return value is needed by the java compiler, even if the code will never get to it, as when loop is called. It should not matter what you return here, but just to distinguish it from the other case, you may as well return false here.

That is all that is required. Your entire submission should be just a single java file, Halting.java. It is quite possible that your submission is very short. It is likely you have not encountered any programming this easy in some time. You should think about what each of your methods does, as a function of the mysteryMethod. This will come up again, but I will not be checking javadoc comments. Make sure your methods are public.

There will be also be two separate (pre-announced) pop-quizes at the start of two different classes, but the dates are yet to be determined.

You should email this assignment to me with the subject
CS154Spring2009 Prog1 Last First
where Last and First are replaced by your name. If you use any other subject, your submission may be lost.