Lab 1 - Java, Unix, and Conway's Days of the Week
Due: Monday, September 20, 2004 at 9:00 AM


Getting Started

During lab today, you will learn how to use the Java environment from the Unix command line on the CSLab Mac systems and get some practice writing Java code.

  1. Go through the Unix tutorial handout. This will teach you how to log in and out of the machines, use basic Unix commands, and edit files with Emacs.
  2. Log in. Start X11, the X Window System, by clicking on the rectangular while icon with an X on it in the dock at the bottom of your desktop. This will bring up an "xterm" command window.
  3. To set up your account to run the correct version of Java, you should enter the command
    source /Network/Servers/cortland.cs.williams.edu/Volumes/Courses/cs136/bin/136
    
    in the command window each time you log in. Rather than type this command every time, you can make it happen automatically by adding it to the file .local_bashrc in your home directory.
  4. Identify the function of and experiment with these Unix Commands:
     
    ls         cd         cp         mv         rm         mkdir      pwd
    man        chmod      cat        more       grep       head       tail
    ln         find       rmdir      wc         diff       tar
    

    Identify the function of and experiment with these Emacs Commands:

     
    C-x C-s    C-x C-c    C-x C-f    C-x C-w    C-g        C-a        C-e        
    C-d        C-_        C-v        M-v        C-s        C-r        M-%
    

    Learn these commands - you will use them often. Hints can be found in the Unix and Emacs web pages on the course website.

  5. Make a directory in your Unix account for CS 136 work (perhaps "136" or "cs136" might be reasonable). Use the chmod command to restrict access to this directory so only you can read the files. Ask a classmate, TA, or instructor to verify that he or she cannot see the contents of this directory.

    Make a subdirectory lab1 in this new directory for files related to this lab.

  6. Create a symbolic link in your home directory to the examples directory
    /Network/Servers/cortland.cs.williams.edu/Volumes/Courses/cs136/examples. This will allow you to use that link to access these examples without having to type the long path each time.
  7. Write, compile, and run a Java program under Unix that prints the first ten odd numbers. Don't just use 10 println statements - use a loop. Call it Odd.java.

Lab Program

Write the Day-of-Week Calculator at the end of Chapter 1.

You should have two classes - one to hold the date and one to play the game. Be sure to document your program with appropriate comments, including a general description at the top of the file and a description of each method. Also use comments and descriptive variable names to clarify sections of the code which may not be clear to someone trying to understand it. Take this opportunity to practice using Javadoc as well.

Answer the four thought questions at the end of the lab. Put your answers in a plain text file conway.txt.

When you are finished, package up your Java source files for the odd number printer and the Conway game along with your file containing your answers to the thought questions into a "tar file" called conway.tar. Submit this using the turnin utility: "turnin -c 136 conway.tar" at the Unix prompt. This will copy your submission to a private area from which we will collect them for grading. The time you run turnin is recorded and this will be used to assign any appropriate late penalties. As in all labs, you will be graded on design, documentation, style, and correctness.