Part 2
Once you get the basic version
working, we would like you to jazz it up a bit. Here are the
extensions we would like you to make:
- Add labels (Text items) at the bottom of the picture showing
the number of correct and incorrect placements. This makes it
clearer when the student succeeds in placing the item correctly.
They should read something like "correct = nn", "incorrect =
mm". The value in the first Text item will be formed by
concatenating the string "correct =" with an integer instance
variable which keeps track of the number of correct answers. The
other is similar.
- Users should drag the items to the correct laundry basket
rather than just clicking on the basket. Recall from the example
in class that you will need an instance variable to label the last
mouse position before the drag so you can determine how far to
drag the item. If the user presses the mouse button down outside
the laundry item, it should not increase the correct or the
incorrect counter.
- Assign the item a randomly generated color by randomly
choosing integers redNum, greenNum, and
blueNum between 0 and 255 for each of the red, blue, and
green components of the color. You can create a color from those
components by writing new
Color(redNum,greenNum,blueNum)).
Now define criteria for determining where each color
should go. A simple criterion is based on the sum of the
three color components. If the sum of the component numbers is
less than 230, decide it is dark, if it is greater than 600,
decide it is white. Otherwise it is colored. After you get the
program working you might want to experiment with other criteria.
We will let you figure out most of the details of how to add the
features for the more advanced versions. One piece of advice is that
for the second enhancement you will be dropping the
onMouseClick method in favor of using the three methods:
- onMousePress - for when the user first clicks on
the item - though remember that they might miss.
- onMouseDrag - to do the actual dragging (assuming they
clicked on it originally).
- onMouseRelease - if they were dragging it,
check to see if they've dropped
it in the right place when the mouse is released.
While we do not require you to bring a design document for this part
of the program, you will find it extremely helpful to make some notes
and sketch this out in advance, realizing that your work in part 1
will help you better understand how to do part 2.
Value | Feature |
| Design (1 pt total) |
1/2 | Variables and constants |
1/2 | Pseudo-code in begin & onMouseClick |
|
| Style, Design, and Efficiency (10 pts total) |
2 pts. | Descriptive comments |
2 pts. | Good variable names |
2 pts. | Good use of constants |
2 pts. | Appropriate formatting |
1 pt. | Does not generate new objects unnecessarily |
|
| Correctness (10 pts total) |
2 pts. | Generates a new color swatch only if previous one
placed correctly |
2 pts. | Swatch displayed in the correct initial position;
returns to original location if incorrectly sorted |
2 pts. | Updates number correct and incorrect properly |
2 pts. | Drags swatch properly (-1 pt if can use clicking instead
of dragging) |
2 pts. | Appropriate behavior if user does unexpected things
like starting to drag outside the swatch |
|
| Extra credit (1 pt) |
1 pt. | Does not update either # correct or # incorrect if
user misses all baskets |
|
Be sure to do the basic version of the lab before attempting the more
advanced features. Just work on adding one feature at a time, testing
each thoroughly before working on the next.
Your program is due at 11p.m. on Monday evening. Turn in your
program as you did last week. Here are the instructions again:
- First, return to Eclipse and make sure you included your name
and course number in a comment at the start of the program.
- Next, click on the "Laundry" project in the Package
Explorer panel on the left side of the Eclipse window.
- Now, select "Export" from the "File menu.
- Select "File system" in the dialog box and click next.
- Make sure the folder with your project has a check mark next
to it. (That will make all the files on the right have checks too!)
- Click the "Browse" button next to the "To directory:" entry.
- Double click on "Desktop".
- Click the "Finish" button. It will create a new folder on your
desktop.
- Quit Eclipse.
- Click on the new folder's name and type in a name for the
folder that identifies you and the lab you are working on, such as
"Yourname-Lab2" or "Yourname-Laundry" and then
click "OK". (Dashes in names are OK, but don't include spaces or
periods.)
- Open the cs051 folder icon to find the "dropbox" folder.
- Drag your new folder into the dropbox folder. When you do
this, the computer will warn you that you will not be able to look at
this folder. That is fine. Just click "OK".
- The new folder will still show up on your desktop. Drag it
into the trash both to save space and to keep anyone from copying it.
(Files in your CSC 051 folder are protected so that others cannot read
them.) Select "empty trash" from the file menu to completely
delete those files. Do NOT throw away the version of the program in your
workspace. You should save that so you can study it later.
If you should accidentally turn in a bad version of your program, you
may drag another copy in as long as you change the name to be slightly
different from the one you used before (e.g. Jane Doe - lab 2a). The
new name should make it clear which is the newer version.
Good luck and have fun!
Computer Science
051
Department of Computer Science
Pomona College