CS 280 Spring 2008

Assignment 3 –Using Existing Classes – String, Random

100 points

 

Assigned: 01/30/2008

Due: 02/06/2008 at the start of class

 

Pre-Lab (Do Before Lab):  Bring materials – a USB for a take home copy. Plan out your GUI, tasks, objects, and events needed for program. Plan out how you will solve the problem.

 

Main Assignment:

Imagine that you are writing some parts of a Scrabble ™ program.  We are a long way from being able to do the full job, so pay attention to what I’m asking for. You should create buttons to

1.      Draw 7 tiles at the start of the game. The chances of drawing each letter should be based on the number of tiles for each letter in Scrabble ™ (shown below). Furthermore, to get full credit, the chances of drawing a letter should be influenced by what has already been drawn (e.g. if you draw a ‘Z’ there should be no chance of drawing another ‘Z’). You probably will not figure out how to do this in a minute or less; you will have to think about it.  Think about it before Thursday’s lab!!

HINT: we have just talked about two library classes – Random and String; both are necessary (and we haven’t covered loops or branching, so those aren’t needed).

Also, it should make the Search capability (button, label, and text field, see below) visible.

2.      Clear – clears the displayed set of letters and hides the Search capability (button, label, and text field, see below)

3.      Exit – Exits from the program

4.      Search – reports where a specified letter (specified in a text field) is found in the current tiles (a String’s positions start with 0, so 0 means it is the first tile. -1 means the letter was not found). If the user enters more than one letter in the text field, the search can be done, but it will be searching for the letters in that order adjacent to each other.

·         Also, put your name on the GUI form as a jlabel.

·         You’re just beginning at setting up GUIs. Don’t worry too much about making the interface nice.  See my simple sample interface below - Don’t let that constrain your creativity. Use it to help understand what I see as the inputs and outputs.

·         But if you plan on working with 5.5 or higher version of the IDE, ask me about using layouts, panels etc so that your program will work with 5.0.

·         Please set the name of the project to something other than the default name (JavaApplication1, …).  

 

Hand in:

 

Miscellaneous:

Letter

Number of Tiles

Letter

Number of Tiles

Letter

Number of Tiles

Letter

Number of Tiles

A

9

H

2

O

8

V

2

B

2

I

9

P

2

W

2

C

2

J

1

Q

1

X

1

D

4

K

1

R

6

Y

2

E

12

L

4

S

4

Z

1

F

2

M

2

T

6

BLANK

2

G

3

N

6

U

4

 

 

 

o    Note that we haven’t done anything yet with making sure the user enters something reasonable – don’t worry about that.

o    MAKE SURE YOUR PROGRAM WORKS! (i.e. really has the appropriate chances of getting each letter, gets the correct answer when searching).

o    You MUST include some comments that explain your program in order to get full credit (for this program, there are a few complicated things that certainly should be explained (in English)).