![]() | ![]() | ![]() | Part 2 |
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. One piece of advice is that for the second enhancement you will be dropping 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. Unfortunately, for now this means that you will not see our demonstration program unless you are running Internet Explorer (at least if you are on a Mac). You should experiment with this demonstration version to make sure you understand exactly what we have in mind.
Value | Feature |
Style, Design, and Efficiency (10 pts total) | |
2 pts. | comments |
2 pts. | good names. |
2 pts. | constants. |
2 pts. | appropriate formatting. |
1 pt. | generates 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 |
Good luck and have fun!
![]() | ![]() | ![]() | Part 2 |