TopPart 1Part 2

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:
  1. 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.
  2. 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.
  3. 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. The simplest 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. Note that for the second enhancement drop the onMouseClick method in favor of using the three methods:




The image above will be a working version of the simple laundry sorter if your web browser supports Java 1.1. You should experiment with this demonstration version to make sure you understand exactly what we have in mind.

Extra credit

We would like you to focus on getting the lab working, writing good comments, and using good style in your programming. If you have done all that and would like to do more, here is an opportunity to earn extra credit.

As described above, if the user drops their laundry outside of all baskets, it will count as an incorrect sorting. For extra credit, you can be nicer to the user. If he/she misses all the baskets, let him/her try again without increasing either the correct or incorrect counters.

Grading guidelines

As with last week's lab, your grade will have components based on style and on correctness. Please note that each week we will likely be adding new style guidelines that we will be looking for in your programs.

Grading Point Allocations

Value

Feature
Style, Design, and Efficiency (10 pts total)
2 pts. appropriate comments
2 pts. good variable names
2 pts. good use of constants
2 pts. appropriate formatting
1 pt. does not generate new objects unnecessarily
1 pts. design issues
Correctness (10 pts)
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 # correct and # incorrect appropriately
2 pts. drags swatch properly (-1 pt if use clicking instead of dragging)
2 pts. appropriate behavior if user does unexpected things like starting
to drag outside the laundry item
Extra credit (1 pt)
1 pt. does not update # correct or # incorrect sorted if user
misses all baskets.

Final remarks

Try to complete 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.

Turning in your program

Your program is due at 11p.m. on the evening two days after your lab (Wednesday if you are in the Monday lab, Thursday if you are in the Tuesday lab). As last time, you need to export your project before copying it to the dropoff Folder:

Good luck and have fun!


Computer Science 134
Department of Computer Science
Williams College


TopPart 1Part 2