Computer Science 202
Introduction to Programming

Fall 2013, The College of Saint Rose

Programming Project 1: Random Flower
Due: 11:59 PM, Thursday, October 3, 2013

For this project, you are to write a Java program using objectdraw graphics primitives that draws a potted flower and displays a message on the canvas. The trick is that the flower's parts are placed at randomly chosen positions, and you must click on each part to move it into the correct spot.

You must work individually on this project. You may consult only Prof. Teresco for help. You may not discuss the programs with anyone else including your classmates and the computer science tutors until after everyone has submitted their programs. You may consult your own graded or ungraded lab submissions, your own class notes, and any class examples or notes available from the course web page. Think of this as an open-book lab exam. Any collaboration or consultation of unauthorized sources will be considered a breach of academic integrity and will be dealt with according to the course policies outlined on the syllabus.

While no written design will be graded for these programs, coming up with a written design is likely to be a beneficial first step.

Note that a significant portion of the credit for the project is for style, program design, documentation, and efficiency. While everyone should strive to earn all of the correctness points, you may find that a well-designed, thoroughly-commented program that makes appropriate use of variables and constants but does not quite implement all functionality will earn a higher grade than a perfectly-functioning program that uses poor variable names, does not use named constants, is uncommented, or is poorly formatted.

Have fun and good luck!


The flower drawn by your program should consist of at least 5 parts, each of which is one of objectdraw's graphics primitives (e.g., FilledRect, FramedOval, etc.). You may choose to use more than 5 parts to create a more interesting flower, but this is not necessary. The colors of the objects are your choice, but at least one of them should use a "custom" color created using RGB values.

Your program should start by placing the components of your flower at random positions in the upper-left portion of the canvas. When any of the parts is clicked, it should move into its final position on the lower-right part canvas so that the flower is displayed properly after all have been moved into place. If more than one flower part is at the location where the mouse is clicked, all such parts should be moved.

Additionally, an appropriate message should be displayed on the canvas when the mouse exits the window and which gets removed when the mouse reenters the window. There should be at least three different messages, and a message to display is chosen randomly each time the mouse exits the window.

A working solution for the program will appear below. Click inside the applet to interact with it.

Submitting Your Work

Before 11:59 PM, Thursday, October 3, 2013, submit your Java program for grading. There are three things you need to do to complete the submission: (i) upload a copy of your Java program (the .java file only) using Submission Box under assignment "RandomFlower", (ii) print a copy of your program and hand it to your instructor, and (iii) demonstrate the execution of your program for your instructor (2-day grace period for demos).

Don't forget to check your programs for compliance with the Style Guide for CSC 202 Programs before you submit!


This assignment is worth 100 points, which are distributed as follows:

> FeatureValueScore
Style, Design, and Efficiency (30%)
Appropriate comments 8
Good variable names and declaration types 7
Good use of constants 7
Appropriate formatting 3
Good overall design 5
Correctness (70%)
Appropriate final flower drawing 10
At least one custom color used 5
Flower parts randomly placed initially 15
Flower part moves into position when clicked 15
All flower parts under mouse click point move 10
Spring message displayed when mouse exits window 5
Spring message chosen randomly from at least three options 5
Spring message removed when mouse enters window 5
Total 100