CS 110 Fundamentals of Computing
Homework Assignment 1
Bolker and Rodriguez
Spring 2004

There are two parts to this assignment, due at different times:

You can find this assignment on the web by following the hw1 link on the course web page www.cs.umb.edu/cs110.

Some words of warning and advice. Much of computer programming requires reading and writing in which you pay careful attention to details. That's not the way most people read and write most of the time, and most of the time that's OK. But if you're too casual in this course, and just skim, you will not do well.

Begin reading carefully with this assignment.

Part I

  1. Electronic mail will be one of the important ways we communicate with you this semester, so your first task is to make sure we have your email address in our address book: send email from the account you plan to use for this course to the head TA, Ricardo Menard, at rmenard@cs.umb.edu, with a copy to yourself and to your instructor. (Find out his email address from the course web page.)

    The Subject for the email should be CS110 and the body should be just one line with entries, separated by commas, containg your last name, your full name, your student id, your section number and the email address we should use to contact you. For example, if Tony Liu were in section 4 his email might contain the line

    	Liu, Anthony Liu, 1234567890, 4, tony_liu@umass-student.umb.edu
    

    Follow these instructions exactly!

    You may use any email account you read regularly. If you do not have an email account, UMass-Boston will provide you with a free one: the instructions at http://www.umb.edu/students/webmail.html tell you go to the Customer Service Center (Upper Level walkway between the bus stop and the Quinn Administration building) to set up your account.

  2. Visit the course web page at http://www.cs.umb.edu/cs110/. Look around. Find the home page for the course textbook. Find the source code for the Bank class discussed in Chapter 1.

    Write a paragraph or two describing some interesting things you came across and where you found them.

  3. Find the discussion of intellectual honesty. Write a few sentences, first summarizing what it says (don't just quote it) and then recording your reactions to that material.

  4. Optional, for no extra credit but maybe fun: what is the picture on the cover of Java Outside In and why is it appropriate?

  5. Your next job is to type the words you have just written (about the course web page, and about honesty) into the computer. You may be familiar with some word processing program. Unfortunately, neither Microsoft Word, nor any other traditional word processing program is suitable for the writing you will be doing in this course. There are several programs which will do. We will teach you XEmacs, which has been installed on the lab PCs, and which you can get for yourself, free, for your PC at home if you have one.

    You can find the instructions which follow illustrated in the on line XEmacs tutorial for CS110.

    After you are satisfied with what you have, save your work (again) and print hard copy to turn in. Use the print choice from the File pulldown.

    Neither a handwritten version of the file nor hard copy from some other word processing program will (perhaps at home) will do. Part of the point of this exercise is to make sure you learn your way around our system.

    Be sure your name is on your work - in the file itself, not added as an afterthought. If you are submitting more than one page, staple them together.

    Remember that there will be a long queue at the printer just when the assignment is due. Don't wait until the last minute to print your memo.txt.

    What if you forgot your floppy disk?

    The lab computers are set up with temporary space allocated on the G: disk in folder G:\Temp\My Documents . If you have no floppy to put in drive A: you can do your work there. But then you cannot take it home with you. When you are done

    Part II

    This part of the assignment will be collected electronically at http://turnin.cs.umb.edu/. We will not accept hard copy.

    We have written programs to compile and test the your Java code, and prepare a package of your material for for the grader. It is your responsibility to make sure that you submit all the required files, with the right filenames - spelled correctly. Our software is case sensitive the program will not find Memo.txt if memo.txt was called for.

    Note: This is a long assignment. It is better to do part of it well then all of it poorly.

    If you can't finish, don't worry. You can redeem lots of partial credit by writing clearly about what you tried. (If you can't get started, do worry.)

    1. Read the the turnin instructions. Then log in and change your password.

    2. The rest of this assignment (and large parts of future assignments) will deal with the Java bank simulation discussed in JOI. We start with Exercise 1-2 in JOI. It's on page 19. To run the Bank simulation

      • Visit http://www.cs.umb.edu/~eb/110/hw1/Bank.class with your browser and save the file on your A: disk. Then do the same with http://www.cs.umb.edu/~eb/110/hw1/BankAccount.class.

      • Open XEmacs and visit your A: disk by typing Ctrl-x Ctrl-f and then just A: at the prompt. You should see a listing of all the files on your floppy.

      • On the Tools pulldown, click on Shell and then Shell again on the submenu, or (the easy way) type ctrl-x ctrl-r.

      • Run the Bank simulation in the new XEmacs buffer that opens by typing
        	java Bank
        

      Now do the exercise. Use XEmacs to write the results of your exploration in file memo.txt. (You can add to the file that's already on your A: disk.)

      You may (but need not) include a partial record of an actual Bank session in your memo.txt. If you want to do that you will want to learn how to copy text from one place in XEmacs and paste it in another: drag the mouse over the text you want to copy, select Copy from the Edit pulldown, move the cursor to where you want to paste, and select Paste from the Edit pulldown. (And, yes, you can do all this with just the keyboard. Find out by studying the XEmacs tutorial - go there by typing ctrl-h (for "help")and then t (for "tutorial").

    3. Now you are ready to start looking at some Java code. As you work on these exercises, record your progress in your memo.txt. Tell us what things were easy; what things were hard; what problems you encountered and how you solved them; what was interesting; what was boring ...

      This is essentially Exercise 1-1 in JOI. Every assignment for this course will require a memo.txt file like this one. This memo will count significantly in your grade. Do not wait to write it "until you get the answers right". Rather, write about your ongoing work as tool to help you master the material. Many find that writing the memo often helps them do a better job. Consider keeping part of your memo in the form of a diary, adding to it (with dated entries) each time you sit down to work on the computer.

      But diary format is not always best. When an assignment asks you to answer a particular question in your memo, please make sure that answer is labelled so that the grader can easily find it.

      The Java source code for the bank simulation on the JOI cd, and on the JOI web page in several forms.

      In this assignment you will make some changes to Bank.java. Find that file on the CD or the web page. Then copy it to your A: disk. (You can do that by visiting it with the browser and selecting Save).

      Edit the file in XEmacs: ctrl-x ctrl-f, then type Bank.java at the prompt.

      Tell XEmacs to compile the file: either ctrl-x ctrl-m or Compile from the Tools pulldown. The minibuffer will show the Compile command: prompt and the default entry javac *java, which means "compile all the .java files in the current folder). Type enter.

      Now run the Bank as before just to make sure it works as it always has.

      You are about to work on your first Java program. Before you start, learn these style guidelines:

      • Every well written program starts with a comment block indicating the file name, the original author and the date, followed by information about who may have modified the program, when and perhaps why. Any time you modify a program you should modify this comment block as appropriate, changing the file name if necessary and entering your name, the date and a brief description of the changes you have made. You will lose lots of credit in this course each time you fail to follow these instructions.

      • It is also good practice (for beginners) to put a short comment at each place where you modify a program. For this assignment the comment should start with the string "// @@@" so that the graders can easily find the places that you worked on.

    4. Your first task is to change the name of the Bank from Engulf and Devour to whatever name you choose. This is JOI Exercise 1-3a.
      • Edit your copy of Bank.java with XEmacs, find the place in the file where the name is set, and change it.
      • Save Bank.java and recompile. What happens if you try to recompile without saving the file first? What happens if there's a syntax error in your file?
      • Run the simulation as before.
      • Check that your change shows up in the output and write yourself a little note of congratulations in your memo.txt .

    5. JOI Exercise 1-3b: add a third BankAccount to the Bank:
      • Read Bank.java to locate the places where you want to make changes.
      • Edit Bank.java to make those changes. Be sure to preserve the look of the code - in particular, the way the lines are indented. Save your work.
      • Compile. Edit to fix any mistakes.
      • Run the program to test your changes. Edit to fix any mistakes, recompile and run again.
      • Write about your success (or failure) in memo.txt. Include an annotated fragment of your run (pasted from the XEmacs Shell buffer) demonstrating that your code works as it should.