Computer Science 211
Data Structures

Mount Holyoke College
Fall 2009


Lab 1: Java, Unix, and the Silver Dollar Game
Due: 9:00 AM, Friday, September 25, 2009


For our first lab, we'll spend some time learning how to get around the Macs in Kendade 307, and then you will write a program for the Silver Dollar Game at the end of Chapter 3 in Bailey.


Before Lab

You should come to our meeting with a proposed design for your CoinStrip class. These designs may be handwritten or typed. They will be checked at the start of lab and will constitute a small part of the grade for this week's lab.


Getting Started

During today's meeting, you will learn how to use the Java environment on the Macs in Kendade 307, both at the Unix command line (using Emacs to edit, if you wish) and in the Eclipse integrated development environment (IDE), brush up on your Java, and get started on the lab program.

You can find information about how to do many of these tasks on the page of information about Java and Unix on the Kendade 307 Macs, linked from the course home page.

  1. Log into your account and open a terminal window.
  2. 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
    
  3. Open the Emacs text editor (just type emacs at your command prompt) and 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.

  4. Choose one of the class examples that uses the structure package and copy it to your home folder and run it both from the Unix command line and within the Eclipse IDE.


Lab Programming Assignment

Your task for the lab this week is to write the Silver Dollar Game at the end of Chapter 3 in Bailey.

Write your program in a file named CoinStrip.java. Include a main method in this class to play the game. This method should create an instance of CoinStrip, as is done in the PocketChange class example.

When you have finished the program, turn in CoinStrip.java by emailing it to jteresco AT mtholyoke.edu as an attachment.

Also, answer the thought questions at the end of the lab. Put your answers in the file lab1.txt and submit that file as an email attachment as well to jteresco AT mtholyoke.edu.


Grading

This lab assignment is graded out of 30 points. As in all labs, you will be graded on design, documentation, style, and correctness. Be sure to document your program with appropriate comments (use Javadoc!), including a general description at the top of the file, a description of each method with pre and postconditions where appropriate. Also use comments and descriptive variable names to clarify sections of the code which may not be clear to someone trying to understand it. You should also include a justification of your choice of internal data structure as a comment where you declare that structure in your program.

Grading Breakdown

Pre-lab design 3 points
Program design 3 points
Program style 3 points
Program documentation 5 points
Program correctess 10 points
Thought questions 6 points

The program design grade will be based on the appropriateness of your choice of internal data structures and methods provided to play the game. The program style grade will be based on code formatting and approriate use of Java naming conventions. The program documentation grade is, of course, based on the comments you provide. The program correctness grade is based on how well your program meets the functionality requirements.