CSE143 Winter 2003

Project 0

Does Luck Know Your Name?

An Experiment in Computational Theology

Please read the following turn-in forms carefully, including the fine print!  After submitting a form, read what comes back, too. PLEASE make sure that you use the correct form for each part!!

Part A Turn-in form

Part B Turn-in form

Due dates: Part A (electronically): 9:00 pm Friday, Jan. 10; Part B (electronically): 9:00pm Monday, Jan. 13; paperwork for both parts: beginning of quiz section, Tuesday, January 14.  ["Paperwork" will always mean the printed electronic receipts, plus any written material (questions, diagrams, etc.) that might have been assigned.  Staple all such material together, please.]

When you cross your fingers, or say "wish me luck", you're invoking the god or goddess of luck, at least metaphorically.  But does that deity even know who you are?  Let's find out, using the latest tool of experimental theology: the computer.

Here's the idea.  If you pick a letter at random, it might be the first letter of your first name.  That would be a clear sign that you have Luck on your side.  If the letter you pick is not your initial, pick at random again.  Keep picking if necessary.  Eventually you might expect to draw your initial, unless the gods really hated you.  The sooner you draw your initial, the luckier you are. 

To make the sign from the gods even more definite, we'll draw two letters at once, and see if they match your first and last initials.  The fewer times you have to pick before the match, the more affection Luck has for you.  Each random letter is picked from the full set of 26 uppercase letters.  Each pick is completely independent.  If your first pick is "A", for example, that has no effect on how likely "A" is as the next pick.   If a pair of letters doesn't match your initials, we throw away both letters and draw another pair.

To implement this is Java, we have designed three classes.  You will need to read through the program code and comments carefully.  It will have information that is not in this write-up.   Your job will be to add code to make a Luck Tester.  With it, you and your friends can have hours of fun determining who you among you is truly the luckiest.

The classes are:

Written part

 

Some rules (for this project):

Some advice:

What about style?  Style and programming practice are taken seriously in CSE143.  We'll have much more to say about those topics as we go along.  For now, just use your best style, as you understand it.  We will look mainly to see that you are making a conscious and reasonable effort to be clear and consistent.  The basic philosophy is that a program must communicate well to a human reader as well as to a computer.

What about efficiency? Don't worry about it -- really!  Make the code correct and straightforward, and it will be efficient enough for now.  We will talk about efficiency in technical terms as the course progresses.

Part A specifics: Turn in the two classes, such that they compile without error on the turn-in server, and such that the resulting program executes without blowing up.  The program does not even have to produce any sensible output, or really do anything at all!  Do the minimum possible.  The entire focus is on the mechanics of Java and using the tools for building and turning in programs.

Part B specifics: Turn in the two classes again, such that the resulting program, executed on our servers, operates correctly.

A major goal of this project is to ensure that you have your computing environment set up properly, or can use the environment in the IPL successfully.  If the program compiles on your computer and not on ours when you turn it in -- then you're out of Luck (so to speak).  Find the problem and fix it, and turn in again.  (Of course, another goal of Project 0 is to make sure we have the course software and turn-in programs working properly!  There could be glitches...)

Notes on running from the command prompt.  Once the program is compiled, you can run it from a Windows command prompt.

For example, on my home machine, my project directory is C:\Documents and Settings\dickey\My Documents\MDJava\143-03wi-projects\poStarter\project0, so I open a command window with cmd, then change to C:\Documents and Settings\dickey\My Documents\MDJava\143-03wi-projects\poStarter.  Then I type java project0/P0Main "MD".  The last time I tried this, the result was:

Trial #:1 104 pairs before success, implying The gods smile upon you.

Trial #:2 262 pairs before success, implying The gods of luck are just a tiny bit displeased.

Trial #:3 2987 pairs before success, implying EXTREME DANGER -- the gods are wrathful unto thee.

Overall evaluation after 3 trials: 1117.6666666666667. The message is clear:

EXTREME DANGER -- the gods are wrathful unto thee.

Just my luck, so to speak.  Maybe yours will be better.